From ec181873c96b3df4c7ca5006b64b11e78acb1551 Mon Sep 17 00:00:00 2001 From: siddhant-0707 Date: Fri, 20 Oct 2023 16:09:12 +0530 Subject: [PATCH] requested changes --- src/frontends/pytorch/src/op/is_nonzero.cpp | 14 +++----------- tests/layer_tests/pytorch_tests/test_is_nonzero.py | 2 +- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/frontends/pytorch/src/op/is_nonzero.cpp b/src/frontends/pytorch/src/op/is_nonzero.cpp index cd0e923b6852ce..e35b901ed8d426 100644 --- a/src/frontends/pytorch/src/op/is_nonzero.cpp +++ b/src/frontends/pytorch/src/op/is_nonzero.cpp @@ -4,7 +4,6 @@ #include "openvino/frontend/pytorch/node_context.hpp" #include "openvino/op/constant.hpp" -#include "openvino/op/convert.hpp" #include "openvino/op/not_equal.hpp" #include "pt_framework_node.hpp" #include "utils.hpp" @@ -20,17 +19,10 @@ OutputVector translate_is_nonzero(const NodeContext& context) { num_inputs_check(context, 1, 1); auto input = context.get_input(0); - Output zero_tensor = context.mark_node(v0::Constant::create(element::f32, Shape{1}, {0.0})); - auto false_tensor = context.mark_node(v0::Constant::create(element::boolean, Shape{1}, {false})); + Output zero_tensor = context.mark_node(v0::Constant::create(element::boolean, Shape{1}, {false})); - std::shared_ptr result; - - if (input.get_element_type() == element::boolean) { - result = context.mark_node(std::make_shared(input, false_tensor)); - } else { - align_eltwise_input_types(context, input, zero_tensor); - result = context.mark_node(std::make_shared(input, zero_tensor)); - } + align_eltwise_input_types(context, input, zero_tensor); + auto result = context.mark_node(std::make_shared(input, zero_tensor)); return {result}; }; diff --git a/tests/layer_tests/pytorch_tests/test_is_nonzero.py b/tests/layer_tests/pytorch_tests/test_is_nonzero.py index 2cd63d6a80ad00..0b9dbf1d410e9e 100644 --- a/tests/layer_tests/pytorch_tests/test_is_nonzero.py +++ b/tests/layer_tests/pytorch_tests/test_is_nonzero.py @@ -8,7 +8,7 @@ from pytorch_layer_test_class import PytorchLayerTest -@pytest.mark.parametrize('input_tensor', (np.array([0.]), np.array([1.5]), np.array([False]), np.array([3]), np.array([1, 3, 5]))) +@pytest.mark.parametrize('input_tensor', (np.array([0.]), np.array([1.5]), np.array([False]), np.array([3]))) class TestIsNonZero(PytorchLayerTest): def _prepare_input(self):