Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into shape
Browse files Browse the repository at this point in the history
  • Loading branch information
fnhirwa committed Feb 9, 2024
2 parents d91d866 + 81a0371 commit 1c188a8
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 39 deletions.
2 changes: 1 addition & 1 deletion ivy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def __rmod__(self, other):
return other % self._shape

def __reduce__(self):
return (self._shape,)
return (self.__class__, (self._shape,))

def as_dimension(self, other):
if isinstance(other, self._shape):
Expand Down
28 changes: 15 additions & 13 deletions ivy/functional/backends/paddle/elementwise.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# global
from typing import Union, Optional

import math
from typing import Optional, Union

import paddle
import ivy.functional.backends.paddle as paddle_backend

import ivy
import ivy.functional.backends.paddle as paddle_backend
from ivy import promote_types_of_inputs
from ivy.func_wrapper import (
with_unsupported_device_and_dtypes,
with_supported_device_and_dtypes,
with_supported_dtypes,
with_unsupported_device_and_dtypes,
with_unsupported_dtypes,
)

Expand Down Expand Up @@ -340,15 +341,8 @@ def less(
return paddle.less_than(x1, x2)


@with_unsupported_dtypes(
{
"2.6.0 and below": (
"int8",
"int16",
"uint8",
"float16",
)
},
@with_supported_dtypes(
{"2.6.0 and below": ("bool", "int32", "int64", "float32", "float64", "complex")},
backend_version,
)
def multiply(
Expand All @@ -359,6 +353,14 @@ def multiply(
out: Optional[paddle.Tensor] = None,
) -> paddle.Tensor:
x1, x2, ret_dtype = _elementwise_helper(x1, x2)
if isinstance(x1, paddle.Tensor) and isinstance(x2, paddle.Tensor):
if paddle.is_complex(x1) or paddle.is_complex(x2):
a, b = x1.real(), x1.imag()
c, d = x2.real(), x2.imag()
real = a * c - b * d
imag = a * d + b * c
return paddle.complex(real, imag)

return paddle.multiply(x1, x2).astype(ret_dtype)


Expand Down
1 change: 1 addition & 0 deletions ivy/functional/backends/tensorflow/device.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def dev(
dv = x.device
if as_native:
return dv
dv = dv if dv else ivy.default_device(as_native=False)
return as_ivy_dev(dv)


Expand Down
Loading

0 comments on commit 1c188a8

Please sign in to comment.