Skip to content

Commit

Permalink
fix: Fixed paddle_backend.divide (#28063)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sai-Suraj-27 authored Jan 30, 2024
1 parent 7b0bdad commit b33ed80
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions ivy/functional/backends/paddle/elementwise.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,12 +402,13 @@ def divide(
*,
out: Optional[paddle.Tensor] = None,
) -> paddle.Tensor:
if paddle.is_complex(x1) or paddle.is_complex(x2):
angle_value = paddle.angle(x1) - paddle.angle(x2)
abs_value = paddle.abs(x1) / paddle.abs(x2)
return paddle.complex(
abs_value * paddle.cos(angle_value), abs_value * paddle.sin(angle_value)
)
if isinstance(x1, paddle.Tensor) and isinstance(x2, paddle.Tensor):
if paddle.is_complex(x1) or paddle.is_complex(x2):
angle_value = paddle.angle(x1) - paddle.angle(x2)
abs_value = paddle.abs(x1) / paddle.abs(x2)
return paddle.complex(
abs_value * paddle.cos(angle_value), abs_value * paddle.sin(angle_value)
)
x1, x2, ret_dtype = _elementwise_helper(x1, x2)
return (x1 / x2).astype(ret_dtype)

Expand Down

0 comments on commit b33ed80

Please sign in to comment.