"git@developer.sourcefind.cn:chenpangpang/transformers.git" did not exist on "8ac840ff8758fb242e3e89cbc809366165ccf960"
Unverified Commit 25e1af36 authored by Sylvain Gugger's avatar Sylvain Gugger Committed by GitHub
Browse files

Fix #10128 (#11248)

parent 63ca4023
...@@ -72,7 +72,7 @@ def torch_pad_and_concatenate(tensor1, tensor2, padding_index=-100): ...@@ -72,7 +72,7 @@ def torch_pad_and_concatenate(tensor1, tensor2, padding_index=-100):
def numpy_pad_and_concatenate(array1, array2, padding_index=-100): def numpy_pad_and_concatenate(array1, array2, padding_index=-100):
"""Concatenates `array1` and `array2` on first axis, applying padding on the second if necessary.""" """Concatenates `array1` and `array2` on first axis, applying padding on the second if necessary."""
if len(array1.shape) == 1 or array1.shape[1] == array2.shape[1]: if len(array1.shape) == 1 or array1.shape[1] == array2.shape[1]:
return np.concatenate((array1, array2), dim=0) return np.concatenate((array1, array2), axis=0)
# Let's figure out the new shape # Let's figure out the new shape
new_shape = (array1.shape[0] + array2.shape[0], max(array1.shape[1], array2.shape[1])) + array1.shape[2:] new_shape = (array1.shape[0] + array2.shape[0], max(array1.shape[1], array2.shape[1])) + array1.shape[2:]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment