Skip to content

Commit

Permalink
update the paddle backend of ivy.stack to work for empty arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
AnnaTz authored and sushmanthreddy committed Aug 17, 2023
1 parent 52a4b32 commit 3a8c7b6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ivy/functional/backends/paddle/manipulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,12 @@ def stack(

arrays = list(map(lambda x: x.cast(dtype), arrays))

first_shape = arrays[0].shape
if not all(arr.shape == first_shape for arr in arrays):
raise Exception("Shapes of all inputs must match")
if 0 in first_shape:
return ivy.empty(first_shape[:axis] + [len(arrays)] + first_shape[axis:], dtype=dtype)

if dtype in [paddle.int8, paddle.int16, paddle.uint8, paddle.float16, paddle.bool]:
arrays = list(map(lambda x: x.cast("float32"), arrays))
return paddle.stack(arrays, axis=axis).cast(dtype)
Expand Down

0 comments on commit 3a8c7b6

Please sign in to comment.