Files
openvino/tests/layer_tests/tensorflow_tests/test_tf_ArgMinMax.py
T
Andrey Kashchikhin dfc91186a1 [CI] [GHA] Extract test jobs into reusable workflows (#21395)
* extract cpu func tests into a reusable workflow

* add needs

* check paths

* correct paths

* rm usage of setupvars

* extract samples

* use yaml string

* split mac workflow

* check variables

* try github workspace

* check full dir

* set variables

* try with sub directory

* Revert "try with sub directory"

This reverts commit d891ee3f28.

* extract c++ tests from linux

* change

* use cxx workflow in mac workflows

* add noninteractive

* extract cpu func tests

* rm unused

* enable mac

* fix reusable workflow name

* correct path for sparse-checkout

* extract python UT

* remove unnecessary asterisk

* remove another unnecessary asterisk

* use reusable action for linux cc

* add check for setupvars existence

* check with manually installed opencl

* add components input to samples workflow; rm pr triggers for mac workflows

* add missing needs

* add missing option for deps install  script

* use disables in test themselves instead of ifs in workflows

* use reusable workflow for cxx tests in linux arm

* use python reusable workflow in linux arm

* add missing endif

* use self-hosted for samples, add x86_64 constraint for jax

* check paths

* find gompby partial name

* skip failing tests on arm; correct gomp finding for ovc

* check tests

* add debian packages job; use job_ prefix for reusable workflows with jobs

* extract tf hub model tests

* extract tf model hub perf tests

* extract pytorch models tests

* do not use container on GHA runners

* extract onnx runtime

* add missing deps

* skip test for linux arm

* rm always()s

* fix quotes

* correct paths

* correct ifs, check dir for onnxruntime

* correct path for onnxruntime utils folder; install python3

* use self-hosted as input

* check for self-hosted runner via name, pass version

* skip cpu plugin unittest

* check cxx tests

* rm pr trigger
2023-12-07 23:44:45 +04:00

65 lines
2.7 KiB
Python

# Copyright (C) 2022 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
# Testing operation ArgMin, ArgMax (Initial Implementation)
# Documentation: https://www.tensorflow.org/api_docs/python/tf/raw_ops/ArgMin
# https://www.tensorflow.org/api_docs/python/tf/raw_ops/ArgMax
class TestArgMinMax(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
assert 'input' in inputs_info
input_shape = inputs_info['input']
inputs_data = {}
rng = np.random.default_rng()
inputs_data['input'] = rng.integers(-8, 8, input_shape).astype(self.input_type)
return inputs_data
def create_argmin_max_net(self, input_shape, dimension, input_type, output_type, op_type):
self.input_type = input_type
tf.compat.v1.reset_default_graph()
# Create the graph and model
with tf.compat.v1.Session() as sess:
tf_input = tf.compat.v1.placeholder(input_type, input_shape, 'input')
tf_dimension = tf.constant(dimension)
op_type(input=tf_input, dimension=tf_dimension, output_type=output_type)
tf.compat.v1.global_variables_initializer()
tf_net = sess.graph_def
ref_net = None
return tf_net, ref_net
test_data = [
dict(input_shape=[20], dimension=0),
dict(input_shape=[20, 30], dimension=1),
dict(input_shape=[2, 30, 3, 4], dimension=2),
]
@pytest.mark.parametrize("params", test_data)
@pytest.mark.parametrize("input_type", [np.float32, np.int32])
@pytest.mark.parametrize("output_type", [tf.int32, tf.int64])
@pytest.mark.parametrize("op_type", [tf.raw_ops.ArgMax, tf.raw_ops.ArgMin])
@pytest.mark.precommit_tf_fe
@pytest.mark.nightly
@pytest.mark.xfail(condition=platform.system() == 'Linux' and platform.machine() in ['arm', 'armv7l',
'aarch64',
'arm64', 'ARM64'],
reason='Ticket - 126314')
def test_argmin_max_net(self, params, input_type, output_type, op_type, ie_device, precision, ir_version, temp_dir,
use_new_frontend, use_old_api):
self._test(*self.create_argmin_max_net(**params, input_type=input_type,
output_type=output_type, op_type=op_type),
ie_device, precision, ir_version, temp_dir=temp_dir,
use_new_frontend=use_new_frontend, use_old_api=use_old_api)