Skip to content

Commit

Permalink
bitwise_and (#6715)
Browse files Browse the repository at this point in the history
* test torch tensor instance bitwise_and

* torch tensor instance bitwise_and

* fix lint error

* fix lint error
  • Loading branch information
Gitigi authored Nov 9, 2022
1 parent 96ed8d1 commit fd42152
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ivy/functional/frontends/torch/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def abs_(self):
self.data = self.abs()
return self.data

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

def contiguous(self, memory_format=None):
return self.data

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 @@ -1946,3 +1946,38 @@ def test_torch_instance_device(dtype_and_x, as_variable, native_array):
class_name="tensor",
method_name="device",
)


# bitwise_and
@handle_cmd_line_args
@given(
dtype_and_x=helpers.dtype_and_values(
available_dtypes=helpers.get_dtypes("integer"),
num_arrays=2,
)
)
def test_torch_instance_bitwise_and(
dtype_and_x,
as_variable,
native_array,
):
input_dtype, x = dtype_and_x
helpers.test_frontend_method(
input_dtypes_init=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=input_dtype,
as_variable_flags_method=as_variable,
num_positional_args_method=1,
native_array_flags_method=native_array,
all_as_kwargs_np_method={
"other": x[1],
},
frontend="torch",
class_name="tensor",
method_name="bitwise_and"
)

0 comments on commit fd42152

Please sign in to comment.