Skip to content

Commit

Permalink
[TF FE] Run HSVToRGB tests on all platforms (#27945)
Browse files Browse the repository at this point in the history
**Details:** Run HSVToRGB tests on all platforms

**Ticket:** TBD

---------

Signed-off-by: Kazantsev, Roman <[email protected]>
  • Loading branch information
rkazants authored Dec 6, 2024
1 parent 94f647d commit e8fa9f7
Showing 1 changed file with 19 additions and 34 deletions.
53 changes: 19 additions & 34 deletions tests/layer_tests/tensorflow_tests/test_tf_HSVToRGB.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
# Copyright (C) 2018-2024 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

rng = np.random.default_rng(23345)


class TestHSVToRGB(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
assert 'images:0' in inputs_info
if self.special_case == "Black Image":
images_shape = inputs_info['images:0']
inputs_data = {}
inputs_data['images:0'] = np.zeros(images_shape).astype(self.input_type)
elif self.special_case == "Grayscale Image":
images_shape = inputs_info['images:0']
inputs_data = {}
images_shape = inputs_info['images:0']
inputs_data = {}
if self.special_case == 'Black Image':
inputs_data['images:0'] = np.zeros(images_shape).astype(self.input_type)
elif self.special_case == 'Grayscale Image':
inputs_data['images:0'] = np.broadcast_to([0, 0, 0.5], images_shape).astype(self.input_type)
else:
images_shape = inputs_info['images:0']
inputs_data = {}
inputs_data['images:0'] = np.random.rand(*images_shape).astype(self.input_type)

inputs_data['images:0'] = rng.uniform(0.0, 1.0, images_shape).astype(self.input_type)
return inputs_data

def create_hsv_to_rgb_net(self, input_shape, input_type, special_case=False):
def create_hsv_to_rgb_net(self, input_shape, input_type, special_case):
self.special_case = special_case
self.input_type = input_type
tf.compat.v1.reset_default_graph()
Expand All @@ -39,27 +35,16 @@ def create_hsv_to_rgb_net(self, input_shape, input_type, special_case=False):

return tf_net, None

# Each input is a tensor of with values in [0,1].
# The last dimension must be size 3.
test_data_basic = [
dict(input_shape=[7, 7, 3], input_type=np.float32, special_case="Black Image"),
dict(input_shape=[7, 7, 3], input_type=np.float32, special_case="Grayscale Image"),
dict(input_shape=[5, 5, 3], input_type=np.float32),
dict(input_shape=[5, 23, 27, 3], input_type=np.float64),
dict(input_shape=[3, 4, 13, 15, 3], input_type=np.float64),
]

@pytest.mark.parametrize("params", test_data_basic)
@pytest.mark.parametrize('input_shape', [[3], [5, 3], [4, 5, 3], [5, 21, 21, 3]])
@pytest.mark.parametrize('input_type', [np.float16, np.float32, np.float64])
@pytest.mark.parametrize('special_case', [None, 'Black Image', 'Grayscale Image'])
@pytest.mark.precommit
@pytest.mark.nightly
@pytest.mark.xfail(condition=platform.system() in ('Darwin', 'Linux') and platform.machine() in ['arm', 'armv7l',
'aarch64',
'arm64', 'ARM64'],
reason='Ticket - 126314, 132699')
def test_hsv_to_rgb_basic(self, params, ie_device, precision, ir_version, temp_dir,
use_legacy_frontend):
def test_hsv_to_rgb_basic(self, input_shape, input_type, special_case,
ie_device, precision, ir_version, temp_dir,
use_legacy_frontend):
if ie_device == 'GPU':
pytest.skip("Accuracy mismatch on GPU")
self._test(*self.create_hsv_to_rgb_net(**params),
pytest.skip('158898: accuracy issue on GPU')
self._test(*self.create_hsv_to_rgb_net(input_shape, input_type, special_case),
ie_device, precision, ir_version, temp_dir=temp_dir,
use_legacy_frontend=use_legacy_frontend)
use_legacy_frontend=use_legacy_frontend, custom_eps=3 * 1e-3)

0 comments on commit e8fa9f7

Please sign in to comment.