Skip to content

Commit

Permalink
feat torch frontends: adding a few missing frontends to the torch.Ten…
Browse files Browse the repository at this point in the history
…sor class.
  • Loading branch information
YushaArif99 committed Sep 14, 2024
1 parent 9321152 commit b5b4b49
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ivy/functional/frontends/torch/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ def get_device(self):
else:
return int(self.device.split(":")[-1])

@property
def itemsize(self):
return self.element_size()

# Setters #
# --------#

Expand Down Expand Up @@ -721,6 +725,12 @@ def detach_(self):
self.ivy_array = ivy.inplace_update(self.ivy_array, ret.ivy_array)
return self

def cpu(self):
return ivy.to_device(self.ivy_array, "cpu")

def cuda(self):
return ivy.to_device(self.ivy_array, "gpu:0")

@with_unsupported_dtypes({"2.2 and below": ("uint16",)}, "torch")
@numpy_to_torch_style_args
def unsqueeze(self, dim):
Expand Down Expand Up @@ -1543,6 +1553,10 @@ def item(self):
"only one element tensors can be converted to Python scalars"
)

def element_size(self):
dtype = ivy.dtype(self.ivy_array)
return int(ivy.dtype_bits(dtype) // 8)

@numpy_to_torch_style_args
@with_unsupported_dtypes({"2.2 and below": ("float16",)}, "torch")
def cumprod(self, dim, dtype=None):
Expand Down

0 comments on commit b5b4b49

Please sign in to comment.