Skip to content

Commit

Permalink
[OPS] Add torch.Tensor.sin, torch.Tensor.cos and `torch._C._nn.pa…
Browse files Browse the repository at this point in the history
…d` (#175)

1. Add  `torch.Tensor.sin` and `torch.Tensor.cos` to `register_method`
Gemma passed after that.

2. Add `torch._C._nn.pad` 
Test Workflow works with torch 2.3.0 after that
  • Loading branch information
vadiklyutiy committed Jul 22, 2024
1 parent 742a6b6 commit cafaeed
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/hidet/graph/frontend/torch/register_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1263,6 +1263,7 @@ def isinf(x: Tensor) -> Tensor:
return ops.isinf(x)


@register_function(torch._C._nn.pad)
@register_function(torch.nn.functional.pad)
def torch_pad(x: Tensor, pad: Union[Tuple[int, ...], List[int]], mode: str = 'constant', value=0):
if isinstance(pad, tuple):
Expand Down
10 changes: 10 additions & 0 deletions python/hidet/graph/frontend/torch/register_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,3 +312,13 @@ def tensor_new_zeros(self: Tensor, *size, dtype=None, layout=None, device=None,
@register_method(torch.Tensor.zero_)
def tensor_zero_(self: Tensor):
return ops.full(self.shape, dtype=self.dtype, device=self.device, value=self.dtype.zero)


@register_method(torch.Tensor.sin)
def sin(x: Tensor):
return ops.sin(x)


@register_method(torch.Tensor.cos)
def cos(x: Tensor):
return ops.cos(x)

0 comments on commit cafaeed

Please sign in to comment.