Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added torch instance method cos and tested #5785

Merged
merged 2 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions ivy/functional/frontends/torch/Tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def sinh_(self):
self.data = self.sinh()
return self.data

def cos(self, *, out=None):
return torch_frontend.cos(self.data, out=out)

def view(self, shape):
self.data = torch_frontend.reshape(self.data, shape)
return self.data
Expand Down
34 changes: 34 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 @@ -156,6 +156,40 @@ def test_torch_instance_sin_(
)


# cos
@handle_cmd_line_args
@given(
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("float"),
allow_inf=False,
),
)
def test_torch_instance_cos(
dtype_and_x,
as_variable,
native_array,
):
input_dtype, x = dtype_and_x
assume("bfloat16" not in input_dtype)
helpers.test_frontend_method(
input_dtypes_init=["float64"] + input_dtype,
as_variable_flags_init=as_variable,
num_positional_args_init=1,
native_array_flags_init=native_array,
all_as_kwargs_np_init={
"data": x[0],
},
input_dtypes_method=["float64"] + input_dtype,
as_variable_flags_method=as_variable,
num_positional_args_method=0,
native_array_flags_method=native_array,
all_as_kwargs_np_method={},
frontend="torch",
class_name="tensor",
method_name="cos",
)


# sinh
@handle_cmd_line_args
@given(
Expand Down