Skip to content

Commit

Permalink
fix: torch frontend Tensor.__bool__ now returning bools, Tensor.type_…
Browse files Browse the repository at this point in the history
…as returning new tensor instead of operating inplace and fixed signature for unique_consecutive (ivy-llc#27887)
  • Loading branch information
mattbarrett98 authored Jan 9, 2024
1 parent aa1561c commit 45b563c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ivy/functional/frontends/torch/reduction_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def unique(input, sorted=True, return_inverse=False, return_counts=False, dim=No
"torch",
)
@to_ivy_arrays_and_back
def unique_consecutive(input, return_inverse, return_counts, dim):
def unique_consecutive(input, return_inverse=False, return_counts=False, dim=None):
output, inverse_indices, counts = ivy.unique_consecutive(input, axis=dim)
ret = (output,)
if return_inverse:
Expand Down
4 changes: 2 additions & 2 deletions ivy/functional/frontends/torch/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ def type(self, dtype=None, non_blocking=False, **kwargs):
@with_unsupported_dtypes({"2.1.2 and below": ("bfloat16",)}, "torch")
def type_as(self, other):
if self.dtype != other.dtype:
self.ivy_array = ivy.astype(self.ivy_array, other.dtype)
return torch_frontend.tensor(ivy.astype(self.ivy_array, other.dtype))
return self

def byte(self, memory_format=None):
Expand Down Expand Up @@ -1185,7 +1185,7 @@ def bernoulli(self, *, generator=None, out=None):

def __bool__(self):
if len(self.shape) == sum(self.shape):
return torch_frontend.tensor(self.ivy_array.to_scalar().__bool__())
return self.ivy_array.to_scalar().__bool__()
raise ValueError(
"The truth value of an array with more than one element is ambiguous. "
"Use a.any() or a.all()"
Expand Down

0 comments on commit 45b563c

Please sign in to comment.