forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_tf_Roll.py
52 lines (41 loc) · 2.35 KB
/
test_tf_Roll.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
from common.utils.tf_utils import permute_nchw_to_nhwc
class TestTFRoll(CommonTFLayerTest):
def create_tf_roll_net(self, shift, axis, x_shape, input_type, ir_version, use_new_frontend):
tf.compat.v1.reset_default_graph()
# Create the graph and model
with tf.compat.v1.Session() as sess:
tf_x_shape = x_shape.copy()
tf_x_shape = permute_nchw_to_nhwc(tf_x_shape, use_new_frontend)
x = tf.compat.v1.placeholder(input_type, tf_x_shape, 'Input')
roll = tf.roll(x, shift=shift, axis=axis)
tf.compat.v1.global_variables_initializer()
tf_net = sess.graph_def
# TODO: add reference IR net. Now it is omitted and tests only inference result that is more important
ref_net = None
return tf_net, ref_net
test_data = [dict(shift=[1], axis=[-1], x_shape=[4, 3], input_type=tf.float32),
pytest.param(dict(shift=[1, 5, -7], axis=[0, 1, 1], x_shape=[2, 3, 5], input_type=tf.float16),
marks=pytest.mark.precommit_tf_fe),
dict(shift=[11, -8], axis=[-1, -2], x_shape=[3, 4, 3, 1], input_type=tf.int32),
dict(shift=[7, -2, 5], axis=[0, -1, -1], x_shape=[5, 2, 3, 7],
input_type=tf.int64),
dict(shift=[3, 7], axis=[0, 1], x_shape=[2, 4, 3, 5, 4], input_type=tf.half),
pytest.param(
dict(shift=[1, -2], axis=[0, 1], x_shape=[2, 4, 3, 5], input_type=tf.float32),
marks=pytest.mark.precommit)]
@pytest.mark.parametrize("params", test_data)
@pytest.mark.nightly
def test_tf_roll(self, params, ie_device, precision, ir_version, temp_dir, use_new_frontend,
use_old_api):
if ie_device == 'GPU':
pytest.skip("Roll is not supported on GPU")
self._test(*self.create_tf_roll_net(**params, ir_version=ir_version,
use_new_frontend=use_new_frontend), ie_device,
precision,
temp_dir=temp_dir, ir_version=ir_version, use_new_frontend=use_new_frontend,
use_old_api=use_old_api, **params)