forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TF FE] Support Conj operation (openvinotoolkit#21947)
* Conjugate * Moved common logic into make_conj helper. * Update src/frontends/tensorflow_common/src/op/conj_transpose.cpp * Moved helper to conj_transpose * Applied helper to both conj and conj_transpose * Deleted conj.cpp * Update src/frontends/tensorflow_common/src/op/conj_transpose.cpp Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com> * Update src/frontends/tensorflow_common/src/op/conj_transpose.cpp Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com> * Removed additional Shape:: scope resolution from get_conj helper * Added Conj and ConjugateTranspose to supported ops * Update src/frontends/tensorflow/src/op_table.cpp Change "Conjugate" to "Conj" Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com> * Apply suggestions from code review * Removed perms call and moved test data directly to parametrize macro * Apply suggestions from code review * Apply suggestions from code review * Changed input types from float32 to complex64 * Changed input type back to np.float32 and removed real tensor test * Update src/frontends/tensorflow_common/src/op/conj_transpose.cpp --------- Co-authored-by: Roman Kazantsev <roman.kazantsev@intel.com> Co-authored-by: Michal Lukaszewski <michal.lukaszewski@intel.com>
- Loading branch information
1 parent
4e302aa
commit 79b4645
Showing
5 changed files
with
101 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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) |