Skip to content

Commit

Permalink
Merge branch 'master' into issue#22949
Browse files Browse the repository at this point in the history
  • Loading branch information
rkazants authored Mar 30, 2024
2 parents fe7bce6 + 8482121 commit abe61c1
Show file tree
Hide file tree
Showing 8 changed files with 109 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/coverity.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/linux_arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/mac_arm64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ jobs:
with:
repository: 'openvinotoolkit/openvino_contrib'
path: 'openvino_contrib'
ref: 'master'
# ref: 'master'
ref: 3eeb2326e0d974f61a83f8e67d37e918ccfa1edd

#
# Print system info
Expand Down Expand Up @@ -149,14 +150,15 @@ 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 `
-DENABLE_STRICT_DEPENDENCIES=OFF `
-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 }}
Expand Down Expand Up @@ -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

#
Expand Down
20 changes: 18 additions & 2 deletions src/frontends/tensorflow_common/src/op/bias_add.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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<ComplexTypeMark>(value.get_node_shared_ptr());
auto complex_type_mark_bias = as_type_ptr<ComplexTypeMark>(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<std::string>("data_format", "NHWC");
TENSORFLOW_OP_VALIDATION(node,
Expand All @@ -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<int64_t> axes_unsqueeze;
for (int64_t dim_ind = 0; dim_ind < value_rank; ++dim_ind) {
Expand All @@ -51,6 +62,11 @@ OutputVector translate_bias_add_op(const NodeContext& node) {

auto res = make_shared<v1::Add>(value, bias_reshaped);
set_node_name(node.get_name(), res);

if (complex_type_inputs) {
auto complex_reshape = make_shared<ComplexTypeMark>(res, complex_type_mark_value->get_complex_part_type());
return {complex_reshape->output(0)};
}
return res->outputs();
}
} // namespace op
Expand Down
58 changes: 58 additions & 0 deletions tests/layer_tests/tensorflow_tests/test_tf_BiasAdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit abe61c1

Please sign in to comment.