[TF FE] Refactor Tile and add layer test (#15584)

Signed-off-by: Kazantsev, Roman <roman.kazantsev@intel.com>
This commit is contained in:
Roman Kazantsev 2023-02-09 11:43:39 +04:00 committed by GitHub
parent 84ecacda26
commit 9cd23790c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 52 additions and 5 deletions

View File

@ -14,12 +14,13 @@ namespace tensorflow {
namespace op {
OutputVector translate_tile_op(const NodeContext& node) {
auto data = node.get_input(0);
auto repeats = node.get_input(1);
default_op_checks(node, 2, {"Tile", "TILE"});
auto input = node.get_input(0);
auto multiples = node.get_input(1);
auto res = make_shared<Tile>(data, repeats);
set_node_name(node.get_name(), res);
return res->outputs();
auto tile = make_shared<Tile>(input, multiples);
set_node_name(node.get_name(), tile);
return {tile};
}
} // namespace op

View 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 TestTile(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
assert 'input' in inputs_info
assert 'multiples' in inputs_info
input_shape = inputs_info['input']
multiples_shape = inputs_info['multiples']
inputs_data = {}
inputs_data['input'] = np.random.randint(-50, 50, input_shape).astype(np.float32)
inputs_data['multiples'] = np.random.randint(1, 4, multiples_shape).astype(np.int32)
return inputs_data
def create_tile_net(self, input_shape):
tf.compat.v1.reset_default_graph()
# Create the graph and model
with tf.compat.v1.Session() as sess:
input = tf.compat.v1.placeholder(tf.float32, input_shape, 'input')
multiples = tf.compat.v1.placeholder(tf.int32, [len(input_shape)], 'multiples')
tf.raw_ops.Tile(input=input, multiples=multiples)
tf.compat.v1.global_variables_initializer()
tf_net = sess.graph_def
return tf_net, None
test_data_basic = [
dict(input_shape=[2, 4]),
dict(input_shape=[3, 1, 2]),
]
@pytest.mark.parametrize("params", test_data_basic)
@pytest.mark.precommit_tf_fe
@pytest.mark.nightly
def test_tile_basic(self, params, ie_device, precision, ir_version, temp_dir,
use_new_frontend, use_old_api):
self._test(*self.create_tile_net(**params),
ie_device, precision, ir_version, temp_dir=temp_dir,
use_new_frontend=use_new_frontend, use_old_api=use_old_api)