From c5fe0e61373262617b26cf5c3a74f327731ed4e3 Mon Sep 17 00:00:00 2001 From: Andrey Babushkin Date: Sat, 30 Mar 2024 10:46:13 +0000 Subject: [PATCH 1/2] Revert "Use only Java API, Custom ops in contrib build" (#23775) Reverts openvinotoolkit/openvino#23706 Probably causes Windows JS API job failure --- .github/workflows/coverity.yml | 2 ++ .github/workflows/linux.yml | 6 ++++-- .github/workflows/linux_arm64.yml | 6 ++++-- .github/workflows/mac.yml | 4 +++- .github/workflows/mac_arm64.yml | 4 +++- .github/workflows/windows.yml | 19 +++++++++++++++++-- 6 files changed, 33 insertions(+), 8 deletions(-) diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 7d7a2d9faecd13..9976078295a18c 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -87,7 +87,9 @@ jobs: -DENABLE_CPPLINT=OFF \ -DENABLE_STRICT_DEPENDENCIES=OFF \ -DCMAKE_VERBOSE_MAKEFILE=ON \ + -DBUILD_nvidia_plugin=OFF \ -DENABLE_FASTER_BUILD=OFF \ + -DOPENVINO_EXTRA_MODULES=${OPENVINO_CONTRIB_REPO}/modules \ -S ${OPENVINO_REPO} \ -B ${BUILD_DIR} diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index d89d187930b3ed..61f46dca78cac5 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -100,7 +100,8 @@ jobs: repository: 'openvinotoolkit/openvino_contrib' path: ${{ env.OPENVINO_CONTRIB_REPO }} submodules: 'true' - ref: 'master' + # ref: 'master' + ref: 3eeb2326e0d974f61a83f8e67d37e918ccfa1edd # # Print system info @@ -223,8 +224,9 @@ jobs: - name: Cmake & Build - OpenVINO Contrib run: | cmake \ + -DBUILD_nvidia_plugin=OFF \ -DCUSTOM_OPERATIONS="calculate_grid;complex_mul;fft;grid_sample;sparse_conv;sparse_conv_transpose" \ - -DOPENVINO_EXTRA_MODULES="${OPENVINO_CONTRIB_REPO}/modules/java_api;${OPENVINO_CONTRIB_REPO}/modules/custom_operations" \ + -DOPENVINO_EXTRA_MODULES=${OPENVINO_CONTRIB_REPO}/modules \ -S ${OPENVINO_REPO} \ -B ${BUILD_DIR} cmake --build ${BUILD_DIR} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} diff --git a/.github/workflows/linux_arm64.yml b/.github/workflows/linux_arm64.yml index 3fbe11b4ad2aaf..3e0e13d21a7efb 100644 --- a/.github/workflows/linux_arm64.yml +++ b/.github/workflows/linux_arm64.yml @@ -100,7 +100,8 @@ jobs: repository: 'openvinotoolkit/openvino_contrib' path: ${{ env.OPENVINO_CONTRIB_REPO }} submodules: 'true' - ref: 'master' + # ref: 'master' + ref: 3eeb2326e0d974f61a83f8e67d37e918ccfa1edd # # Print system info @@ -228,8 +229,9 @@ jobs: - name: Cmake & Build - OpenVINO Contrib run: | cmake \ + -DBUILD_nvidia_plugin=OFF \ -DCUSTOM_OPERATIONS="calculate_grid;complex_mul;fft;grid_sample;sparse_conv;sparse_conv_transpose" \ - -DOPENVINO_EXTRA_MODULES="${OPENVINO_CONTRIB_REPO}/modules/java_api;${OPENVINO_CONTRIB_REPO}/modules/custom_operations" \ + -DOPENVINO_EXTRA_MODULES=${OPENVINO_CONTRIB_REPO}/modules \ -S ${OPENVINO_REPO} \ -B ${BUILD_DIR} cmake --build ${BUILD_DIR} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} diff --git a/.github/workflows/mac.yml b/.github/workflows/mac.yml index 6331aaae61a7af..1ee2c30c8ea417 100644 --- a/.github/workflows/mac.yml +++ b/.github/workflows/mac.yml @@ -180,8 +180,10 @@ jobs: - name: Cmake & Build - OpenVINO Contrib run: | cmake \ + -DBUILD_nvidia_plugin=OFF \ + -DBUILD_java_api=OFF \ -DCUSTOM_OPERATIONS="calculate_grid;complex_mul;fft;grid_sample;sparse_conv;sparse_conv_transpose" \ - -DOPENVINO_EXTRA_MODULES=${{ env.OPENVINO_CONTRIB_REPO }}/modules/custom_operations \ + -DOPENVINO_EXTRA_MODULES=${{ env.OPENVINO_CONTRIB_REPO }}/modules \ -S ${{ env.OPENVINO_REPO }} \ -B ${{ env.BUILD_DIR }} cmake --build ${{ env.BUILD_DIR }} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} diff --git a/.github/workflows/mac_arm64.yml b/.github/workflows/mac_arm64.yml index b816d5e6a4dccd..f270dccfb8275c 100644 --- a/.github/workflows/mac_arm64.yml +++ b/.github/workflows/mac_arm64.yml @@ -179,8 +179,10 @@ jobs: - name: Cmake & Build - OpenVINO Contrib run: | cmake \ + -DBUILD_nvidia_plugin=OFF \ + -DBUILD_java_api=OFF \ -DCUSTOM_OPERATIONS="calculate_grid;complex_mul;fft;grid_sample;sparse_conv;sparse_conv_transpose" \ - -DOPENVINO_EXTRA_MODULES=${{ OPENVINO_CONTRIB_REPO }}/modules/custom_operations \ + -DOPENVINO_EXTRA_MODULES=${{ env.OPENVINO_CONTRIB_REPO }}/modules \ -S ${{ env.OPENVINO_REPO }} \ -B ${{ env.BUILD_DIR }} cmake --build ${{ env.BUILD_DIR }} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index f75208e0217bf5..becd5bf6087f53 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -80,7 +80,8 @@ jobs: with: repository: 'openvinotoolkit/openvino_contrib' path: 'openvino_contrib' - ref: 'master' + # ref: 'master' + ref: 3eeb2326e0d974f61a83f8e67d37e918ccfa1edd # # Print system info @@ -149,6 +150,7 @@ jobs: run: | cmake -G "${{ env.CMAKE_GENERATOR }}" ` -DENABLE_CPPLINT=OFF ` + -DBUILD_nvidia_plugin=OFF ` -DBUILD_SHARED_LIBS=ON ` -DENABLE_TESTS=ON ` -DCMAKE_COMPILE_WARNING_AS_ERROR=ON ` @@ -156,7 +158,7 @@ jobs: -DENABLE_PYTHON=ON ` -DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=ON ` -DCUSTOM_OPERATIONS="calculate_grid;complex_mul;fft;grid_sample;sparse_conv;sparse_conv_transpose" ` - -DOPENVINO_EXTRA_MODULES="${{ env.OPENVINO_CONTRIB_REPO }}/modules/custom_operations;${{ env.OPENVINO_CONTRIB_REPO }}/modules/java_api" ` + -DOPENVINO_EXTRA_MODULES=${{ env.OPENVINO_CONTRIB_REPO }}/modules ` -S ${{ env.OPENVINO_REPO }} ` -B ${{ env.BUILD_DIR }} @@ -206,11 +208,24 @@ jobs: } Compress-Archive @compress + - name: Cmake & Build - OpenVINO Contrib + if: ${{ 'false' }} # Ticket: 122441 + run: | + cmake ` + -DBUILD_nvidia_plugin=OFF ` + -DCUSTOM_OPERATIONS="calculate_grid;complex_mul;fft;grid_sample;sparse_conv;sparse_conv_transpose" ` + -DOPENVINO_EXTRA_MODULES=${{ env.OPENVINO_CONTRIB_REPO }}/modules ` + -S ${{ env.OPENVINO_REPO }} ` + -B ${{ env.BUILD_DIR }} + cmake --build ${{ env.BUILD_DIR }} --parallel --config ${{ env.CMAKE_BUILD_TYPE }} --verbose + - name: CMake configure, build and install - OpenVINO JS API if: fromJSON(needs.smart_ci.outputs.affected_components).JS_API run: cmake -DCPACK_GENERATOR=NPM -DENABLE_SYSTEM_TBB=OFF -UTBB* -S ${{ env.OPENVINO_REPO }} -B ${{ env.BUILD_DIR }} + cmake --build ${{ env.BUILD_DIR }} --parallel + cmake -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR_JS }} -P ${{ env.BUILD_DIR }}/cmake_install.cmake # From 8482121fc4515a385ca1425c0bfb02081190040d Mon Sep 17 00:00:00 2001 From: Pranshu Shukla <55992439+Pranshu-S@users.noreply.github.com> Date: Sat, 30 Mar 2024 19:49:52 +0530 Subject: [PATCH 2/2] [TF FE] Support complex tensors for BiasAdd operation (#23218) Extending support for BiasAdd operation to complex tensors. Resolves Issue: #22945 --------- Co-authored-by: Roman Kazantsev Co-authored-by: Michal Lukaszewski --- .../tensorflow_common/src/op/bias_add.cpp | 20 ++++++- .../tensorflow_tests/test_tf_BiasAdd.py | 58 +++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) diff --git a/src/frontends/tensorflow_common/src/op/bias_add.cpp b/src/frontends/tensorflow_common/src/op/bias_add.cpp index 04db49af5f3b4e..6c7c17a8b95cbc 100644 --- a/src/frontends/tensorflow_common/src/op/bias_add.cpp +++ b/src/frontends/tensorflow_common/src/op/bias_add.cpp @@ -3,6 +3,7 @@ // #include "common_op_table.hpp" +#include "helper_ops/complex_type_mark.hpp" #include "openvino/op/add.hpp" #include "openvino/op/constant.hpp" #include "openvino/op/unsqueeze.hpp" @@ -16,10 +17,20 @@ namespace tensorflow { namespace op { OutputVector translate_bias_add_op(const NodeContext& node) { - default_op_checks(node, 2, {"BiasAdd"}); + default_op_checks(node, 2, {"BiasAdd"}, true); auto value = node.get_input(0); auto bias = node.get_input(1); + auto complex_type_mark_value = as_type_ptr(value.get_node_shared_ptr()); + auto complex_type_mark_bias = as_type_ptr(bias.get_node_shared_ptr()); + auto complex_type_inputs = (complex_type_mark_value || complex_type_mark_bias) ? true : false; + // validations prior to processing + if (complex_type_inputs) { + // extractions for complex processing + bias = complex_type_mark_bias->input_value(0); + value = complex_type_mark_value->input_value(0); + } + // retrieve optional attributes std::string data_format = node.get_attribute("data_format", "NHWC"); TENSORFLOW_OP_VALIDATION(node, @@ -36,7 +47,7 @@ OutputVector translate_bias_add_op(const NodeContext& node) { TENSORFLOW_OP_VALIDATION(node, value_shape.rank().is_static(), "Value of dynamic rank for BiasAdd in NCHW layout is not supported."); - auto value_rank = value_shape.rank().get_length(); + auto value_rank = complex_type_inputs ? value_shape.rank().get_length() - 1 : value_shape.rank().get_length(); std::vector axes_unsqueeze; for (int64_t dim_ind = 0; dim_ind < value_rank; ++dim_ind) { @@ -51,6 +62,11 @@ OutputVector translate_bias_add_op(const NodeContext& node) { auto res = make_shared(value, bias_reshaped); set_node_name(node.get_name(), res); + + if (complex_type_inputs) { + auto complex_reshape = make_shared(res, complex_type_mark_value->get_complex_part_type()); + return {complex_reshape->output(0)}; + } return res->outputs(); } } // namespace op diff --git a/tests/layer_tests/tensorflow_tests/test_tf_BiasAdd.py b/tests/layer_tests/tensorflow_tests/test_tf_BiasAdd.py index 3fde179f78524e..11c1d2a2ffed17 100644 --- a/tests/layer_tests/tensorflow_tests/test_tf_BiasAdd.py +++ b/tests/layer_tests/tensorflow_tests/test_tf_BiasAdd.py @@ -154,3 +154,61 @@ def test_bias_add_2_consts_5D(self, params, ie_device, precision, ir_version, te use_legacy_frontend=use_legacy_frontend), ie_device, precision, ir_version, temp_dir=temp_dir, use_legacy_frontend=use_legacy_frontend) + + +class TestComplexBiasAdd(CommonTFLayerTest): + def _prepare_input(self, inputs_info): + rng = np.random.default_rng() + assert 'x_real:0' in inputs_info + assert 'x_imag:0' in inputs_info + assert 'y_real:0' in inputs_info + assert 'y_imag:0' in inputs_info + x_shape = inputs_info['x_real:0'] + y_shape = inputs_info['y_real:0'] + inputs_data = {} + + inputs_data['x_real:0'] = 4 * rng.random(x_shape).astype(np.float64) - 2 + inputs_data['x_imag:0'] = 4 * rng.random(x_shape).astype(np.float64) - 2 + + inputs_data['y_real:0'] = 4 * rng.random(y_shape).astype(np.float64) - 2 + inputs_data['y_imag:0'] = 4 * rng.random(y_shape).astype(np.float64) - 2 + + return inputs_data + + def create_complex_bias_add_net(self, input_shape, bias_shape, data_format, ir_version, use_legacy_frontend, output_type=tf.float32): + tf.compat.v1.reset_default_graph() + + with tf.compat.v1.Session() as sess: + x_real = tf.compat.v1.placeholder(output_type, input_shape, 'x_real') + x_imag = tf.compat.v1.placeholder(output_type, input_shape, 'x_imag') + + y_real = tf.compat.v1.placeholder(output_type, bias_shape, 'y_real') + y_imag = tf.compat.v1.placeholder(output_type, bias_shape, 'y_imag') + + complex_input = tf.complex(x_real, x_imag) + complex_bias = tf.complex(y_real, y_imag) + + result = tf.raw_ops.BiasAdd(value=complex_input, bias=complex_bias,data_format=data_format,name="ComplexBiasAdd") + real = tf.raw_ops.Real(input=result) + img = tf.raw_ops.Imag(input=result) + + tf_net = sess.graph_def + + return tf_net, None + + test_data_2D = [ + dict(input_shape=[1, 1], bias_shape=[1], data_format="NHWC"), + dict(input_shape=[3, 2, 7], bias_shape=[7], data_format="NHWC"), + dict(input_shape=[3, 2, 7, 10], bias_shape=[2], data_format="NCHW"), + dict(input_shape=[7, 6, 4, 5], bias_shape=[6], data_format="NCHW"), + ] + + @pytest.mark.parametrize("params", test_data_2D) + @pytest.mark.precommit + @pytest.mark.nightly + def test_complex_bias_add(self, params, ie_device, precision, ir_version, temp_dir, + use_legacy_frontend): + self._test(*self.create_complex_bias_add_net(**params, ir_version=ir_version, + use_legacy_frontend=use_legacy_frontend), + ie_device, precision, ir_version, temp_dir=temp_dir, + use_legacy_frontend=use_legacy_frontend) \ No newline at end of file