forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_tf_ExtractImagePatches.py
44 lines (37 loc) · 2.05 KB
/
test_tf_ExtractImagePatches.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
# 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 TestExtractImagePatches(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
# generate elements so that the input tensor may contain repeating elements
assert 'images' in inputs_info, "Test error: inputs_info must contain `images`"
images_shape = inputs_info['images']
inputs_data = {}
inputs_data['images'] = np.random.randint(-10, 10, images_shape).astype(np.float32)
return inputs_data
def create_extract_image_patches_net(self, images_shape, ksizes, strides, rates, padding):
tf.compat.v1.reset_default_graph()
with tf.compat.v1.Session() as sess:
images = tf.compat.v1.placeholder(tf.float32, images_shape, 'images')
tf.raw_ops.ExtractImagePatches(images=images, ksizes=ksizes, strides=strides, rates=rates, padding=padding)
tf.compat.v1.global_variables_initializer()
tf_net = sess.graph_def
return tf_net, None
test_basic = [
# TensorFlow supports patching only across spatial dimensions
dict(images_shape=[2, 110, 50, 4], ksizes=[1, 20, 30, 1], strides=[1, 5, 5, 1], rates=[1, 1, 1, 1]),
dict(images_shape=[3, 30, 40, 3], ksizes=[1, 5, 10, 1], strides=[1, 3, 1, 1], rates=[1, 4, 3, 1]),
]
@pytest.mark.parametrize("params", test_basic)
@pytest.mark.parametrize("padding", ["SAME", "VALID"])
@pytest.mark.nightly
@pytest.mark.precommit_tf_fe
def test_extract_image_patches_basic(self, params, padding, ie_device, precision, ir_version, temp_dir,
use_new_frontend,
use_old_api):
self._test(*self.create_extract_image_patches_net(**params, padding=padding),
ie_device, precision, ir_version, temp_dir=temp_dir,
use_new_frontend=use_new_frontend, use_old_api=use_old_api)