From c9a14db78ef417b1e3f71520c3bbbdeb933cae8c Mon Sep 17 00:00:00 2001 From: Ahmed Qazi <67039553+ahmedqazi123@users.noreply.github.com> Date: Sat, 21 Jan 2023 18:54:36 +0500 Subject: [PATCH] bitwise_or (#9861) * bitwise_or Close #9848 * bitwise_or Close #9848 * Update test_tensor.py * Update test_tensor.py * Update tensor.py * Update tensor.py --- ivy/functional/frontends/torch/tensor.py | 3 ++ .../test_frontends/test_torch/test_tensor.py | 40 +++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/ivy/functional/frontends/torch/tensor.py b/ivy/functional/frontends/torch/tensor.py index 39e02944bde73..92c30061d61c6 100644 --- a/ivy/functional/frontends/torch/tensor.py +++ b/ivy/functional/frontends/torch/tensor.py @@ -256,6 +256,9 @@ def abs_(self): def bitwise_and(self, other): return torch_frontend.bitwise_and(self._ivy_array, other) + def bitwise_or(self, other, *, out=None): + return torch_frontend.bitwise_or(self._ivy_array, other) + def contiguous(self, memory_format=None): return torch_frontend.tensor(self.ivy_array) diff --git a/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py b/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py index b1af35ee0876d..402939f915219 100644 --- a/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py +++ b/ivy_tests/test_ivy/test_frontends/test_torch/test_tensor.py @@ -2778,6 +2778,46 @@ def test_torch_instance_bitwise_and( ) +# bitwise_or +@handle_frontend_method( + class_tree=CLASS_TREE, + init_tree="torch.tensor", + method_name="bitwise_or", + dtype_and_x=helpers.dtype_and_values( + available_dtypes=helpers.get_dtypes("integer"), + num_arrays=2, + ), +) +def test_torch_instance_bitwise_or( + dtype_and_x, + init_num_positional_args: pf.NumPositionalArgFn, + method_num_positional_args: pf.NumPositionalArgMethod, + as_variable: pf.AsVariableFlags, + native_array: pf.NativeArrayFlags, + frontend_method_data, + frontend, +): + input_dtype, x = dtype_and_x + helpers.test_frontend_method( + init_input_dtypes=input_dtype, + init_as_variable_flags=as_variable, + init_num_positional_args=init_num_positional_args, + init_native_array_flags=native_array, + init_all_as_kwargs_np={ + "data": x[0], + }, + method_input_dtypes=input_dtype, + method_as_variable_flags=as_variable, + method_num_positional_args=method_num_positional_args, + method_native_array_flags=native_array, + method_all_as_kwargs_np={ + "other": x[1], + }, + frontend_method_data=frontend_method_data, + frontend=frontend, + ) + + # add_ @handle_frontend_method( class_tree=CLASS_TREE,