* add arm as a matrix for build job * uncomment * comment * try inside pipeline * check location * another dirs * try to privide correct action path * use corrected action * use newer commit * use newer commit * use newer commit * use newer action commit * add setting * rm from pipeline, adapt action iteslf * add missing deps * enable samples and debian jobs * correct yml * correct image name * correct syntax, use self-hosted option * enable onnx runtime and c++, use newer action * enable Python and CPU Func tests * add missing deps for arm64 * increase timeout for python tests * disable some tests, add more time * skip failing tests * skip speech sample test on arm * dummy chang * skip mxnet mo on arm, run all tests * rm quotes * separate linux x86 and arm64 workflows * rm unused matrix refs, add timeouts * add skips for c++ tests and some Python tests * correct cache keys, extend timeout * skip more python tests * add more skips: for python and CPU func * extend cpu func list with skips * disable cpu func tests and python api 2.0 tests * rm disable job * styling, rm pr trigger, rm always(), rm unnecessary changes * revert * use ifs instead of comments, provide better wording for skips
60 lines
2.9 KiB
Python
60 lines
2.9 KiB
Python
# Copyright (C) 2018-2023 Intel Corporation
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
import platform
|
|
|
|
import numpy as np
|
|
import pytest
|
|
import tensorflow as tf
|
|
from common.tf_layer_test_class import CommonTFLayerTest
|
|
|
|
|
|
class TestTopKV2(CommonTFLayerTest):
|
|
def _prepare_input(self, inputs_info):
|
|
# generate elements so that the input tensor may contain repeating elements
|
|
assert 'input' in inputs_info, "Test error: inputs_info must contain `input`"
|
|
x_shape = inputs_info['input']
|
|
inputs_data = {}
|
|
inputs_data['input'] = np.random.randint(-10, 10, x_shape)
|
|
return inputs_data
|
|
|
|
def create_topk_v2_net(self, input_shape, input_type, k, sorted, is_first_output, is_second_output):
|
|
tf.compat.v1.reset_default_graph()
|
|
with tf.compat.v1.Session() as sess:
|
|
input = tf.compat.v1.placeholder(input_type, input_shape, 'input')
|
|
k = tf.constant(k, dtype=tf.int32, shape=[])
|
|
topk = tf.raw_ops.TopKV2(input=input, k=k, sorted=sorted)
|
|
if is_first_output:
|
|
tf.identity(topk[0], name='topk_values')
|
|
if is_second_output:
|
|
tf.identity(topk[1], name='unique_indices')
|
|
tf.compat.v1.global_variables_initializer()
|
|
tf_net = sess.graph_def
|
|
|
|
ref_net = None
|
|
return tf_net, None
|
|
|
|
test_basic = [
|
|
dict(input_shape=[10], input_type=tf.float32, k=5, sorted=True, is_first_output=True, is_second_output=False),
|
|
dict(input_shape=[2, 3, 10], input_type=tf.int32, k=10, sorted=True, is_first_output=True,
|
|
is_second_output=False),
|
|
dict(input_shape=[4, 12], input_type=tf.float32, k=10, sorted=True, is_first_output=True,
|
|
is_second_output=True),
|
|
# Expect stable mode implementation for sort_type=indices in OpenVINO. See 101503
|
|
pytest.param(dict(input_shape=[5, 10], input_type=tf.int32, k=8, sorted=False, is_first_output=True,
|
|
is_second_output=True), marks=pytest.mark.xfail(reason="101503")),
|
|
]
|
|
|
|
@pytest.mark.parametrize("params", test_basic)
|
|
@pytest.mark.precommit_tf_fe
|
|
@pytest.mark.nightly
|
|
@pytest.mark.xfail(condition=platform.system() in ('Linux', 'Darwin') and platform.machine() in ('arm', 'armv7l',
|
|
'aarch64',
|
|
'arm64', 'ARM64'),
|
|
reason='Ticket - 126314, 122716')
|
|
def test_topk_v2_basic(self, params, ie_device, precision, ir_version, temp_dir, use_new_frontend,
|
|
use_old_api):
|
|
self._test(*self.create_topk_v2_net(**params),
|
|
ie_device, precision, ir_version, temp_dir=temp_dir,
|
|
use_new_frontend=use_new_frontend, use_old_api=use_old_api)
|