forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_tf_Conj.py
61 lines (45 loc) · 2.19 KB
/
test_tf_Conj.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
53
54
55
56
57
58
59
60
61
# Copyright (C) 2018-2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
import pytest
import numpy as np
import tensorflow as tf
from common.tf_layer_test_class import CommonTFLayerTest
# Testing operation Conj
# Documentation: https://www.tensorflow.org/api_docs/python/tf/raw_ops/Conj
class TestComplexConjugate(CommonTFLayerTest):
def _prepare_input(self, inputs_info):
rng = np.random.default_rng()
assert 'real_part' in inputs_info
real_part_shape = inputs_info['real_part']
assert 'imag_part' in inputs_info
imag_part_shape = inputs_info['imag_part']
inputs_data = {}
inputs_data['real_part'] = 4 * rng.random(real_part_shape).astype(np.float32) - 2
inputs_data['imag_part'] = 4 * rng.random(imag_part_shape).astype(np.float32) - 2
return inputs_data
def create_complex_conjugate_net(self, input_shape):
"""
TensorFlow net IR net
Placeholder->Conjugate => Placeholder->Conjugate
"""
tf.compat.v1.reset_default_graph()
# Create the graph and model
with tf.compat.v1.Session() as sess:
real_part = tf.compat.v1.placeholder(np.float32, input_shape, 'real_part')
imag_part = tf.compat.v1.placeholder(np.float32, input_shape, 'imag_part')
complex_input = tf.raw_ops.Complex(real=real_part, imag=imag_part)
conj= tf.raw_ops.Conj(input=complex_input, name = "Operation")
real = tf.raw_ops.Real(input=conj)
img = tf.raw_ops.Imag(input=conj)
tf.compat.v1.global_variables_initializer()
tf_net = sess.graph_def
ref_net = None
return tf_net, ref_net
@pytest.mark.parametrize("input_shape", [[1,2], [1,2,3], [1,2,3,4], [1,2,3,4,5,6]])
@pytest.mark.precommit_tf_fe
@pytest.mark.nightly
def test_conjugate(self, input_shape, ie_device, precision, ir_version, temp_dir,
use_new_frontend):
self._test(*self.create_complex_conjugate_net(input_shape),
ie_device, precision, ir_version, temp_dir=temp_dir,
use_new_frontend=use_new_frontend)