[TF FE] Support Atan2 operation for TensorFlow models (#21076)
* Create atan2.cpp * Update common_op_table.hpp Adds atan2 operation to the list * Update op_table.cpp Adds atan2 to the list of BinaryOp. * Create test_tf_Atan2.py Adds test for Atan2. * Update src/frontends/tensorflow_common/src/op/atan2.cpp Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com> * Update src/frontends/tensorflow/src/op_table.cpp Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com> * Update atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com> * Update atan2.cpp declares x and y , explicitly mentions conditions * Update atan2.cpp * Update atan2.cpp Adds versions. * Update atan2.cpp adds namespace * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update atan2.cpp Clang format * Update atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update src/frontends/tensorflow_common/src/op/atan2.cpp * Update test_tf_Atan2.py fixes the datatype of y * Update tests/layer_tests/tensorflow_tests/test_tf_Atan2.py * Update test_tf_Atan2.py shape to float * Update tests/layer_tests/tensorflow_tests/test_tf_Atan2.py * Update tests/layer_tests/tensorflow_tests/test_tf_Atan2.py * Update tests/layer_tests/tensorflow_tests/test_tf_Atan2.py * Update test_tf_Atan2.py Makes the range of input inclusive for x<0 and y<0. * Update src/frontends/tensorflow_common/src/op/atan2.cpp --------- Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com>
This commit is contained in:
46
tests/layer_tests/tensorflow_tests/test_tf_Atan2.py
Normal file
46
tests/layer_tests/tensorflow_tests/test_tf_Atan2.py
Normal file
@@ -0,0 +1,46 @@
|
||||
# Copyright (C) 2018-2023 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import numpy as np
|
||||
import pytest
|
||||
import tensorflow as tf
|
||||
from common.tf_layer_test_class import CommonTFLayerTest
|
||||
|
||||
|
||||
class TestAtan2(CommonTFLayerTest):
|
||||
def _prepare_input(self, inputs_info):
|
||||
assert 'y' in inputs_info
|
||||
assert 'x' in inputs_info
|
||||
y_shape = inputs_info['y']
|
||||
x_shape = inputs_info['x']
|
||||
inputs_data = {}
|
||||
inputs_data['y'] = np.random.rand(*y_shape).astype(self.input_type) - np.random.rand(*y_shape).astype(self.input_type)
|
||||
inputs_data['x'] = np.random.rand(*x_shape).astype(self.input_type) - np.random.rand(*x_shape).astype(self.input_type)
|
||||
return inputs_data
|
||||
|
||||
def create_atan2_net(self, input_shape, input_type):
|
||||
self.input_type = input_type
|
||||
tf.compat.v1.reset_default_graph()
|
||||
# Create the graph and model
|
||||
with tf.compat.v1.Session() as sess:
|
||||
y = tf.compat.v1.placeholder(input_type, input_shape, 'y')
|
||||
x = tf.compat.v1.placeholder(input_type, input_shape, 'x')
|
||||
tf.raw_ops.Atan2(y=y, x=x)
|
||||
tf.compat.v1.global_variables_initializer()
|
||||
tf_net = sess.graph_def
|
||||
|
||||
return tf_net, None
|
||||
|
||||
test_data_basic = [
|
||||
dict(input_shape=[1, 2], input_type=np.float32),
|
||||
dict(input_shape=[2, 3, 4], input_type=np.float32),
|
||||
]
|
||||
|
||||
@pytest.mark.parametrize("params", test_data_basic)
|
||||
@pytest.mark.precommit_tf_fe
|
||||
@pytest.mark.nightly
|
||||
def test_atan2_basic(self, params, ie_device, precision, ir_version, temp_dir,
|
||||
use_new_frontend, use_old_api):
|
||||
self._test(*self.create_atan2_net(**params),
|
||||
ie_device, precision, ir_version, temp_dir=temp_dir,
|
||||
use_new_frontend=use_new_frontend, use_old_api=use_old_api)
|
||||
Reference in New Issue
Block a user