Skip to content

Commit

Permalink
Add Instance Methods to PyTorch Frontend #3612 - sinc #21142 (#21144)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkoziell authored Aug 14, 2023
1 parent c252035 commit 35f36db
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ivy/functional/frontends/torch/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,18 @@ def quantile(self, q, dim=None, keepdim=False, *, interpolation="linear", out=No
self, q, axis=dim, keepdims=keepdim, interpolation=interpolation, out=out
)

@with_unsupported_dtypes(
{
"2.0.1 and below": (
"float16",
"bfloat16",
)
},
"torch",
)
def sinc(self):
return torch_frontend.sinc(self)


class Size(tuple):
def __new__(cls, iterable=()):
Expand Down
35 changes: 35 additions & 0 deletions ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11929,3 +11929,38 @@ def test_torch_tensor_quantile(
method_flags=method_flags,
on_device=on_device,
)


@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="torch.tensor",
method_name="sinc",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
),
)
def test_torch_instance_sinc(
*,
dtype_and_x,
frontend,
backend_fw,
frontend_method_data,
init_flags,
method_flags,
on_device,
):
input_dtype, x = dtype_and_x
helpers.test_frontend_method(
init_input_dtypes=input_dtype,
init_all_as_kwargs_np={
"data": x[0],
},
method_input_dtypes=input_dtype,
method_all_as_kwargs_np={},
frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
frontend=frontend,
backend_to_test=backend_fw,
on_device=on_device,
)

0 comments on commit 35f36db

Please sign in to comment.