Skip to content

Commit

Permalink
bernoulli_instance (ivy-llc#19445)
Browse files Browse the repository at this point in the history
Co-authored-by: Anwaar Khalid <shahanwaar.khalid8@gmail.com>
  • Loading branch information
ManoBharathi93 and hello-fri-end authored Jul 18, 2023
1 parent 05f3151 commit 4b87926
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ivy/functional/frontends/torch/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,10 @@ def addr_(self, vec1, vec2, *, beta=1, alpha=1):
def dot(self, tensor):
return torch_frontend.dot(self, tensor)

@with_supported_dtypes({"2.0.1 and below": ("float32", "float64")}, "torch")
def bernoulli(self, *, generator=None, out=None):
return torch_frontend.bernoulli(self._ivy_array, generator=generator, out=out)

# Special Methods #
# -------------------#

Expand Down
32 changes: 32 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 @@ -1726,6 +1726,38 @@ def test_torch_instance_aminmax(
)


# bernoulli
@handle_frontend_method(
class_tree=CLASS_TREE,
init_tree="torch.tensor",
method_name="bernoulli",
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("valid"),
),
test_with_out=st.just(True),
)
def test_torch_instance_bernoulli(
dtype_and_x,
frontend,
frontend_method_data,
init_flags,
method_flags,
):
input_dtype, x = dtype_and_x
helpers.test_frontend_method(
init_input_dtypes=input_dtype,
init_all_as_kwargs_np={
"input": x[0],
},
method_input_dtypes=input_dtype,
method_all_as_kwargs_np={"generator": x[1], "out": x[2]},
frontend_method_data=frontend_method_data,
init_flags=init_flags,
method_flags=method_flags,
frontend=frontend,
)


# contiguous
@handle_frontend_method(
class_tree=CLASS_TREE,
Expand Down

0 comments on commit 4b87926

Please sign in to comment.