Skip to content

Commit

Permalink
[Wav2Vec2] Fix dtype 64 bug (#13517)
Browse files Browse the repository at this point in the history
* fix

* 2nd fix
  • Loading branch information
patrickvonplaten committed Sep 10, 2021
1 parent 2c51442 commit a5fc344
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Expand Up @@ -210,7 +210,7 @@ def __call__(
raw_speech = [np.asarray(speech) for speech in raw_speech]
elif not is_batched and not isinstance(raw_speech, np.ndarray):
raw_speech = np.asarray(raw_speech)
elif isinstance(raw_speech, np.ndarray) and raw_speech.dtype is np.float64:
elif isinstance(raw_speech, np.ndarray) and raw_speech.dtype is np.dtype(np.float64):
raw_speech = raw_speech.astype(np.float32)

# always return batch
Expand Down
Expand Up @@ -207,10 +207,10 @@ def __call__(
elif (
not isinstance(input_values, np.ndarray)
and isinstance(input_values[0], np.ndarray)
and input_values[0].dtype is np.float64
and input_values[0].dtype is np.dtype(np.float64)
):
padded_inputs["input_values"] = [array.astype(np.float32) for array in input_values]
elif isinstance(input_values, np.ndarray) and input_values.dtype is np.float64:
elif isinstance(input_values, np.ndarray) and input_values.dtype is np.dtype(np.float64):
padded_inputs["input_values"] = input_values.astype(np.float32)

# convert attention_mask to correct format
Expand Down

0 comments on commit a5fc344

Please sign in to comment.