From c683a7240069ebb03d9417ae518e170716bfb67e Mon Sep 17 00:00:00 2001 From: Szymon Irzabek Date: Tue, 3 Jan 2023 16:06:23 +0100 Subject: [PATCH] Gna namespace (#14877) * [GNA] Cleanup intel_dnn * [GNA] Replace GNAPluginNS * [GNA] Rename headers --- .../openvino/runtime/intel_gna/properties.hpp | 4 +- .../intel_gna/src/backend/am_intel_dnn.cpp | 289 ++++++++---------- .../intel_gna/src/backend/am_intel_dnn.hpp | 75 +++-- src/plugins/intel_gna/src/backend/dnn.cpp | 73 ----- src/plugins/intel_gna/src/backend/dnn.hpp | 66 ---- .../intel_gna/src/backend/dnn_components.cpp | 33 +- .../intel_gna/src/backend/dnn_components.hpp | 10 +- .../intel_gna/src/backend/dnn_traits.hpp | 92 ------ .../intel_gna/src/backend/dnn_types.cpp | 15 +- .../backend/{dnn_types.h => dnn_types.hpp} | 22 +- .../intel_gna/src/backend/gna_limitations.cpp | 24 +- .../intel_gna/src/backend/gna_limitations.hpp | 214 ++++++++----- .../backend/{gna_types.h => gna_types.hpp} | 0 .../intel_gna/src/backend/make_pwl.cpp | 6 +- .../src/backend/pwl_input_params.hpp | 2 +- .../src/backend/pwl_segments_creator.hpp | 2 +- .../backend/pwl_segments_creator_factory.cpp | 2 +- .../backend/pwl_segments_creator_identity.cpp | 2 +- .../intel_gna/src/backend/pwl_tools.cpp | 2 +- .../intel_gna/src/backend/pwl_tools.hpp | 2 +- .../intel_gna/src/common/gna_target.hpp | 10 +- .../intel_gna/src/connection_details.hpp | 8 +- .../intel_gna/src/descriptions/gna_desc.hpp | 84 +++-- .../intel_gna/src/descriptions/gna_flags.hpp | 8 +- .../src/frontend/layer_quantizer.cpp | 6 +- .../src/frontend/layer_quantizer.hpp | 2 - .../intel_gna/src/frontend/quantization.cpp | 2 +- .../intel_gna/src/frontend/quantization.hpp | 2 +- .../src/frontend/scale_factor_calc.cpp | 14 +- .../src/frontend/scale_factor_calc.hpp | 22 +- .../src/frontend/weights_converter.cpp | 2 +- .../src/gna2_model_export_helper.cpp | 4 +- .../intel_gna/src/gna2_model_helper.hpp | 2 +- src/plugins/intel_gna/src/gna_data_types.hpp | 14 +- src/plugins/intel_gna/src/gna_device.cpp | 40 +-- src/plugins/intel_gna/src/gna_device.hpp | 6 +- .../intel_gna/src/gna_device_allocation.hpp | 2 +- .../intel_gna/src/gna_device_interface.hpp | 13 +- .../intel_gna/src/gna_executable_network.hpp | 6 +- .../intel_gna/src/gna_fused_iterator.hpp | 7 +- .../intel_gna/src/gna_graph_compiler.cpp | 102 +++---- .../intel_gna/src/gna_graph_compiler.hpp | 27 +- .../intel_gna/src/gna_graph_patterns.hpp | 10 +- src/plugins/intel_gna/src/gna_groups.hpp | 13 +- .../intel_gna/src/gna_infer_request.cpp | 7 +- .../intel_gna/src/gna_infer_request.hpp | 8 +- src/plugins/intel_gna/src/gna_itt.hpp | 12 +- .../intel_gna/src/gna_lib_ver_selector.hpp | 9 +- .../intel_gna/src/gna_model_serial.cpp | 72 ++--- .../intel_gna/src/gna_model_serial.hpp | 26 +- src/plugins/intel_gna/src/gna_plugin.cpp | 61 ++-- src/plugins/intel_gna/src/gna_plugin.hpp | 19 +- .../intel_gna/src/gna_plugin_config.cpp | 11 +- .../intel_gna/src/gna_plugin_config.hpp | 6 +- .../intel_gna/src/gna_plugin_entry_points.cpp | 1 - .../intel_gna/src/gna_plugin_internal.hpp | 6 +- .../intel_gna/src/gna_plugin_query_api.cpp | 1 - src/plugins/intel_gna/src/gna_slope_scale.cpp | 2 +- ...{gna_slope_scale.h => gna_slope_scale.hpp} | 0 .../intel_gna/src/gna_tensor_tools.hpp | 6 +- .../intel_gna/src/gna_upstream_iterator.hpp | 8 +- .../intel_gna/src/layers/gna_concat_layer.hpp | 8 +- .../src/layers/gna_convolution_layer.cpp | 50 ++- .../src/layers/gna_convolution_layer.hpp | 27 +- .../intel_gna/src/layers/gna_copy_layer.hpp | 7 +- .../intel_gna/src/layers/gna_crop_layer.cpp | 8 +- .../intel_gna/src/layers/gna_crop_layer.hpp | 7 +- .../src/layers/gna_fake_quantize_layer.hpp | 69 +++-- .../src/layers/gna_layer_helpers.hpp | 12 +- .../intel_gna/src/layers/gna_layer_info.hpp | 12 +- .../intel_gna/src/layers/gna_layer_type.cpp | 8 +- .../intel_gna/src/layers/gna_layer_type.hpp | 14 +- .../intel_gna/src/layers/gna_memory_layer.hpp | 8 +- .../intel_gna/src/layers/gna_permute.hpp | 41 +-- .../intel_gna/src/layers/gna_split_layer.hpp | 13 +- .../intel_gna/src/layers/layers_builder.hpp | 8 +- .../intel_gna/src/memory/gna_allocator.hpp | 9 +- .../intel_gna/src/memory/gna_mem_regions.hpp | 6 +- .../intel_gna/src/memory/gna_mem_requests.hpp | 7 +- .../src/memory/gna_mem_requests_queue.hpp | 8 +- .../intel_gna/src/memory/gna_memory.hpp | 10 +- .../intel_gna/src/memory/gna_memory_state.cpp | 200 ++++++------ .../intel_gna/src/memory/gna_memory_state.hpp | 8 +- .../intel_gna/src/memory/gna_memory_util.cpp | 11 +- .../intel_gna/src/memory/gna_memory_util.hpp | 6 +- src/plugins/intel_gna/src/ops/util/util.hpp | 6 +- .../src/optimizer/gna_pass_manager.cpp | 67 ++-- .../src/optimizer/gna_pass_manager.hpp | 7 +- .../intel_gna/src/orientation_helper.cpp | 12 +- .../intel_gna/src/orientation_helper.hpp | 13 +- src/plugins/intel_gna/src/preprocessing.cpp | 24 +- src/plugins/intel_gna/src/preprocessing.hpp | 6 +- .../intel_gna/src/request/model_wrapper.cpp | 6 +- .../intel_gna/src/request/model_wrapper.hpp | 7 +- .../src/request/model_wrapper_factory.cpp | 6 +- .../src/request/model_wrapper_factory.hpp | 6 +- .../intel_gna/src/request/subrequest.hpp | 10 +- .../intel_gna/src/request/subrequest_impl.cpp | 6 +- .../intel_gna/src/request/subrequest_impl.hpp | 8 +- src/plugins/intel_gna/src/request/worker.hpp | 8 +- .../intel_gna/src/request/worker_factory.cpp | 12 +- .../intel_gna/src/request/worker_factory.hpp | 9 +- .../intel_gna/src/request/worker_impl.cpp | 6 +- .../intel_gna/src/request/worker_impl.hpp | 6 +- .../intel_gna/src/request/worker_pool.hpp | 6 +- .../src/request/worker_pool_impl.cpp | 6 +- .../src/request/worker_pool_impl.hpp | 6 +- src/plugins/intel_gna/src/request_status.hpp | 6 +- src/plugins/intel_gna/src/runtime/cnn.cpp | 6 +- src/plugins/intel_gna/src/runtime/cnn.h | 2 +- .../src/runtime/gna_float_runtime.cpp | 129 ++++---- .../src/runtime/gna_float_runtime.hpp | 8 +- .../src/runtime/gna_float_runtime_op.cpp | 81 ++--- src/plugins/intel_gna/src/runtime/pwl.cpp | 2 +- src/plugins/intel_gna/src/runtime/pwl.h | 4 +- .../intel_gna/src/scale_factor_helper.cpp | 26 +- .../intel_gna/src/scale_factor_helper.hpp | 17 +- .../serial/headers/2dot1/gna_model_header.hpp | 28 +- .../serial/headers/2dot2/gna_model_header.hpp | 30 +- .../serial/headers/2dot3/gna_model_header.hpp | 30 +- .../serial/headers/2dot4/gna_model_header.hpp | 31 +- .../serial/headers/2dot5/gna_model_header.hpp | 32 +- .../serial/headers/2dot6/gna_model_header.hpp | 30 +- .../serial/headers/2dot7/gna_model_header.hpp | 37 +-- .../serial/headers/2dot8/gna_model_header.hpp | 46 +-- .../headers/latest/gna_model_header.hpp | 16 +- ...onvert_matmul_to_pointwise_convolution.cpp | 12 +- .../decompose_2d_convolution.cpp | 22 +- .../src/transformations/decompose_mvn.cpp | 198 ++++++++---- .../handle_transposes_around_matmul.cpp | 8 +- ...lit_convolution_with_large_buffer_size.cpp | 67 ++-- ...lit_convolution_with_large_buffer_size.hpp | 1 + .../src/transformations/split_eltwise.cpp | 55 ++-- .../src/transformations/split_eltwise.hpp | 1 + .../single_layer_tests/convolution.cpp | 12 +- .../unit/backend/gna_limitations_test.cpp | 112 +++---- .../unit/backend/gna_make_pwl_identity.cpp | 2 +- .../tests/unit/gna_allocator_test.cpp | 4 +- .../intel_gna/tests/unit/gna_am_intel_dnn.cpp | 2 +- .../tests/unit/gna_export_import_test.cpp | 2 +- .../unit/gna_extra_pwl_segments_tests.cpp | 5 +- .../tests/unit/gna_get_2d_reshaped_data.cpp | 2 +- .../unit/gna_get_aligned_split_sizes.cpp | 4 +- .../tests/unit/gna_get_crop_params.cpp | 4 +- .../tests/unit/gna_hw_precision_test.cpp | 6 +- .../tests/unit/gna_infer_request_test.cpp | 4 +- .../tests/unit/gna_input_preproc_test.cpp | 2 +- .../tests/unit/gna_memory_compact_test.cpp | 10 +- .../intel_gna/tests/unit/gna_memory_test.cpp | 4 +- .../tests/unit/gna_permute_sequence_test.cpp | 2 +- .../tests/unit/gna_plugin_config_test.cpp | 2 +- .../unit/gna_plugin_load_network_test.cpp | 2 +- .../intel_gna/tests/unit/gna_wait_test.cpp | 3 +- .../gna_request_worker_factory_test.cpp | 2 +- .../request/gna_request_worker_impl_test.cpp | 4 +- .../gna_request_worker_pool_impl_test.cpp | 5 +- .../tests/unit/request/mock_gna_device.hpp | 8 +- .../tests/unit/request/mock_subrequest.hpp | 6 +- .../tests/unit/request/mock_worker.hpp | 6 +- .../tests/unit/request/mock_worker_pool.hpp | 6 +- .../tests/unit/scale_factor_helper_test.cpp | 34 +-- .../gna_decompose_2d_convolution.cpp | 4 +- .../transformations/gna_decompose_mvn.cpp | 2 +- .../transformations/gna_split_eltwise.cpp | 2 +- .../unit/engines/gna/I8_quantisation_test.cpp | 6 +- .../engines/gna/fp32_non_quantized_tests.cpp | 1 - .../unit/engines/gna/gna_matcher.cpp | 5 +- .../unit/engines/gna/gna_matcher.hpp | 6 +- .../unit/engines/gna/gna_proc_type_test.cpp | 1 - .../gna/graph_tools/graph_copy_tests.cpp | 6 +- .../engines/gna/i16_quantisation_test.cpp | 8 +- .../gna/layers/gna_align_filter2_tests.cpp | 1 - .../engines/gna/matchers/copy_matcher.hpp | 2 +- .../engines/gna/matchers/fill_with_data.hpp | 2 +- .../gna/matchers/input_data_matcher.hpp | 2 +- .../gna/matchers/nnet_base_matcher.hpp | 2 +- .../gna/matchers/precision_matcher.hpp | 2 +- .../pwl_quantization_metrics_matcher.hpp | 2 +- 178 files changed, 1928 insertions(+), 1702 deletions(-) delete mode 100644 src/plugins/intel_gna/src/backend/dnn.cpp delete mode 100644 src/plugins/intel_gna/src/backend/dnn.hpp delete mode 100644 src/plugins/intel_gna/src/backend/dnn_traits.hpp rename src/plugins/intel_gna/src/backend/{dnn_types.h => dnn_types.hpp} (93%) rename src/plugins/intel_gna/src/backend/{gna_types.h => gna_types.hpp} (100%) rename src/plugins/intel_gna/src/{gna_slope_scale.h => gna_slope_scale.hpp} (100%) diff --git a/src/inference/include/openvino/runtime/intel_gna/properties.hpp b/src/inference/include/openvino/runtime/intel_gna/properties.hpp index 3dcbf9eebec..2c384c6af90 100644 --- a/src/inference/include/openvino/runtime/intel_gna/properties.hpp +++ b/src/inference/include/openvino/runtime/intel_gna/properties.hpp @@ -164,7 +164,7 @@ inline std::istream& operator>>(std::istream& is, HWGeneration& hw_generation) { static constexpr Property execution_mode{"GNA_DEVICE_MODE"}; /** - * @brief The option to override the GNA HW execution target. May be one of GNA_2_0, GNA_3_0. + * @brief The option to override the GNA HW execution target. May be one of GNA_2_0, GNA_3_0, GNA_3_5. * By default (in case of no value set) the behavior depends on GNA HW availability: * If GNA HW is present, use the option corresponding to this HW. * If HW is not present, use the option corresponding to the latest fully supported GNA HW generation. @@ -175,7 +175,7 @@ static constexpr Property execution_mode{"GNA_DEVICE_MODE"}; static constexpr Property execution_target{"GNA_HW_EXECUTION_TARGET"}; /** - * @brief The option to override the GNA HW compile target. May be one of GNA_2_0, GNA_3_0. + * @brief The option to override the GNA HW compile target. May be one of GNA_2_0, GNA_3_0, GNA_3_5. * By default the same as execution_target. * @ingroup ov_runtime_gna_prop_cpp_api */ diff --git a/src/plugins/intel_gna/src/backend/am_intel_dnn.cpp b/src/plugins/intel_gna/src/backend/am_intel_dnn.cpp index e409ed49504..ff41c584a31 100644 --- a/src/plugins/intel_gna/src/backend/am_intel_dnn.cpp +++ b/src/plugins/intel_gna/src/backend/am_intel_dnn.cpp @@ -22,11 +22,10 @@ #include "memory/gna_memory_util.hpp" #include "log/log.hpp" #include "log/dump.hpp" -#include "backend/dnn.hpp" #include "backend/am_intel_dnn.hpp" -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include "gna/gna_config.hpp" -#include "backend/gna_types.h" +#include "backend/gna_types.hpp" #include "backend/gna_limitations.hpp" #include "layers/gna_convolution_layer.hpp" #include "memory/gna_memory.hpp" @@ -46,20 +45,18 @@ */ #define LIGHT_DUMP -using namespace GNAPluginNS::backend; -using namespace ov::intel_gna; +using gna_convolution_layer::outputFromConv; +using gna_convolution_layer::outputFromPooling; -using GNAPluginNS::GNAConvolutionLayer::outputFromConv; -using GNAPluginNS::GNAConvolutionLayer::outputFromPooling; -using GNAPluginNS::GNAConvolutionLayer::outputFromPoolingLegacy; +namespace ov { +namespace intel_gna { +namespace backend { -using GNAPluginNS::memory::GNAMemoryInterface; - -void GNAPluginNS::backend::AMIntelDNN::BeginNewWrite(uint32_t index) { +void backend::AMIntelDNN::BeginNewWrite(uint32_t index) { dump_write_index = index; } -void GNAPluginNS::backend::AMIntelDNN::Init(GNAMemoryInterface* memoryInterface, +void backend::AMIntelDNN::Init(memory::GNAMemoryInterface* memoryInterface, intel_dnn_number_type_t compute_precision, float scale_factor) { memory = memoryInterface; @@ -68,25 +65,13 @@ void GNAPluginNS::backend::AMIntelDNN::Init(GNAMemoryInterface* memoryInterface, ptr_active_outputs_ = nullptr; num_active_outputs_ = 0; - num_left_context = 0; - num_right_context = 0; - softmax_type = kSoftmaxNone; - ptr_sumgroup_sizes = nullptr; - num_sumgroup_sizes = 0; - ptr_priors = nullptr; } -GNAPluginNS::backend::AMIntelDNN::~AMIntelDNN() { +backend::AMIntelDNN::~AMIntelDNN() { component.clear(); - if (ptr_sumgroup_sizes != NULL) { - _mm_free(ptr_sumgroup_sizes); - } - if (ptr_priors != NULL) { - _mm_free(ptr_priors); - } } -void GNAPluginNS::backend::AMIntelDNN::InitActiveList(uint32_t *ptr_active_list) { +void backend::AMIntelDNN::InitActiveList(uint32_t *ptr_active_list) { ptr_active_outputs_ = ptr_active_list; if (ptr_active_list == nullptr) { if (component[component.size() - 1].orientation_out == kDnnInterleavedOrientation) { @@ -100,7 +85,7 @@ void GNAPluginNS::backend::AMIntelDNN::InitActiveList(uint32_t *ptr_active_list) } -void GNAPluginNS::backend::AMIntelDNN::InitAffineComponentPrivate(intel_dnn_component_t &comp, +void backend::AMIntelDNN::InitAffineComponentPrivate(intel_dnn_component_t &comp, uint32_t num_rows_in, uint32_t num_columns, uint32_t num_rows_out, @@ -123,7 +108,6 @@ void GNAPluginNS::backend::AMIntelDNN::InitAffineComponentPrivate(intel_dnn_comp comp.num_bytes_per_input = num_bytes_per_input; comp.num_bytes_per_output = num_bytes_per_output; comp.operation = isDiag ? kDnnDiagonalOp : kDnnAffineOp; - comp.macro_operation = kDnnMacroOpNone; comp.orientation_in = kDnnInterleavedOrientation; comp.orientation_out = kDnnInterleavedOrientation; comp.op.affine.num_bytes_per_weight = num_bytes_per_weight; @@ -145,23 +129,23 @@ void GNAPluginNS::backend::AMIntelDNN::InitAffineComponentPrivate(intel_dnn_comp } -void GNAPluginNS::backend::AMIntelDNN::InitConvolutional1DComponentPrivate(intel_dnn_component_t &comp, - uint32_t num_columns_in, - uint32_t num_columns_out, - uint32_t num_bytes_per_input, - uint32_t num_bytes_per_output, - uint32_t num_bytes_per_weight, - uint32_t num_bytes_per_bias, - uint32_t num_filters, - uint32_t num_filter_coefficients, - const uint32_t convStride, - float weight_scale_factor, - float output_scale_factor, - void *&ptr_inputs, - void *&ptr_outputs, - void *&ptr_filters, - void *&ptr_biases, - bool postInitMem) { +void backend::AMIntelDNN::InitConvolutional1DComponentPrivate(intel_dnn_component_t &comp, + uint32_t num_columns_in, + uint32_t num_columns_out, + uint32_t num_bytes_per_input, + uint32_t num_bytes_per_output, + uint32_t num_bytes_per_weight, + uint32_t num_bytes_per_bias, + uint32_t num_filters, + uint32_t num_filter_coefficients, + const uint32_t convStride, + float weight_scale_factor, + float output_scale_factor, + void *&ptr_inputs, + void *&ptr_outputs, + void *&ptr_filters, + void *&ptr_biases, + bool postInitMem) { comp.num_rows_in = 1; comp.num_columns_in = num_columns_in; comp.num_rows_out = 1; @@ -169,7 +153,6 @@ void GNAPluginNS::backend::AMIntelDNN::InitConvolutional1DComponentPrivate(intel comp.num_bytes_per_input = num_bytes_per_input; comp.num_bytes_per_output = num_bytes_per_output; comp.operation = kDnnConvolutional1dOp; - comp.macro_operation = kDnnMacroOpNone; comp.orientation_in = kDnnNonInterleavedOrientation; comp.orientation_out = kDnnNonInterleavedOrientation; comp.ptr_inputs = ptr_inputs; @@ -199,9 +182,9 @@ void GNAPluginNS::backend::AMIntelDNN::InitConvolutional1DComponentPrivate(intel THROW_GNA_EXCEPTION << "Number of inputs to Convolutional1DComponent (" << num_columns_in << ") is not a multiply by 8"; } - if (num_filters < GNALimitations::convMinFiltersNum || - num_filters > GNALimitations::convMaxFiltersNum || - num_filters % GNALimitations::convFiltersNumDivider != 0) { + if (num_filters < limitations::convMinFiltersNum || + num_filters > limitations::convMaxFiltersNum || + num_filters % limitations::convFiltersNumDivider != 0) { THROW_GNA_EXCEPTION << "Unsupported number of filters in Convolutional1DComponent: " << num_filters; } auto max_number_of_out_elements = outputFromConv(num_columns_in, num_filter_coefficients, convStride); @@ -210,26 +193,25 @@ void GNAPluginNS::backend::AMIntelDNN::InitConvolutional1DComponentPrivate(intel } } -void GNAPluginNS::backend::AMIntelDNN::InitConvolutional2DComponentPrivate(intel_dnn_component_t& comp, - OvGnaTensor inputTensor, - OvGnaTensor outputTensor, - OvGnaTensor filterTensor, - OvGnaTensor biasTensor, - std::array convStride, - std::array zeroPadding, - float weight_scale_factor, - float output_scale_factor, - void*& ptr_inputs, - void*& ptr_outputs, - void*& ptr_filters, - void*& ptr_biases) { +void backend::AMIntelDNN::InitConvolutional2DComponentPrivate(intel_dnn_component_t& comp, + OvGnaTensor inputTensor, + OvGnaTensor outputTensor, + OvGnaTensor filterTensor, + OvGnaTensor biasTensor, + std::array convStride, + std::array zeroPadding, + float weight_scale_factor, + float output_scale_factor, + void*& ptr_inputs, + void*& ptr_outputs, + void*& ptr_filters, + void*& ptr_biases) { comp.tensors.clear(); comp.tensors.push_back(inputTensor); comp.tensors.push_back(outputTensor); comp.tensors.push_back(filterTensor); comp.tensors.push_back(biasTensor); comp.operation = kDnnConvolutional2dOp; - comp.macro_operation = kDnnMacroOpNone; comp.orientation_in = kDnnNonInterleavedOrientation; comp.orientation_out = kDnnNonInterleavedOrientation; comp.ptr_inputs = ptr_inputs; @@ -246,7 +228,7 @@ void GNAPluginNS::backend::AMIntelDNN::InitConvolutional2DComponentPrivate(intel ptr_outputs = &comp.ptr_outputs; } -bool GNAPluginNS::backend::AMIntelDNN::isOperationCnnLegacySpecific(const Gna2Operation& op) { +bool backend::AMIntelDNN::isOperationCnnLegacySpecific(const Gna2Operation& op) { // GNA compile target GNA_TARGET_3_0 does not support pooling window < pooling stride return op.Type == Gna2OperationTypeConvolution && op.NumberOfParameters > std::max(PoolStrideParamIdx, PoolWinParamIdx) && @@ -256,7 +238,7 @@ bool GNAPluginNS::backend::AMIntelDNN::isOperationCnnLegacySpecific(const Gna2Op static_cast(op.Parameters[PoolStrideParamIdx])->Dimensions[0] > static_cast(op.Parameters[PoolWinParamIdx])->Dimensions[0]; } -void GNAPluginNS::backend::AMIntelDNN::updateNumberOfOutputsIfPoolingEnabled(Gna2Model& gnaModel, bool useLegacyFormula) { +void backend::AMIntelDNN::updateNumberOfOutputsIfPoolingEnabled(Gna2Model& gnaModel, bool useLegacyFormula) { IE_ASSERT(gnaModel.Operations != nullptr || gnaModel.NumberOfOperations == 0); for (uint32_t i = 0; i < gnaModel.NumberOfOperations; i++) { auto& gnaOp = gnaModel.Operations[i]; @@ -277,10 +259,10 @@ void GNAPluginNS::backend::AMIntelDNN::updateNumberOfOutputsIfPoolingEnabled(Gna const auto fltStride = fltStrideShape.Dimensions[0]; const auto inVecCnt = inputShape.Dimensions[1]; const auto nFltSize = gnaOp.Operands[FilterOpIdx]->Shape.Dimensions[1]; - const auto outFromConv = GNAPluginNS::GNAConvolutionLayer::outputFromConv(inVecCnt, nFltSize, fltStride); + const auto outFromConv = gna_convolution_layer::outputFromConv(inVecCnt, nFltSize, fltStride); const auto& poolWindow = *static_cast(gnaOp.Parameters[PoolWinParamIdx]); const auto& poolStride = *static_cast(gnaOp.Parameters[PoolStrideParamIdx]); - const auto numberOfOutputs = GNAPluginNS::GNAConvolutionLayer::outputFromPooling( + const auto numberOfOutputs = gna_convolution_layer::outputFromPooling( outFromConv, poolWindow.Dimensions[0], poolStride.Dimensions[0], useLegacyFormula || isOperationCnnLegacySpecific(gnaOp)); auto& outputTensor = *gnaOp.Operands[OutOpIdx]; @@ -289,21 +271,20 @@ void GNAPluginNS::backend::AMIntelDNN::updateNumberOfOutputsIfPoolingEnabled(Gna } } -void GNAPluginNS::backend::AMIntelDNN::InitMaxpoolComponentPrivate(intel_dnn_component_t &comp, - std::array inCHW, - std::array outCHW, - uint32_t num_bytes_per_input, - uint32_t num_bytes_per_output, - std::array poolingWindowXY, - std::array poolingStrideXY, - float output_scale_factor, - void *&ptr_inputs, - void *&ptr_outputs, - bool postInitMem) { +void backend::AMIntelDNN::InitMaxpoolComponentPrivate(intel_dnn_component_t &comp, + std::array inCHW, + std::array outCHW, + uint32_t num_bytes_per_input, + uint32_t num_bytes_per_output, + std::array poolingWindowXY, + std::array poolingStrideXY, + float output_scale_factor, + void *&ptr_inputs, + void *&ptr_outputs, + bool postInitMem) { comp.num_bytes_per_input = num_bytes_per_input; comp.num_bytes_per_output = num_bytes_per_output; comp.operation = kDnnMaxPoolOp; - comp.macro_operation = kDnnMacroOpNone; comp.orientation_in = kDnnNonInterleavedOrientation; comp.orientation_out = kDnnNonInterleavedOrientation; comp.op.maxpool.inCHW = inCHW; @@ -321,20 +302,20 @@ void GNAPluginNS::backend::AMIntelDNN::InitMaxpoolComponentPrivate(intel_dnn_com } } -void GNAPluginNS::backend::AMIntelDNN::InitCopyComponentPrivate(intel_dnn_component_t &comp, - intel_dnn_orientation_t orientation, - uint32_t num_rows_in, - uint32_t num_columns_in, - uint32_t num_rows_out, - uint32_t num_columns_out, - uint32_t num_bytes_per_input, - uint32_t num_bytes_per_output, - float output_scale_factor, - uint32_t num_copy_rows, - uint32_t num_copy_columns, - void *&ptr_inputs, - void *&ptr_outputs, - bool postInitMem) { +void backend::AMIntelDNN::InitCopyComponentPrivate(intel_dnn_component_t &comp, + intel_dnn_orientation_t orientation, + uint32_t num_rows_in, + uint32_t num_columns_in, + uint32_t num_rows_out, + uint32_t num_columns_out, + uint32_t num_bytes_per_input, + uint32_t num_bytes_per_output, + float output_scale_factor, + uint32_t num_copy_rows, + uint32_t num_copy_columns, + void *&ptr_inputs, + void *&ptr_outputs, + bool postInitMem) { comp.num_rows_in = num_rows_in; comp.num_columns_in = num_columns_in; comp.num_rows_out = num_rows_out; @@ -342,7 +323,6 @@ void GNAPluginNS::backend::AMIntelDNN::InitCopyComponentPrivate(intel_dnn_compon comp.num_bytes_per_input = num_bytes_per_input; comp.num_bytes_per_output = num_bytes_per_output; comp.operation = kDnnCopyOp; - comp.macro_operation = kDnnMacroOpNone; comp.orientation_in = orientation; comp.orientation_out = orientation; comp.ptr_inputs = ptr_inputs; @@ -361,20 +341,20 @@ void GNAPluginNS::backend::AMIntelDNN::InitCopyComponentPrivate(intel_dnn_compon } } -void GNAPluginNS::backend::AMIntelDNN::InitPiecewiseLinearComponentPrivate(intel_dnn_component_t &comp, - const DnnActivation& function_id, - intel_dnn_orientation_t orientation, - uint32_t num_rows, - uint32_t num_columns, - uint32_t num_bytes_per_input, - uint32_t num_bytes_per_output, - uint32_t num_segments, - float output_scale_factor, - float input_scale_factor, - void *&ptr_inputs, - void *&ptr_outputs, - gna_pwl_segment_t *ptr_segments, - bool postInitMem) { +void backend::AMIntelDNN::InitPiecewiseLinearComponentPrivate(intel_dnn_component_t &comp, + const DnnActivation& function_id, + intel_dnn_orientation_t orientation, + uint32_t num_rows, + uint32_t num_columns, + uint32_t num_bytes_per_input, + uint32_t num_bytes_per_output, + uint32_t num_segments, + float output_scale_factor, + float input_scale_factor, + void *&ptr_inputs, + void *&ptr_outputs, + gna_pwl_segment_t *ptr_segments, + bool postInitMem) { comp.num_rows_in = num_rows; comp.num_columns_in = num_columns; comp.num_rows_out = num_rows; @@ -382,7 +362,6 @@ void GNAPluginNS::backend::AMIntelDNN::InitPiecewiseLinearComponentPrivate(intel comp.num_bytes_per_input = num_bytes_per_input; comp.num_bytes_per_output = num_bytes_per_output; comp.operation = kDnnPiecewiselinearOp; - comp.macro_operation = kDnnMacroOpNone; comp.orientation_in = orientation; comp.orientation_out = orientation; comp.op.pwl.func_id = function_id; @@ -404,15 +383,15 @@ void GNAPluginNS::backend::AMIntelDNN::InitPiecewiseLinearComponentPrivate(intel } } -void GNAPluginNS::backend::AMIntelDNN::InitInterleaveComponentPrivate(intel_dnn_component_t &comp, - uint32_t num_rows_in, - uint32_t num_columns_in, - uint32_t num_bytes_per_input, - uint32_t num_bytes_per_output, - float output_scale_factor, - void *&ptr_inputs, - void *&ptr_outputs, - bool postInitMem) { +void backend::AMIntelDNN::InitInterleaveComponentPrivate(intel_dnn_component_t &comp, + uint32_t num_rows_in, + uint32_t num_columns_in, + uint32_t num_bytes_per_input, + uint32_t num_bytes_per_output, + float output_scale_factor, + void *&ptr_inputs, + void *&ptr_outputs, + bool postInitMem) { comp.num_rows_in = num_rows_in; comp.num_columns_in = num_columns_in; comp.num_rows_out = num_columns_in; @@ -420,7 +399,6 @@ void GNAPluginNS::backend::AMIntelDNN::InitInterleaveComponentPrivate(intel_dnn_ comp.num_bytes_per_input = num_bytes_per_input; comp.num_bytes_per_output = num_bytes_per_output; comp.operation = kDnnInterleaveOp; - comp.macro_operation = kDnnMacroOpNone; comp.orientation_in = kDnnNonInterleavedOrientation; comp.orientation_out = kDnnInterleavedOrientation; comp.output_scale_factor = output_scale_factor; @@ -434,15 +412,15 @@ void GNAPluginNS::backend::AMIntelDNN::InitInterleaveComponentPrivate(intel_dnn_ } } -void GNAPluginNS::backend::AMIntelDNN::InitDeinterleaveComponentPrivate(intel_dnn_component_t &comp, - uint32_t num_rows_in, - uint32_t num_columns_in, - uint32_t num_bytes_per_input, - uint32_t num_bytes_per_output, - float output_scale_factor, - void *&ptr_inputs, - void *&ptr_outputs, - bool postInitMem) { +void backend::AMIntelDNN::InitDeinterleaveComponentPrivate(intel_dnn_component_t &comp, + uint32_t num_rows_in, + uint32_t num_columns_in, + uint32_t num_bytes_per_input, + uint32_t num_bytes_per_output, + float output_scale_factor, + void *&ptr_inputs, + void *&ptr_outputs, + bool postInitMem) { comp.num_rows_in = num_rows_in; comp.num_columns_in = num_columns_in; comp.num_rows_out = num_columns_in; @@ -450,7 +428,6 @@ void GNAPluginNS::backend::AMIntelDNN::InitDeinterleaveComponentPrivate(intel_dn comp.num_bytes_per_input = num_bytes_per_input; comp.num_bytes_per_output = num_bytes_per_output; comp.operation = kDnnDeinterleaveOp; - comp.macro_operation = kDnnMacroOpNone; comp.orientation_in = kDnnInterleavedOrientation; comp.orientation_out = kDnnInterleavedOrientation; comp.output_scale_factor = output_scale_factor; @@ -464,7 +441,7 @@ void GNAPluginNS::backend::AMIntelDNN::InitDeinterleaveComponentPrivate(intel_dn } } -float GNAPluginNS::backend::AMIntelDNN::OutputScaleFactor(intel_dnn_component_t &comp) { +float backend::AMIntelDNN::OutputScaleFactor(intel_dnn_component_t &comp) { return comp.output_scale_factor; } @@ -476,7 +453,7 @@ struct InputEndPoint { InputEndPoint(int nidx, size_t sz, size_t esize) : idx(nidx), size(sz), num_bytes_per_output(esize) {} }; -void GNAPluginNS::backend::AMIntelDNN::WriteGraphWizModel(const char *filename) { +void backend::AMIntelDNN::WriteGraphWizModel(const char *filename) { auto & components = component; #define IS_AFFINE(k)\ @@ -743,12 +720,12 @@ void PrintTensors(std::ofstream& out, T tensors) { } } -void GNAPluginNS::backend::AMIntelDNN::PrintOffset(std::ofstream& out, const std::string& type, void* ptr) { +void backend::AMIntelDNN::PrintOffset(std::ofstream& out, const std::string& type, void* ptr) { const auto queue = memory->getQueue(ptr); std::string typeOfRegion = "UNKNOWN_QUEUE"; auto offset = std::numeric_limits::max(); if (queue != nullptr) { - typeOfRegion = GNAPluginNS::memory::rRegionToStr(queue->regionType()); + typeOfRegion = memory::rRegionToStr(queue->regionType()); offset = queue->getOffset(ptr).second; } out << " " << typeOfRegion << "\n"; @@ -756,9 +733,9 @@ void GNAPluginNS::backend::AMIntelDNN::PrintOffset(std::ofstream& out, const std << "0x" << std::setfill('0') << std::setw(8) << std::hex << offset << "\n"; } -void GNAPluginNS::backend::AMIntelDNN::WriteDnnText(const char *filename, intel_dnn_number_type_t logging_precision) { +void backend::AMIntelDNN::WriteDnnText(const char *filename, intel_dnn_number_type_t logging_precision) { if ((compute_precision_ == kDnnFloat) && (logging_precision == kDnnInt)) { - fprintf(stderr, "Error trying to write floating point DNN as integer in GNAPluginNS::backend::AMIntelDNN::WriteDnnText().\n"); + fprintf(stderr, "Error trying to write floating point DNN as integer in backend::AMIntelDNN::WriteDnnText().\n"); fprintf(stderr, " Please convert to integer first.\n"); throw -1; } @@ -777,8 +754,7 @@ void GNAPluginNS::backend::AMIntelDNN::WriteDnnText(const char *filename, intel_ out_file << "\n"; out_file << " " << intel_dnn_number_type_name[logging_precision] << "\n"; - out_file << " " << intel_dnn_softmax_name[softmax_type] << "\n"; - const auto& regionsMap = GNAPluginNS::memory::GetAllRegionsToStrMap(); + const auto& regionsMap = memory::GetAllRegionsToStrMap(); for (const auto& regionPair : regionsMap) { out_file << " " << std::dec << regionPair.second << "\n"; out_file << " " << std::dec << memory->getRegionBytes(regionPair.first) << "\n"; @@ -818,7 +794,6 @@ void GNAPluginNS::backend::AMIntelDNN::WriteDnnText(const char *filename, intel_ layer++; } out_file << " " << intel_dnn_operation_name[component[i].operation] << "\n"; - out_file << " " << intel_dnn_macro_operation_name[component[i].macro_operation] << "\n"; out_file << " " << std::dec << num_rows_in << "\n"; out_file << " " << std::dec << num_columns_in << "\n"; out_file << " " << std::dec << num_rows_out << "\n"; @@ -1383,7 +1358,7 @@ void GNAPluginNS::backend::AMIntelDNN::WriteDnnText(const char *filename, intel_ } } -uint32_t GNAPluginNS::backend::AMIntelDNN::CountLayers() { +uint32_t backend::AMIntelDNN::CountLayers() { uint32_t n = 0; for (auto && c : component) { if (c.operation == kDnnAffineOp @@ -1401,7 +1376,7 @@ uint32_t GNAPluginNS::backend::AMIntelDNN::CountLayers() { return n; } -void GNAPluginNS::backend::AMIntelDNN::InitGNAStruct(Gna2Model *gnaModel, const std::string& gnaCompileTarget) { +void backend::AMIntelDNN::InitGNAStruct(Gna2Model *gnaModel, const std::string& gnaCompileTarget) { Gna2Operation * gnaOperation; if (gnaModel == nullptr) THROW_GNA_EXCEPTION << "Invalid input parameter"; @@ -1409,12 +1384,12 @@ void GNAPluginNS::backend::AMIntelDNN::InitGNAStruct(Gna2Model *gnaModel, const THROW_GNA_EXCEPTION << "InitGNAStruct can't work on preallocated layers array"; if (component.empty()) - THROW_GNA_EXCEPTION << "empty model in GNAPluginNS::backend::AMIntelDNN::InitGNAStruct()"; + THROW_GNA_EXCEPTION << "empty model in backend::AMIntelDNN::InitGNAStruct()"; gnaModel->NumberOfOperations = CountLayers(); gnaModel->Operations = reinterpret_cast(gnaUserAllocator(gnaModel->NumberOfOperations * sizeof(Gna2Operation))); if (gnaModel->Operations == nullptr) - THROW_GNA_EXCEPTION << "out of memory in GNAPluginNS::backend::AMIntelDNN::InitGNAStruct()"; + THROW_GNA_EXCEPTION << "out of memory in backend::AMIntelDNN::InitGNAStruct()"; memset(gnaModel->Operations, 0, gnaModel->NumberOfOperations * sizeof(Gna2Operation)); gnaOperation = gnaModel->Operations; for (int i = 0; i < component.size(); i++) { @@ -1666,7 +1641,7 @@ void GNAPluginNS::backend::AMIntelDNN::InitGNAStruct(Gna2Model *gnaModel, const gnaModel->NumberOfOperations = static_cast(std::distance(gnaModel->Operations, gnaOperation)); } -void GNAPluginNS::backend::AMIntelDNN::DestroyGNAStruct(Gna2Model *gnaModel) { +void backend::AMIntelDNN::DestroyGNAStruct(Gna2Model *gnaModel) { if (gnaModel->Operations != nullptr) { for (uint32_t i = 0; i < gnaModel->NumberOfOperations; i++) { switch (gnaModel->Operations[i].Type) { @@ -1686,7 +1661,7 @@ void GNAPluginNS::backend::AMIntelDNN::DestroyGNAStruct(Gna2Model *gnaModel) { gnaModel->NumberOfOperations = 0; } -void GNAPluginNS::backend::AMIntelDNN::WriteInputAndOutputTextGNA(const Gna2Model & model) { +void backend::AMIntelDNN::WriteInputAndOutputTextGNA(const Gna2Model & model) { #ifdef LIGHT_DUMP dump::WriteInputAndOutputTextGNAImpl( model, @@ -1695,7 +1670,7 @@ void GNAPluginNS::backend::AMIntelDNN::WriteInputAndOutputTextGNA(const Gna2Mode #endif } -void GNAPluginNS::backend::AMIntelDNN::WriteInputAndOutputText() { +void backend::AMIntelDNN::WriteInputAndOutputText() { #ifdef LIGHT_DUMP for (uint32_t i = 0; i < num_components(); i++) { std::stringstream out_file_name; @@ -1791,11 +1766,11 @@ void GNAPluginNS::backend::AMIntelDNN::WriteInputAndOutputText() { #endif } -uint32_t GNAPluginNS::backend::AMIntelDNN::num_components() { +uint32_t backend::AMIntelDNN::num_components() { return static_cast(component.size()); } -uint32_t GNAPluginNS::backend::AMIntelDNN::num_gna_layers() { +uint32_t backend::AMIntelDNN::num_gna_layers() { uint32_t num_layers = 0; std::set gna_layers({ kDnnAffineOp, kDnnDiagonalOp, @@ -1812,27 +1787,27 @@ uint32_t GNAPluginNS::backend::AMIntelDNN::num_gna_layers() { return num_layers; } -uint32_t GNAPluginNS::backend::AMIntelDNN::num_group_in() { +uint32_t backend::AMIntelDNN::num_group_in() { return ((!component.empty()) ? ((component[0].orientation_in == kDnnInterleavedOrientation) ? component[0].num_columns_in : component[0].num_rows_in) : 0); } -uint32_t GNAPluginNS::backend::AMIntelDNN::num_group_out() { +uint32_t backend::AMIntelDNN::num_group_out() { return ((!component.empty()) ? ((component[component.size() - 1].orientation_out == kDnnInterleavedOrientation) ? component[component.size() - 1].num_columns_out : component[component.size() - 1].num_rows_out) : 0); } -uint32_t GNAPluginNS::backend::AMIntelDNN::num_inputs() { +uint32_t backend::AMIntelDNN::num_inputs() { return component.empty() ? 0 : component[0].num_rows_in; } -uint32_t GNAPluginNS::backend::AMIntelDNN::num_outputs() { +uint32_t backend::AMIntelDNN::num_outputs() { return (component[component.size() - 1].orientation_out == kDnnInterleavedOrientation) ? component[ component.size() - 1].num_rows_out : component[component.size() - 1].num_columns_out; } -std::string GNAPluginNS::backend::AMIntelDNN::getDumpFilePrefix(const std::string& folder) { +std::string backend::AMIntelDNN::getDumpFilePrefix(const std::string& folder) { const char pathSeparator = #ifdef _WIN32 '\\'; @@ -1842,14 +1817,18 @@ std::string GNAPluginNS::backend::AMIntelDNN::getDumpFilePrefix(const std::strin return std::string(".") + pathSeparator + folder + pathSeparator + std::to_string(dump_write_index) + pathSeparator; } -std::string GNAPluginNS::backend::AMIntelDNN::getDumpFilePrefixGNA() { +std::string backend::AMIntelDNN::getDumpFilePrefixGNA() { return getDumpFilePrefix("gna_layers"); } -std::string GNAPluginNS::backend::AMIntelDNN::getDumpFolderName() { +std::string backend::AMIntelDNN::getDumpFolderName() { return getDumpFilePrefix("layers"); } -std::string GNAPluginNS::backend::AMIntelDNN::getRefFolderName() { +std::string backend::AMIntelDNN::getRefFolderName() { return getDumpFilePrefix("ref_layers"); } + +} // namespace backend +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/backend/am_intel_dnn.hpp b/src/plugins/intel_gna/src/backend/am_intel_dnn.hpp index 4c9c6897d64..ea1df0572d7 100644 --- a/src/plugins/intel_gna/src/backend/am_intel_dnn.hpp +++ b/src/plugins/intel_gna/src/backend/am_intel_dnn.hpp @@ -8,8 +8,8 @@ #include #include -#include "dnn_types.h" -#include "gna_types.h" +#include "dnn_types.hpp" +#include "gna_types.hpp" #include "gna/gna_config.hpp" #include "log/debug.hpp" @@ -17,9 +17,8 @@ #include "memory/gna_memory.hpp" #include -using GNAPluginNS::memory::GNAMemoryInterface; - -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace backend { class AMIntelDNN { @@ -28,24 +27,15 @@ public: : ptr_active_outputs_(NULL), num_active_outputs_(0), input_scale_factor_(1.0), - num_left_context(0), - num_right_context(0), do_rotate_input(false), - do_rotate_output(false), num_rotate_rows(0), num_rotate_columns(0), - num_rotate_output_rows(0), - num_rotate_output_columns(0), - softmax_type(kSoftmaxNone), - ptr_sumgroup_sizes(NULL), - num_sumgroup_sizes(0), - ptr_priors(NULL), compute_precision_(kDnnNumNumberType) { } ~AMIntelDNN(); - void Init(GNAMemoryInterface * memoryInterface, + void Init(memory::GNAMemoryInterface * memoryInterface, intel_dnn_number_type_t compute_precision, float scale_factor); @@ -284,9 +274,31 @@ public: true); } + template + void AdvanceOperationIfAllApplied(const std::vector& cmp, int i, T*& operation) { + if (i == cmp.size() - 1 || cmp[i + 1].operation != kDnnPiecewiselinearOp) { + ++operation; + } + } - float OutputScaleFactor(uint32_t component_index) { - return OutputScaleFactor(component[component_index]); + template + void AdvanceCnnOperationIfAllApplied(const std::vector& cmp, int i, T*& operation) { + if (i == cmp.size() - 1 || + ((cmp[i + 1].operation != kDnnMaxPoolOp) && (cmp[i + 1].operation != kDnnPiecewiselinearOp))) { + operation++; + } + } + + template + void AdvancePwlOperationIfAllApplied(const std::vector& cmp, int i, T*& operation) { + if (i == cmp.size() - 1 || + ((cmp[i + 1].operation != kDnnMaxPoolOp) && (cmp[i + 1].operation != kDnnPiecewiselinearOp))) { + operation++; + } + } + + float OutputScaleFactor(uint32_t cmp_index) { + return OutputScaleFactor(component[cmp_index]); } float OutputScaleFactor(intel_dnn_component_t &comp); @@ -318,19 +330,10 @@ public: uint32_t num_outputs(); std::vector component; - uint32_t num_left_context; - uint32_t num_right_context; uint32_t new_num_conv_columns = 0; bool do_rotate_input; - bool do_rotate_output; uint32_t num_rotate_rows = 0; uint32_t num_rotate_columns = 0; - uint32_t num_rotate_output_rows = 0; - uint32_t num_rotate_output_columns = 0; - DnnSoftmaxType softmax_type; - uint32_t *ptr_sumgroup_sizes; - uint32_t num_sumgroup_sizes; - float *ptr_priors; void WriteInputAndOutputText(); @@ -339,7 +342,7 @@ public: void BeginNewWrite(uint32_t index); private: - GNAMemoryInterface* memory = nullptr; + memory::GNAMemoryInterface* memory = nullptr; uint32_t *ptr_active_outputs_; uint32_t num_active_outputs_; intel_dnn_number_type_t compute_precision_; @@ -442,6 +445,20 @@ private: void*& ptr_filters, void*& ptr_biases); + static void InitDWSCComponentPrivate(intel_dnn_component_t& comp, + OvGnaTensor inputTensor, + OvGnaTensor outputTensor, + OvGnaTensor filterTensor, + OvGnaTensor biasTensor, + std::array convStride, + std::array zeroPadding, + float weight_scale_factor, + float output_scale_factor, + void*& ptr_inputs, + void*& ptr_outputs, + void*& ptr_filters, + void*& ptr_biases); + static void InitAffineComponentPrivate(intel_dnn_component_t &comp, uint32_t num_rows_in, uint32_t num_columns, @@ -464,5 +481,7 @@ private: std::string getDumpFolderName(); std::string getRefFolderName(); }; + } // namespace backend -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/backend/dnn.cpp b/src/plugins/intel_gna/src/backend/dnn.cpp deleted file mode 100644 index 28c2264e618..00000000000 --- a/src/plugins/intel_gna/src/backend/dnn.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include -#include - -#include -#include "gna2_model_helper.hpp" -#include "log/dump.hpp" - -#ifndef _NO_MKL_ -#include -#endif - -#include "runtime/floatmath.h" -#include "dnn.hpp" - -#include "runtime/pwl.h" -#include "runtime/cnn.h" - -void GNAPluginNS::backend::ClearScoreError(intel_score_error_t *error) { - error->num_scores = 0; - error->num_errors = 0; - error->max_error = 0.0; - error->sum_error = 0.0; - error->sum_squared_error = 0.0; - error->max_rel_error = 0.0; - error->sum_rel_error = 0.0; - error->sum_squared_rel_error = 0.0; -} - -void GNAPluginNS::backend::UpdateScoreError(intel_score_error_t *error, intel_score_error_t *total_error) { - total_error->num_errors += error->num_errors; - total_error->num_scores += error->num_scores; - total_error->sum_error += error->sum_error; - total_error->sum_squared_error += error->sum_squared_error; - if (error->max_error > total_error->max_error) { - total_error->max_error = error->max_error; - } - total_error->sum_rel_error += error->sum_rel_error; - total_error->sum_squared_rel_error += error->sum_squared_rel_error; - if (error->max_rel_error > total_error->max_rel_error) { - total_error->max_rel_error = error->max_rel_error; - } -} - -void GNAPluginNS::backend::SoftmaxGoogle(float *ptr_output, float *ptr_input, const uint32_t num_outputs, const uint32_t num_inputs) { - // Assumes input vector contains log likelihoods - // The computes x[i] = x[i] - log(sum_j exp(x[j])) - // This normalizes the likelihoods by the sum of likelihoods but stores them as log likelihoods - - float max_score = ptr_input[0]; - float sum = 0.0; - float diff; - // find max score for normalization to [0,1] - for (uint32_t i = 0; i < num_inputs; i++) { - if (ptr_input[i] > max_score) { - max_score = ptr_input[i]; - } - } - for (uint32_t i = 0; i < num_inputs; i++) { - sum += exp(ptr_input[i] - max_score); - } - if (sum < 1.0e-20) { - fprintf(stderr, "Warning: attempt to take log(0) in SoftmaxGoogle()!\n"); - sum = 1.0e-20f; - } - diff = max_score + std::log(sum); - for (uint32_t i = 0; i < num_outputs; i++) { - ptr_output[i] = ptr_input[i] - diff; - } -} diff --git a/src/plugins/intel_gna/src/backend/dnn.hpp b/src/plugins/intel_gna/src/backend/dnn.hpp deleted file mode 100644 index d1daaa8a789..00000000000 --- a/src/plugins/intel_gna/src/backend/dnn.hpp +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "am_intel_dnn.hpp" -#include "dnn_types.h" - -#include - -#define DNN_MAX_BATCH_SIZE 8 -#define DNN_MAX_INPUTS 3072 -#define DNN_MAX_OUTPUTS 8192 -#define DNN_MAX_ERROR 1.0e-4f -#define DNN_NUM_BYTES_INT_BIAS 4 -#define DNN_NUM_BYTES_INT_AFFINE_OUT 4 -#define DNN_RAND_INT8_AMPLITUDE 127.0f -#define DNN_RAND_INT16_AMPLITUDE 16384.0f -#define DNN_RAND_INT32_AMPLITUDE 1048576.0f -#define DNN_RAND_FLOAT32_AMPLITUDE 8.0f - -namespace GNAPluginNS { -namespace backend { - -void PlotFloatIntDnn(GNAPluginNS::backend::AMIntelDNN *dnn, GNAPluginNS::backend::AMIntelDNN *dnn_int); -void ClearScoreError(intel_score_error_t *error); -void UpdateScoreError(intel_score_error_t *error, intel_score_error_t *total_error); -void SoftmaxGoogle(float *ptr_output, float *ptr_input, const uint32_t num_outputs, const uint32_t num_inputs); - -template -void AdvanceOperationIfAllApplied(const std::vector& component, int i, T*& operation) { - if (i == component.size() - 1 || component[i + 1].operation != kDnnPiecewiselinearOp) { - ++operation; - } -} - -template -void AdvanceCnnOperationIfAllApplied(const std::vector& component, int i, T*& operation) { - if (i == component.size() - 1 || ((component[i + 1].operation != kDnnMaxPoolOp) - && (component[i + 1].operation != kDnnPiecewiselinearOp))) { - operation++; - } -} - -template -void AdvancePwlOperationIfAllApplied(const std::vector& component, int i, T*& operation) { - if (i == component.size() - 1 || ((component[i + 1].operation != kDnnMaxPoolOp) - && (component[i + 1].operation != kDnnPiecewiselinearOp))) { - operation++; - } -} - -} // namespace backend -} // namespace GNAPluginNS diff --git a/src/plugins/intel_gna/src/backend/dnn_components.cpp b/src/plugins/intel_gna/src/backend/dnn_components.cpp index 4af9b27f612..e269b7577f4 100644 --- a/src/plugins/intel_gna/src/backend/dnn_components.cpp +++ b/src/plugins/intel_gna/src/backend/dnn_components.cpp @@ -14,17 +14,18 @@ #include "dnn_components.hpp" #include "log/log.hpp" -using namespace ov::intel_gna; -using namespace GNAPluginNS; -using namespace GNAPluginNS::backend; +namespace ov { +namespace intel_gna { +namespace backend { -intel_dnn_component_t & DnnComponents::addComponent(const std::string layerName, const std::string layerMetaType) { +intel_dnn_component_t& DnnComponents::addComponent(const std::string layerName, const std::string layerMetaType) { auto isDelayed = InferenceEngine::details::CaselessEq()(layerMetaType, DelayedCopyLayerName); delayedOperations += isDelayed ? 1 : 0; components.emplace_back(DnnComponentExtra{layerName, {}, isDelayed}); - auto ¤tComponent = components.back().dnnComponent; + auto& currentComponent = components.back().dnnComponent; - log::trace() << "IR layer : " << std::left << std::setw(20) << layerName << " " << layerMetaType << "_" << components.size() - 1 << std::endl; + log::trace() << "IR layer : " << std::left << std::setw(20) << layerName << " " << layerMetaType << "_" + << components.size() - 1 << std::endl; currentComponent.original_layer_name = components.back().name.c_str(); int execOrder = 0; @@ -32,10 +33,11 @@ intel_dnn_component_t & DnnComponents::addComponent(const std::string layerName, execOrder = static_cast(components.size() - 1 - delayedOperations); } else { // todo: not perfect - propose to create mapping table that will be printed out by extra request - execOrder = - static_cast(delayedOperations); + execOrder = -static_cast(delayedOperations); } - log::debug() << "IR layer : " << std::left << std::setw(20) << layerName << " " << layerMetaType << "_" << execOrder << std::endl; + log::debug() << "IR layer : " << std::left << std::setw(20) << layerName << " " << layerMetaType << "_" << execOrder + << std::endl; return currentComponent; } @@ -47,7 +49,7 @@ intel_dnn_component_t* DnnComponents::findComponent(InferenceEngine::CNNLayerPtr return nullptr; } -intel_dnn_component_t* GNAPluginNS::backend::DnnComponents::findComponent(const std::string& layerName) { +intel_dnn_component_t* DnnComponents::findComponent(const std::string& layerName) { auto component = std::find_if(begin(components), end(components), [&](const storage_type ::value_type& comp) { return comp.name == layerName; }); @@ -57,8 +59,7 @@ intel_dnn_component_t* GNAPluginNS::backend::DnnComponents::findComponent(const return nullptr; } -const intel_dnn_component_t* GNAPluginNS::backend::DnnComponents::findComponent( - const InferenceEngine::CNNLayerPtr layer) const { +const intel_dnn_component_t* DnnComponents::findComponent(const InferenceEngine::CNNLayerPtr layer) const { if (layer) { return findComponent(layer->name); } @@ -66,7 +67,7 @@ const intel_dnn_component_t* GNAPluginNS::backend::DnnComponents::findComponent( return nullptr; } -const intel_dnn_component_t* GNAPluginNS::backend::DnnComponents::findComponent(const std::string& layerName) const { +const intel_dnn_component_t* DnnComponents::findComponent(const std::string& layerName) const { auto component = std::find_if(begin(components), end(components), [&](const storage_type ::value_type& comp) { return comp.name == layerName; }); @@ -82,10 +83,14 @@ std::vector DnnComponents::getExecutionOrder() { uint32_t direct_id = 0; uint32_t delayed_id = static_cast(components.size() - delayedOperations); - for (auto &&c : components) { - uint32_t &id = c.isDelayed ? delayed_id : direct_id; + for (auto&& c : components) { + uint32_t& id = c.isDelayed ? delayed_id : direct_id; result[id] = c.dnnComponent; id++; } return result; } + +} // namespace backend +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/backend/dnn_components.hpp b/src/plugins/intel_gna/src/backend/dnn_components.hpp index 5776393d01f..5bfc1ef1ee7 100644 --- a/src/plugins/intel_gna/src/backend/dnn_components.hpp +++ b/src/plugins/intel_gna/src/backend/dnn_components.hpp @@ -11,11 +11,13 @@ #include #include -#include "dnn_types.h" +#include "dnn_types.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace backend { + struct DnnComponentExtra { std::string name; intel_dnn_component_t dnnComponent; @@ -71,5 +73,7 @@ struct DnnComponents { private: uint32_t delayedOperations = 0; }; + } // namespace backend -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/backend/dnn_traits.hpp b/src/plugins/intel_gna/src/backend/dnn_traits.hpp deleted file mode 100644 index afac4f9faf7..00000000000 --- a/src/plugins/intel_gna/src/backend/dnn_traits.hpp +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2018-2022 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// -// dnn_traits.hpp : c++ trait approach to define dnn objects -// - -#pragma once - -#include "dnn_types.h" - -template -struct DnnTrait {}; - -template<> -struct DnnTrait { - using Type = intel_affine_t; - static Type *getLayer(intel_dnn_component_t &component) { - return &component.op.affine; - } -}; - -template<> -struct DnnTrait { - using Type = intel_piecewiselinear_t; - static Type *getLayer(intel_dnn_component_t &component) { - return &component.op.pwl; - } -}; - -template<> -struct DnnTrait { - using Type = intel_affine_t; - static Type *getLayer(intel_dnn_component_t &component) { - return &component.op.affine; - } -}; - -template<> -struct DnnTrait { - using Type = intel_convolutionalD_t; - static Type *getLayer(intel_dnn_component_t &component) { - return &component.op.conv1D; - } -}; - -template<> -struct DnnTrait { - using Type = intel_maxpool_t; - static Type *getLayer(intel_dnn_component_t &component) { - return &component.op.maxpool; - } -}; - -template<> -struct DnnTrait { - using Type = intel_recurrent_t; - static Type *getLayer(intel_dnn_component_t &component) { - return &component.op.recurrent; - } -}; - -template<> -struct DnnTrait { - using Type = intel_interleave_t; - static Type *getLayer(intel_dnn_component_t &component) { - return &component.op.interleave; - } -}; - -template<> -struct DnnTrait { - using Type = intel_deinterleave_t; - static Type *getLayer(intel_dnn_component_t &component) { - return &component.op.deinterleave; - } -}; - -template<> -struct DnnTrait { - using Type = intel_copy_t; - static Type *getLayer(intel_dnn_component_t &component) { - return &component.op.copy; - } -}; - -template<> -struct DnnTrait { - using Type = void; - static Type *getLayer(intel_dnn_component_t &component) { - return nullptr; - } -}; diff --git a/src/plugins/intel_gna/src/backend/dnn_types.cpp b/src/plugins/intel_gna/src/backend/dnn_types.cpp index 7dc5d4f2680..d4ceb08a8eb 100644 --- a/src/plugins/intel_gna/src/backend/dnn_types.cpp +++ b/src/plugins/intel_gna/src/backend/dnn_types.cpp @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#include "dnn_types.h" +#include "dnn_types.hpp" const char *intel_dnn_activation_name[kActNumType] = { "kActNone", @@ -25,13 +25,6 @@ const char *intel_dnn_activation_name[kActNumType] = { "kActPwl" }; -const char *intel_dnn_softmax_name[kSoftmaxNumType] = { - "kSoftmaxNone", - "kSoftmaxKaldiSumGroup", - "kSoftmaxKaldiApplyLog", - "kSoftmaxGoogle" -}; - const char* intel_dnn_operation_name[kDnnNumOp] = { "kDnnNullOp", "kDnnAffineOp", @@ -46,12 +39,6 @@ const char* intel_dnn_operation_name[kDnnNumOp] = { "kDnnCopyOp" }; -const char *intel_dnn_macro_operation_name[kDnnNumMacroOp] = { - "kDnnMacroOpNone", - "kDnnMacroOpLstm", - "kDnnMacroOpBiLstm" -}; - const char *intel_dnn_number_type_name[kDnnNumNumberType] = { "kDnnFloat", "kDnnInt" diff --git a/src/plugins/intel_gna/src/backend/dnn_types.h b/src/plugins/intel_gna/src/backend/dnn_types.hpp similarity index 93% rename from src/plugins/intel_gna/src/backend/dnn_types.h rename to src/plugins/intel_gna/src/backend/dnn_types.hpp index 5ff50231d31..6bd9275ad63 100644 --- a/src/plugins/intel_gna/src/backend/dnn_types.h +++ b/src/plugins/intel_gna/src/backend/dnn_types.hpp @@ -10,7 +10,7 @@ #include #include -#include "gna_types.h" +#include "gna_types.hpp" #include "log/debug.hpp" enum DnnActivationType : uint8_t { @@ -83,16 +83,6 @@ static_assert(std::is_trivial::value, "DnnActivation is not triva extern const char *intel_dnn_activation_name[kActNumType]; -typedef enum DnnSoftmaxType { - kSoftmaxNone, - kSoftmaxKaldiSumgroup, - kSoftmaxEesen, - kSoftmaxGoogle, - kSoftmaxNumType -} intel_dnn_softmax_type_t; - -extern const char *intel_dnn_softmax_name[kSoftmaxNumType]; - typedef enum { kDnnUnknownOrientation = 100, kDnnInterleavedOrientation, @@ -117,15 +107,6 @@ typedef enum { extern const char* intel_dnn_operation_name[kDnnNumOp]; -typedef enum { - kDnnMacroOpNone, - kDnnMacroOpLstm, - kDnnMacroOpBiLstm, - kDnnNumMacroOp -} intel_dnn_macro_operation_t; - -extern const char *intel_dnn_macro_operation_name[kDnnNumMacroOp]; - typedef enum { kDnnFloat, kDnnInt, @@ -262,7 +243,6 @@ struct intel_dnn_component_t { uint32_t num_bytes_per_input; uint32_t num_bytes_per_output; intel_dnn_operation_t operation; - intel_dnn_macro_operation_t macro_operation; intel_dnn_orientation_t orientation_in; intel_dnn_orientation_t orientation_out; union operation_struct_t { diff --git a/src/plugins/intel_gna/src/backend/gna_limitations.cpp b/src/plugins/intel_gna/src/backend/gna_limitations.cpp index ffe9de1bab7..df59e1438c5 100644 --- a/src/plugins/intel_gna/src/backend/gna_limitations.cpp +++ b/src/plugins/intel_gna/src/backend/gna_limitations.cpp @@ -15,11 +15,10 @@ #include "gna_limitations.hpp" #include "gna/gna_config.hpp" -using namespace ov::intel_gna; - -namespace GNAPluginNS { -namespace GNALimitations { -namespace Cnn2D { +namespace ov { +namespace intel_gna { +namespace limitations { +namespace cnn2d { bool IsEqualToLimit::isValid(const uint32_t val) const { return val == compared_value; @@ -353,7 +352,7 @@ bool AbstractValidator::ValidationSuccesful(const bool throwOnError, return error.empty(); } -} // namespace Cnn2D +} // namespace cnn2d IE_SUPPRESS_DEPRECATED_START static bool ValidateConcatAxis(const InferenceEngine::CNNLayerPtr layer, std::string& errMessage) { @@ -370,7 +369,7 @@ static bool ValidateConcatAxis(const InferenceEngine::CNNLayerPtr layer, std::st auto isFusableWithConv = [](InferenceEngine::CNNLayerPtr ptr) { return (LayerInfo(ptr).isFusableWithConv() || LayerInfo(ptr).isNonFunctional() || (LayerInfo(ptr).isPermute() && ((ptr->input()->getLayout() == InferenceEngine::Layout::NCHW && - ptr->GetParamAsInts("order") == GetPermuteOrder(InferenceEngine::Layout::NCHW, InferenceEngine::Layout::NHWC)) || + ptr->GetParamAsInts("order") == permute::GetPermuteOrder(InferenceEngine::Layout::NCHW, InferenceEngine::Layout::NHWC)) || (ptr->input()->getLayout() == InferenceEngine::Layout::CHW && ptr->GetParamAsInts("order") == std::vector{0, 2, 1} /* NCW to NWC */)))); }; @@ -505,12 +504,12 @@ bool ValidateConvConcatAxis(const InferenceEngine::ConcatLayer* concat_layer) { break; // Convert dims to NHWC layout to allow later verification - auto new_order = GetPermuteOrder(concat_layout, InferenceEngine::Layout::NHWC); + auto new_order = permute::GetPermuteOrder(concat_layout, InferenceEngine::Layout::NHWC); InferenceEngine::SizeVector new_dims; for (size_t i = 0; i < dims_size; ++i) { new_dims.push_back(in_dims[new_order[i]]); } - concat_axis = GetPermuteOrder(InferenceEngine::Layout::NHWC, concat_layout)[concat_axis]; + concat_axis = permute::GetPermuteOrder(InferenceEngine::Layout::NHWC, concat_layout)[concat_axis]; // Looking for any axis with dimension > 1 before concatentaion axis; // in general such concatenation is unsupported @@ -565,7 +564,7 @@ bool AreLayersSupported(InferenceEngine::CNNNetwork& network, std::string& errMe startLayer, [&](const InferenceEngine::CNNLayerPtr layer) { LayerInfo info(layer); - if (GNAPluginNS::LayerTypeFromStr(layer->type) == GNAPluginNS::LayerType::NO_TYPE) { + if (LayerTypeFromStr(layer->type) == LayerType::NO_TYPE) { errMessage = "The plugin does not support layer: " + layer->name + ":" + layer->type + "\n"; check_result = false; } @@ -591,5 +590,6 @@ bool AreLayersSupported(InferenceEngine::CNNNetwork& network, std::string& errMe } IE_SUPPRESS_DEPRECATED_END -} // namespace GNALimitations -} // namespace GNAPluginNS +} // namespace limitations +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/backend/gna_limitations.hpp b/src/plugins/intel_gna/src/backend/gna_limitations.hpp index e1a8467be38..ff0ce36966f 100644 --- a/src/plugins/intel_gna/src/backend/gna_limitations.hpp +++ b/src/plugins/intel_gna/src/backend/gna_limitations.hpp @@ -4,15 +4,16 @@ #pragma once -#include "dnn_types.h" +#include "dnn_types.hpp" #include #include #include #include #include "gna_lib_ver_selector.hpp" -namespace GNAPluginNS { -namespace GNALimitations { +namespace ov { +namespace intel_gna { +namespace limitations { constexpr uint32_t bufferMaxSize = 65528; @@ -65,7 +66,8 @@ inline bool IsTransposeSupported(const std::vector& shape) { return min <= 8 && max % 8 == 0 && max >= 8 && max <= transposeMaxSize; } -namespace Cnn2D { +namespace cnn2d { + struct IsEqualToLimit { uint32_t compared_value; std::string what; @@ -118,11 +120,10 @@ struct VectorOrSquareLimit { }; struct RectLimitByChannels { - std::vector > limitPerChannel; + std::vector> limitPerChannel; RectLimit GetByChannels(const uint32_t channels) const; bool isValid(const uint32_t h, const uint32_t w, const uint32_t channels) const; - std::string GetErrorOrEmpty(const uint32_t h, const uint32_t w, - const uint32_t channels, std::string what) const; + std::string GetErrorOrEmpty(const uint32_t h, const uint32_t w, const uint32_t channels, std::string what) const; }; struct RectLimitByChannelsAndPrecision { @@ -130,8 +131,11 @@ struct RectLimitByChannelsAndPrecision { RectLimitByChannels limit_for_int16; RectLimitByChannels GetByPrecision(const OvGnaType precision) const; bool isValid(const uint32_t h, const uint32_t w, const OvGnaType precision, const uint32_t channels) const; - std::string GetErrorOrEmpty(const uint32_t h, const uint32_t w, - const OvGnaType precision, const uint32_t channels, std::string what) const; + std::string GetErrorOrEmpty(const uint32_t h, + const uint32_t w, + const OvGnaType precision, + const uint32_t channels, + std::string what) const; }; class AbstractValidator { @@ -144,29 +148,51 @@ protected: public: virtual ~AbstractValidator() = default; - virtual bool ValidateCnn2D(const std::string& name, const uint32_t inHeight, const uint32_t inWidth, - const uint32_t inChannels, const uint32_t kH, const uint32_t kW, const uint32_t kN, - const uint32_t strideH, const uint32_t strideW, const uint32_t dilationH, const uint32_t dilationW, - OvGnaType inPrecision, bool exception = true) const = 0; + virtual bool ValidateCnn2D(const std::string& name, + const uint32_t inHeight, + const uint32_t inWidth, + const uint32_t inChannels, + const uint32_t kH, + const uint32_t kW, + const uint32_t kN, + const uint32_t strideH, + const uint32_t strideW, + const uint32_t dilationH, + const uint32_t dilationW, + OvGnaType inPrecision, + bool exception = true) const = 0; virtual bool ValidatePooling2D(const std::string& name, - const uint32_t windowH, const uint32_t windowW, - const uint32_t strideH, const uint32_t strideW, - bool exception = true) const = 0; + const uint32_t windowH, + const uint32_t windowW, + const uint32_t strideH, + const uint32_t strideW, + bool exception = true) const = 0; virtual bool ValidateInputPadding(const std::string& name, - const uint32_t pad_h_begin, const uint32_t pad_h_end, - const uint32_t pad_w_begin, const uint32_t pad_w_end, - const uint32_t kernel_h, - const uint32_t kernel_w, - const bool throwOnError = true) const = 0; + const uint32_t pad_h_begin, + const uint32_t pad_h_end, + const uint32_t pad_w_begin, + const uint32_t pad_w_end, + const uint32_t kernel_h, + const uint32_t kernel_w, + const bool throwOnError = true) const = 0; virtual bool ShouldUseOnlyConv2DGnaIface() const = 0; - virtual bool ValidateCnn1D(const std::string& name, const uint32_t inHeight, const uint32_t inWidth, - const uint32_t inChannels, const uint32_t kH, const uint32_t kW, const uint32_t kN, - const uint32_t strideH, const uint32_t strideW, const uint32_t dilationH, const uint32_t dilationW, - OvGnaType inPrecision, bool exception = true) const = 0; + virtual bool ValidateCnn1D(const std::string& name, + const uint32_t inHeight, + const uint32_t inWidth, + const uint32_t inChannels, + const uint32_t kH, + const uint32_t kW, + const uint32_t kN, + const uint32_t strideH, + const uint32_t strideW, + const uint32_t dilationH, + const uint32_t dilationW, + OvGnaType inPrecision, + bool exception = true) const = 0; static std::unique_ptr Create(const std::string&); }; @@ -184,29 +210,51 @@ class Validator_30 : public AbstractValidator { public: Validator_30() = default; - bool ValidateCnn2D(const std::string& name, const uint32_t inHeight, const uint32_t inWidth, - const uint32_t inChannels, const uint32_t kH, const uint32_t kW, const uint32_t kN, - const uint32_t strideH, const uint32_t strideW, const uint32_t dilationH, const uint32_t dilationW, - OvGnaType inPrecision, bool exception = true) const override; + bool ValidateCnn2D(const std::string& name, + const uint32_t inHeight, + const uint32_t inWidth, + const uint32_t inChannels, + const uint32_t kH, + const uint32_t kW, + const uint32_t kN, + const uint32_t strideH, + const uint32_t strideW, + const uint32_t dilationH, + const uint32_t dilationW, + OvGnaType inPrecision, + bool exception = true) const override; bool ValidatePooling2D(const std::string& name, - const uint32_t windowH, const uint32_t windowW, - const uint32_t strideH, const uint32_t strideW, - bool exception = true) const override; + const uint32_t windowH, + const uint32_t windowW, + const uint32_t strideH, + const uint32_t strideW, + bool exception = true) const override; bool ValidateInputPadding(const std::string& name, - const uint32_t pad_h_begin, const uint32_t pad_h_end, - const uint32_t pad_w_begin, const uint32_t pad_w_end, - const uint32_t kernel_h, - const uint32_t kernel_w, - const bool throwOnError = true) const override; + const uint32_t pad_h_begin, + const uint32_t pad_h_end, + const uint32_t pad_w_begin, + const uint32_t pad_w_end, + const uint32_t kernel_h, + const uint32_t kernel_w, + const bool throwOnError = true) const override; bool ShouldUseOnlyConv2DGnaIface() const override; - bool ValidateCnn1D(const std::string& name, const uint32_t inHeight, const uint32_t inWidth, - const uint32_t inChannels, const uint32_t kH, const uint32_t kW, const uint32_t kN, - const uint32_t strideH, const uint32_t strideW, const uint32_t dilationH, const uint32_t dilationW, - OvGnaType inPrecision, bool exception = true) const override; + bool ValidateCnn1D(const std::string& name, + const uint32_t inHeight, + const uint32_t inWidth, + const uint32_t inChannels, + const uint32_t kH, + const uint32_t kW, + const uint32_t kN, + const uint32_t strideH, + const uint32_t strideW, + const uint32_t dilationH, + const uint32_t dilationW, + OvGnaType inPrecision, + bool exception = true) const override; }; class Validator_35 : public AbstractValidator { @@ -228,7 +276,30 @@ class Validator_35 : public AbstractValidator { static const CnnLimits kCnn1DLimits; std::string ValidateCnn(const CnnLimits& limits, - const std::string& name, + const std::string& name, + const uint32_t inHeight, + const uint32_t inWidth, + const uint32_t inChannels, + const uint32_t kH, + const uint32_t kW, + const uint32_t kN, + const uint32_t strideH, + const uint32_t strideW, + const uint32_t dilationH, + const uint32_t dilationW, + OvGnaType inPrecision) const; + + std::string ValidatePooling(const CnnLimits& limits, + const std::string& name, + const uint32_t windowH, + const uint32_t windowW, + const uint32_t strideH, + const uint32_t strideW) const; + +public: + Validator_35() = default; + + bool ValidateCnn2D(const std::string& name, const uint32_t inHeight, const uint32_t inWidth, const uint32_t inChannels, @@ -239,43 +310,43 @@ class Validator_35 : public AbstractValidator { const uint32_t strideW, const uint32_t dilationH, const uint32_t dilationW, - OvGnaType inPrecision) const; + OvGnaType inPrecision, + bool exception = true) const override; - std::string ValidatePooling(const CnnLimits& limits, - const std::string& name, + bool ValidatePooling2D(const std::string& name, const uint32_t windowH, const uint32_t windowW, const uint32_t strideH, - const uint32_t strideW) const; - -public: - Validator_35() = default; - - bool ValidateCnn2D(const std::string& name, const uint32_t inHeight, const uint32_t inWidth, - const uint32_t inChannels, const uint32_t kH, const uint32_t kW, const uint32_t kN, - const uint32_t strideH, const uint32_t strideW, const uint32_t dilationH, const uint32_t dilationW, - OvGnaType inPrecision, bool exception = true) const override; - - bool ValidatePooling2D(const std::string& name, - const uint32_t windowH, const uint32_t windowW, - const uint32_t strideH, const uint32_t strideW, - bool exception = true) const override; + const uint32_t strideW, + bool exception = true) const override; bool ValidateInputPadding(const std::string& name, - const uint32_t pad_h_begin, const uint32_t pad_h_end, - const uint32_t pad_w_begin, const uint32_t pad_w_end, - const uint32_t kernel_h, - const uint32_t kernel_w, - const bool throwOnError = true) const override; + const uint32_t pad_h_begin, + const uint32_t pad_h_end, + const uint32_t pad_w_begin, + const uint32_t pad_w_end, + const uint32_t kernel_h, + const uint32_t kernel_w, + const bool throwOnError = true) const override; bool ShouldUseOnlyConv2DGnaIface() const override; - bool ValidateCnn1D(const std::string& name, const uint32_t inHeight, const uint32_t inWidth, - const uint32_t inChannels, const uint32_t kH, const uint32_t kW, const uint32_t kN, - const uint32_t strideH, const uint32_t strideW, const uint32_t dilationH, const uint32_t dilationW, - OvGnaType inPrecision, bool exception = true) const override; + bool ValidateCnn1D(const std::string& name, + const uint32_t inHeight, + const uint32_t inWidth, + const uint32_t inChannels, + const uint32_t kH, + const uint32_t kW, + const uint32_t kN, + const uint32_t strideH, + const uint32_t strideW, + const uint32_t dilationH, + const uint32_t dilationW, + OvGnaType inPrecision, + bool exception = true) const override; }; -} // namespace Cnn2D + +} // namespace cnn2d bool AreLayersSupported(InferenceEngine::CNNNetwork& network, std::string& errMessage); @@ -293,5 +364,6 @@ IE_SUPPRESS_DEPRECATED_START bool ValidateConvConcatAxis(const InferenceEngine::ConcatLayer* concatLayer); IE_SUPPRESS_DEPRECATED_END -} // namespace GNALimitations -} // namespace GNAPluginNS +} // namespace limitations +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/backend/gna_types.h b/src/plugins/intel_gna/src/backend/gna_types.hpp similarity index 100% rename from src/plugins/intel_gna/src/backend/gna_types.h rename to src/plugins/intel_gna/src/backend/gna_types.hpp diff --git a/src/plugins/intel_gna/src/backend/make_pwl.cpp b/src/plugins/intel_gna/src/backend/make_pwl.cpp index 556be6f413a..d3959982604 100644 --- a/src/plugins/intel_gna/src/backend/make_pwl.cpp +++ b/src/plugins/intel_gna/src/backend/make_pwl.cpp @@ -10,9 +10,9 @@ #include "runtime/pwl.h" #include "make_pwl.hpp" -#include "gna_slope_scale.h" -#include "dnn_types.h" -#include "backend/gna_types.h" +#include "gna_slope_scale.hpp" +#include "dnn_types.hpp" +#include "backend/gna_types.hpp" #include "common/numerical_utils.hpp" #include "pwl_input_params.hpp" #include "pwl_segments_creator_factory.hpp" diff --git a/src/plugins/intel_gna/src/backend/pwl_input_params.hpp b/src/plugins/intel_gna/src/backend/pwl_input_params.hpp index cbdd8b23547..cc68d5b120e 100644 --- a/src/plugins/intel_gna/src/backend/pwl_input_params.hpp +++ b/src/plugins/intel_gna/src/backend/pwl_input_params.hpp @@ -4,7 +4,7 @@ #pragma once -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" namespace ov { namespace intel_gna { diff --git a/src/plugins/intel_gna/src/backend/pwl_segments_creator.hpp b/src/plugins/intel_gna/src/backend/pwl_segments_creator.hpp index f80836d2620..d4b29a7c703 100644 --- a/src/plugins/intel_gna/src/backend/pwl_segments_creator.hpp +++ b/src/plugins/intel_gna/src/backend/pwl_segments_creator.hpp @@ -7,7 +7,7 @@ #include #include -#include "backend/gna_types.h" +#include "backend/gna_types.hpp" #include "pwl_border_values_counter.hpp" namespace ov { diff --git a/src/plugins/intel_gna/src/backend/pwl_segments_creator_factory.cpp b/src/plugins/intel_gna/src/backend/pwl_segments_creator_factory.cpp index d319f17c53c..720c959e197 100644 --- a/src/plugins/intel_gna/src/backend/pwl_segments_creator_factory.cpp +++ b/src/plugins/intel_gna/src/backend/pwl_segments_creator_factory.cpp @@ -7,7 +7,7 @@ #include #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include "pwl_border_values_counter_identity.hpp" #include "pwl_segments_creator_identity.hpp" diff --git a/src/plugins/intel_gna/src/backend/pwl_segments_creator_identity.cpp b/src/plugins/intel_gna/src/backend/pwl_segments_creator_identity.cpp index 9861162275e..99893e7627c 100644 --- a/src/plugins/intel_gna/src/backend/pwl_segments_creator_identity.cpp +++ b/src/plugins/intel_gna/src/backend/pwl_segments_creator_identity.cpp @@ -6,7 +6,7 @@ #include "log/debug.hpp" #include "log/log.hpp" -#include "gna_slope_scale.h" +#include "gna_slope_scale.hpp" #include "pwl_input_params.hpp" #include "pwl_tools.hpp" #include "runtime/pwl.h" diff --git a/src/plugins/intel_gna/src/backend/pwl_tools.cpp b/src/plugins/intel_gna/src/backend/pwl_tools.cpp index 50094411ffb..bd9ee9c9afa 100644 --- a/src/plugins/intel_gna/src/backend/pwl_tools.cpp +++ b/src/plugins/intel_gna/src/backend/pwl_tools.cpp @@ -4,7 +4,7 @@ #include "pwl_tools.hpp" -#include "gna_slope_scale.h" +#include "gna_slope_scale.hpp" #include "common/numerical_utils.hpp" #include "runtime/pwl.h" diff --git a/src/plugins/intel_gna/src/backend/pwl_tools.hpp b/src/plugins/intel_gna/src/backend/pwl_tools.hpp index 10a8f5cd146..03f6d4b3403 100644 --- a/src/plugins/intel_gna/src/backend/pwl_tools.hpp +++ b/src/plugins/intel_gna/src/backend/pwl_tools.hpp @@ -4,7 +4,7 @@ #pragma once -#include "backend/gna_types.h" +#include "backend/gna_types.hpp" namespace ov { namespace intel_gna { diff --git a/src/plugins/intel_gna/src/common/gna_target.hpp b/src/plugins/intel_gna/src/common/gna_target.hpp index 467d629d0b5..038f57c8c60 100644 --- a/src/plugins/intel_gna/src/common/gna_target.hpp +++ b/src/plugins/intel_gna/src/common/gna_target.hpp @@ -4,13 +4,17 @@ #pragma once -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace common { + static constexpr const char* kGnaTargetUnspecified = ""; static constexpr const char* kGnaTarget2_0 = "GNA_TARGET_2_0"; static constexpr const char* kGnaTarget3_0 = "GNA_TARGET_3_0"; static constexpr const char* kGnaTarget3_1 = "GNA_TARGET_3_1"; static constexpr const char* kGnaTarget3_5 = "GNA_TARGET_3_5"; static constexpr const char* kGnaDefaultTarget = kGnaTarget3_0; -} // namespace common -} // namespace GNAPluginNS + +} // namespace common +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/connection_details.hpp b/src/plugins/intel_gna/src/connection_details.hpp index 93d9f3affd4..a79acf778b3 100644 --- a/src/plugins/intel_gna/src/connection_details.hpp +++ b/src/plugins/intel_gna/src/connection_details.hpp @@ -6,7 +6,9 @@ #include -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + struct ConnectionDetails { InferenceEngine::CNNLayerPtr input; bool needTransposeWeights = false; @@ -19,4 +21,6 @@ struct ConnectionDetails { , permute(permute) { } }; -} // namespace GNAPluginNS + +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/descriptions/gna_desc.hpp b/src/plugins/intel_gna/src/descriptions/gna_desc.hpp index ada53cd989c..0872a8d86d1 100644 --- a/src/plugins/intel_gna/src/descriptions/gna_desc.hpp +++ b/src/plugins/intel_gna/src/descriptions/gna_desc.hpp @@ -13,10 +13,11 @@ #include "ie_input_info.hpp" #include "ie_algorithm.hpp" -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include "gna_plugin_config.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { /* * This base structure accumulates all required information for network inputs and outputs @@ -27,15 +28,15 @@ struct GnaDesc { std::unordered_set tensor_names = {}; InferenceEngine::Layout model_layout = InferenceEngine::Layout::ANY; InferenceEngine::SizeVector dims = {}; - InferenceEngine::Precision model_precision = InferenceEngine::Precision::UNSPECIFIED; + InferenceEngine::Precision model_precision = InferenceEngine::Precision::UNSPECIFIED; InferenceEngine::Precision tensor_precision = InferenceEngine::Precision::UNSPECIFIED; // gna specific properties - double scale_factor = GNAPluginNS::kScaleFactorDefault; + double scale_factor = kScaleFactorDefault; intel_dnn_orientation_t orientation = kDnnUnknownOrientation; uint32_t num_elements = 0; uint32_t allocated_size = 0; - std::vector ptrs = {}; // ptr per each infer request + std::vector ptrs = {}; // ptr per each infer request // help methods uint32_t get_required_size() const { @@ -53,25 +54,27 @@ struct GnaDesc { // helps to get the precision for gna layers, because they use num_bytes instead of precision values void set_precision(uint32_t num_bytes) { switch (num_bytes) { - case sizeof(int8_t) : { - set_precision(InferenceEngine::Precision::I8); - break; - } - case sizeof(int16_t) : { - set_precision(InferenceEngine::Precision::I16); - break; - } - case sizeof(int32_t) : { - set_precision(InferenceEngine::Precision::I32); - break; - } - default : - set_precision(InferenceEngine::Precision::UNSPECIFIED); + case sizeof(int8_t): { + set_precision(InferenceEngine::Precision::I8); + break; + } + case sizeof(int16_t): { + set_precision(InferenceEngine::Precision::I16); + break; + } + case sizeof(int32_t): { + set_precision(InferenceEngine::Precision::I32); + break; + } + default: + set_precision(InferenceEngine::Precision::UNSPECIFIED); } } InferenceEngine::DataPtr to_ie_data() { - return std::make_shared(name, InferenceEngine::TensorDesc(model_precision, dims, model_layout)); + return std::make_shared( + name, + InferenceEngine::TensorDesc(model_precision, dims, model_layout)); } }; @@ -79,7 +82,9 @@ struct GnaDesc { * This structure accumulates all required information for one the network input */ struct InputDesc : GnaDesc { - InputDesc(const std::string &name) { this->name = name; } + InputDesc(const std::string& name) { + this->name = name; + } void Update(const InferenceEngine::InputInfo::Ptr inputInfo) { this->model_precision = inputInfo->getPrecision(); @@ -101,7 +106,9 @@ struct InputDesc : GnaDesc { * This structure accumulates all required information for one network output */ struct OutputDesc : GnaDesc { - OutputDesc(const std::string &name) { this->name = name; } + OutputDesc(const std::string& name) { + this->name = name; + } void Update(const InferenceEngine::DataPtr outputData) { this->model_precision = outputData->getPrecision(); @@ -123,9 +130,9 @@ private: std::vector infos_; public: - GnaNetworkInfo(): infos_({}) { } + GnaNetworkInfo() : infos_({}) {} - const T& at(const std::string &key) const { + const T& at(const std::string& key) const { if (key.empty()) { throw std::invalid_argument("The key cannot be empty"); } @@ -136,8 +143,8 @@ public: return *desc_it; } - T& at(const std::string &key) { - return const_cast( static_cast(*this).at(key) ); + T& at(const std::string& key) { + return const_cast(static_cast(*this).at(key)); } typename std::vector::iterator end() { @@ -156,11 +163,13 @@ public: }); } - T& operator[](const std::string &key) { + T& operator[](const std::string& key) { if (key.empty()) { throw std::invalid_argument("The key cannot be empty"); } - auto desc_it = std::find_if(infos_.begin(), infos_.end(), [&key](const T& desc){return desc.name == key;}); + auto desc_it = std::find_if(infos_.begin(), infos_.end(), [&key](const T& desc) { + return desc.name == key; + }); if (desc_it == infos_.end()) { infos_.push_back(T(key)); return infos_.back(); @@ -168,16 +177,25 @@ public: return *desc_it; } - size_t size() const { return infos_.size(); } + size_t size() const { + return infos_.size(); + } - bool empty() const { return infos_.empty(); } + bool empty() const { + return infos_.empty(); + } - const std::vector& Get() const { return infos_; } + const std::vector& Get() const { + return infos_; + } - std::vector& Get() { return infos_; } + std::vector& Get() { + return infos_; + } }; typedef GnaNetworkInfo GnaInputs; typedef GnaNetworkInfo GnaOutputs; -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/descriptions/gna_flags.hpp b/src/plugins/intel_gna/src/descriptions/gna_flags.hpp index ebfae867567..38c8e345716 100644 --- a/src/plugins/intel_gna/src/descriptions/gna_flags.hpp +++ b/src/plugins/intel_gna/src/descriptions/gna_flags.hpp @@ -8,7 +8,9 @@ #include "openvino/runtime/intel_gna/properties.hpp" #include "gna/gna_config.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + struct GNAFlags { uint8_t num_requests = 1; bool compact_mode = true; @@ -22,4 +24,6 @@ struct GNAFlags { bool input_low_precision = false; ov::log::Level log_level = ov::log::Level::NO; }; -} // namespace GNAPluginNS + +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/frontend/layer_quantizer.cpp b/src/plugins/intel_gna/src/frontend/layer_quantizer.cpp index e08e5d37d1b..055dbb6dd2a 100644 --- a/src/plugins/intel_gna/src/frontend/layer_quantizer.cpp +++ b/src/plugins/intel_gna/src/frontend/layer_quantizer.cpp @@ -4,12 +4,10 @@ #include "layer_quantizer.hpp" #include "weights_converter.hpp" -#include "backend/gna_types.h" +#include "backend/gna_types.hpp" #include "common/gna_target.hpp" #include "gna_graph_tools.hpp" -using namespace GNAPluginNS; - namespace ov { namespace intel_gna { namespace frontend { @@ -252,7 +250,7 @@ void LayerQuantizer::QuantizeWeightsBiases(InferenceEngine::WeightableLayer& wl) QuantizationData common_data{ num_rows, num_columns, - GNAPluginNS::kScaleFactorDefault, + kScaleFactorDefault, quant_layer_params->_weights_quant }; diff --git a/src/plugins/intel_gna/src/frontend/layer_quantizer.hpp b/src/plugins/intel_gna/src/frontend/layer_quantizer.hpp index 514f7019d6d..e1244e6569c 100644 --- a/src/plugins/intel_gna/src/frontend/layer_quantizer.hpp +++ b/src/plugins/intel_gna/src/frontend/layer_quantizer.hpp @@ -13,8 +13,6 @@ namespace ov { namespace intel_gna { namespace frontend { -using namespace GNAPluginNS; - /** * @brief Returns layer's target input precision * @return layer's target input precision diff --git a/src/plugins/intel_gna/src/frontend/quantization.cpp b/src/plugins/intel_gna/src/frontend/quantization.cpp index 8f9d84ee5d6..419a0b08935 100644 --- a/src/plugins/intel_gna/src/frontend/quantization.cpp +++ b/src/plugins/intel_gna/src/frontend/quantization.cpp @@ -9,7 +9,7 @@ #include "log/debug.hpp" #include "log/log.hpp" #include "layers/gna_fake_quantize_layer.hpp" -#include "backend/gna_types.h" +#include "backend/gna_types.hpp" #include "quantization.hpp" namespace ov { diff --git a/src/plugins/intel_gna/src/frontend/quantization.hpp b/src/plugins/intel_gna/src/frontend/quantization.hpp index 626120b15c7..38c3e41533e 100644 --- a/src/plugins/intel_gna/src/frontend/quantization.hpp +++ b/src/plugins/intel_gna/src/frontend/quantization.hpp @@ -10,7 +10,7 @@ #include #include #include "quantized_layer_params.hpp" -#include "backend/gna_types.h" +#include "backend/gna_types.hpp" namespace ov { namespace intel_gna { diff --git a/src/plugins/intel_gna/src/frontend/scale_factor_calc.cpp b/src/plugins/intel_gna/src/frontend/scale_factor_calc.cpp index 9633cb70c1f..363a9ca9a2e 100644 --- a/src/plugins/intel_gna/src/frontend/scale_factor_calc.cpp +++ b/src/plugins/intel_gna/src/frontend/scale_factor_calc.cpp @@ -3,7 +3,7 @@ // #include "scale_factor_calc.hpp" -#include "gna_slope_scale.h" +#include "gna_slope_scale.hpp" #include "common/numerical_utils.hpp" #include "layer_quantizer.hpp" #include "gna_upstream_iterator.hpp" @@ -323,7 +323,7 @@ bool ScaleFactorCalculator::requantizeInput(InferenceEngine::CNNLayerPtr input, */ float ScaleFactorCalculator::adjustScaleFactor(float sf, InferenceEngine::CNNLayer const* cnnLayer, - GNAPluginNS::LayerInfo const& layer, + LayerInfo const& layer, QuantizedLayerParams* quantizedParams) const { auto get_rank = [](uint32_t value) { uint8_t rank = 0; @@ -365,7 +365,7 @@ float ScaleFactorCalculator::adjustScaleFactor(float sf, } float ScaleFactorCalculator::getActivationScale(InferenceEngine::CNNLayer const* cnnLayer, - GNAPluginNS::LayerInfo const& layer, + LayerInfo const& layer, int inputsSize, const bool fake_quantized) const { auto quantizedParams = InferenceEngine::getInjectedData(*cnnLayer); @@ -420,9 +420,9 @@ float ScaleFactorCalculator::getActivationScale(InferenceEngine::CNNLayer const* double offset = 0; auto powerLayer = dynamic_cast(cnnLayer); if (!powerLayer) { - std::shared_ptr pwl_node; + std::shared_ptr pwl_node; if (!cnnLayer->getNode() || - !(pwl_node = std::dynamic_pointer_cast(cnnLayer->getNode()))) { + !(pwl_node = std::dynamic_pointer_cast(cnnLayer->getNode()))) { IE_THROW() << "Incorrect Power Layer pointer \n"; } else { auto powerIE = std::dynamic_pointer_cast(pwl_node->get_base_node()); @@ -587,7 +587,7 @@ float ScaleFactorCalculator::getActivationScale(InferenceEngine::CNNLayer const* bool ScaleFactorCalculator::ScaleFactorPerLayerCNN(InferenceEngine::CNNLayer* cnnLayer, ScaleFactorUpdateResult& result, int infiniteLoopCount, - const GNAPluginNS::Config& gna_config) const { + const Config& gna_config) const { if ( !cnnLayer ) { IE_THROW() << "Incorrect Layer pointer \n"; } @@ -1234,7 +1234,7 @@ bool ScaleFactorCalculator::ScaleFactorPerLayerWeightable(InferenceEngine::Weigh auto conv = dynamic_cast(wl); if (conv && !LayerInfo(conv).isConvolutionFilter()) { const auto inDepth = GetDataDimByName(conv->insData.front().lock(), InferenceEngine::DataDimName::C); - weights_reducer = GNAConvolutionLayer::getWeightsReducer(*conv); + weights_reducer = gna_convolution_layer::getWeightsReducer(*conv); weights_reducer *= MAX_VAL_2B_FEAT * scaleRange * inDepth / std::numeric_limits::max(); weights_reducer = std::max(1.0, weights_reducer); } diff --git a/src/plugins/intel_gna/src/frontend/scale_factor_calc.hpp b/src/plugins/intel_gna/src/frontend/scale_factor_calc.hpp index 1e162883a7e..ea957e1ff2c 100644 --- a/src/plugins/intel_gna/src/frontend/scale_factor_calc.hpp +++ b/src/plugins/intel_gna/src/frontend/scale_factor_calc.hpp @@ -49,13 +49,13 @@ struct ScaleFactorUpdateResult { class ScaleFactorCalculator { using Cnt = std::vector; Cnt net; - const GNAPluginNS::Config& gna_config; + const Config& gna_config; const bool fake_quantized; mutable Cnt::const_iterator idx; mutable bool needRestart = false; int infiniteLoopCount = 0; - std::vector getPWLSlopes(const GNAPluginNS::LayerInfo& info) const; + std::vector getPWLSlopes(const LayerInfo& info) const; static float selectBestOutputScaleFactors(float inScale, std::vector outScales, const std::vector& slopes); @@ -71,35 +71,35 @@ class ScaleFactorCalculator { int infiniteLoopCount); float adjustScaleFactor(float sf, InferenceEngine::CNNLayer const* cnnLayer, - GNAPluginNS::LayerInfo const& layer, + LayerInfo const& layer, QuantizedLayerParams* quantizedParams) const; float getActivationScale(InferenceEngine::CNNLayer const* cnnLayer, - GNAPluginNS::LayerInfo const& layer, + LayerInfo const& layer, int inputsSize, const bool fakeQuantize) const; bool ScaleFactorPerLayerCNN(InferenceEngine::CNNLayer* cnnLayer, ScaleFactorUpdateResult& result, int infiniteLoopCount, - const GNAPluginNS::Config& gna_config) const; + const Config& gna_config) const; bool ScaleFactorPerLayerConcat(InferenceEngine::ConcatLayer* concatLayer, ScaleFactorUpdateResult& result, int infiniteLoopCount, - const GNAPluginNS::Config& gna_config) const; + const Config& gna_config) const; bool ScaleFactorPerLayerEltwise(InferenceEngine::EltwiseLayer* eltwiseLayer, ScaleFactorUpdateResult& result, int infiniteLoopCount, - const GNAPluginNS::Config& gna_config) const; + const Config& gna_config) const; bool ScaleFactorPerLayerGemm(InferenceEngine::GemmLayer* gemmLayer, ScaleFactorUpdateResult& result, int infiniteLoopCount, - const GNAPluginNS::Config& gna_config) const; + const Config& gna_config) const; bool ScaleFactorPerLayerWeightable(InferenceEngine::WeightableLayer* wl, ScaleFactorUpdateResult& result, int infiniteLoopCount, - const GNAPluginNS::Config& gna_config) const; + const Config& gna_config) const; public: - ScaleFactorCalculator(Cnt& net, const GNAPluginNS::Config& gna_config, const bool fake_quantized) + ScaleFactorCalculator(Cnt& net, const Config& gna_config, const bool fake_quantized) : net(net), gna_config(gna_config), fake_quantized(fake_quantized) { @@ -120,7 +120,7 @@ class ScaleFactorCalculator { bool CalculateScaleFactor(InferenceEngine::CNNLayerPtr layer_ptr) const { ScaleFactorUpdateResult result; needRestart = false; - auto layer_info = GNAPluginNS::LayerInfo(layer_ptr); + auto layer_info = LayerInfo(layer_ptr); if (layer_info.isConcat()) { if (!ScaleFactorPerLayerConcat(dynamic_cast(layer_ptr.get()), diff --git a/src/plugins/intel_gna/src/frontend/weights_converter.cpp b/src/plugins/intel_gna/src/frontend/weights_converter.cpp index 23ed99a3bef..3f9655ff3c8 100644 --- a/src/plugins/intel_gna/src/frontend/weights_converter.cpp +++ b/src/plugins/intel_gna/src/frontend/weights_converter.cpp @@ -42,7 +42,7 @@ InferenceEngine::Blob::Ptr make_fp32_blob(InferenceEngine::Blob::Ptr fp16_blob) } void convert_blobs_precision(InferenceEngine::CNNLayer& layer) { - auto layer_info = GNAPluginNS::LayerInfo(layer); + auto layer_info = LayerInfo(layer); if (layer_info.isWeightable()) { InferenceEngine::WeightableLayer& wl = dynamic_cast(layer); diff --git a/src/plugins/intel_gna/src/gna2_model_export_helper.cpp b/src/plugins/intel_gna/src/gna2_model_export_helper.cpp index 2d8b07d83dc..8a31b8464d7 100644 --- a/src/plugins/intel_gna/src/gna2_model_export_helper.cpp +++ b/src/plugins/intel_gna/src/gna2_model_export_helper.cpp @@ -91,8 +91,8 @@ std::vector GetStringAsTlv(Gna2TlvType type, const std::string& s) { Gna2DeviceVersion getEmbeddedTargetFromCompileTarget(const std::string compileTarget) { static const std::map targetMap = { - {GNAPluginNS::common::kGnaTarget3_1, Gna2DeviceVersionEmbedded3_1}, - {GNAPluginNS::common::kGnaTarget3_5, Gna2DeviceVersionEmbedded3_5}, + {common::kGnaTarget3_1, Gna2DeviceVersionEmbedded3_1}, + {common::kGnaTarget3_5, Gna2DeviceVersionEmbedded3_5}, }; auto found = targetMap.find(compileTarget); if (found == targetMap.end()) { diff --git a/src/plugins/intel_gna/src/gna2_model_helper.hpp b/src/plugins/intel_gna/src/gna2_model_helper.hpp index 31b4ed21a63..051fed9d619 100644 --- a/src/plugins/intel_gna/src/gna2_model_helper.hpp +++ b/src/plugins/intel_gna/src/gna2_model_helper.hpp @@ -6,7 +6,7 @@ #include #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include diff --git a/src/plugins/intel_gna/src/gna_data_types.hpp b/src/plugins/intel_gna/src/gna_data_types.hpp index c40648ac60a..86296993eff 100644 --- a/src/plugins/intel_gna/src/gna_data_types.hpp +++ b/src/plugins/intel_gna/src/gna_data_types.hpp @@ -29,10 +29,12 @@ static inline bool FoundPartToTranspose(const std::vector &tr return partToTranspose != std::end(transpositionInfo); } -namespace GNAPluginNS { - using gna_memory_type = GNAPluginNS::memory::GNAMemoryInterface; - using gna_memory_float = GNAPluginNS::memory::GNAMemory; - using gna_memory_device = GNAPluginNS::memory::GNAMemory<>; +namespace ov { +namespace intel_gna { + + using gna_memory_type = memory::GNAMemoryInterface; + using gna_memory_float = memory::GNAMemory; + using gna_memory_device = memory::GNAMemory<>; using DnnComponentsForLayer = std::list>; using MemoryConnection = std::list>; @@ -40,4 +42,6 @@ namespace GNAPluginNS { using SplitConnection = std::unordered_map; using CropConnection = std::unordered_map; using ConstConnections = std::unordered_map; -} // namespace GNAPluginNS + +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/gna_device.cpp b/src/plugins/intel_gna/src/gna_device.cpp index 06bec0c4b44..ae0e65f7617 100644 --- a/src/plugins/intel_gna/src/gna_device.cpp +++ b/src/plugins/intel_gna/src/gna_device.cpp @@ -80,9 +80,9 @@ uint8_t* GNADeviceHelper::alloc(uint32_t size_requested, uint32_t *size_granted) return static_cast(memPtr); } -void GNADeviceHelper::tagMemoryRegion(void* memPtr, const GNAPluginNS::memory::rRegion tag) { +void GNADeviceHelper::tagMemoryRegion(void* memPtr, const memory::rRegion tag) { std::unique_lock lockGnaCalls{ acrossPluginsSync }; - using GNAPluginNS::memory::rRegion; + using memory::rRegion; static const std::map tagMap { {rRegion::REGION_INPUTS, Gna2MemoryTagInput}, {rRegion::REGION_OUTPUTS, Gna2MemoryTagOutput}, @@ -192,7 +192,7 @@ void GNADeviceHelper::enforceLegacyCnns(Gna2Model& gnaModel) { void GNADeviceHelper::enforceLegacyCnnsWhenNeeded(Gna2Model& gnaModel) { for (uint32_t i = 0; i < gnaModel.NumberOfOperations; i++) { auto& op = gnaModel.Operations[i]; - if (GNAPluginNS::backend::AMIntelDNN::isOperationCnnLegacySpecific(op)) { + if (backend::AMIntelDNN::isOperationCnnLegacySpecific(op)) { enforceLegacyCnn(op); } } @@ -207,7 +207,7 @@ uint32_t GNADeviceHelper::createModel(Gna2Model& gnaModel) const { } enforceLegacyCnnsWhenNeeded(gnaModel); - GNAPluginNS::backend::AMIntelDNN::updateNumberOfOutputsIfPoolingEnabled(gnaModel, legacyExecTarget); + backend::AMIntelDNN::updateNumberOfOutputsIfPoolingEnabled(gnaModel, legacyExecTarget); if (per_model_diagnostics) { std::string path = @@ -240,10 +240,10 @@ bool GNADeviceHelper::enforceLegacyCnnNeeded() const { Gna2DeviceVersion GNADeviceHelper::parseTarget(const std::string& target) { static const std::map targetMap { - {GNAPluginNS::common::kGnaTarget2_0, Gna2DeviceVersion2_0}, - {GNAPluginNS::common::kGnaTarget3_0, Gna2DeviceVersion3_0}, - {GNAPluginNS::common::kGnaTarget3_5, Gna2DeviceVersion3_5}, - {GNAPluginNS::common::kGnaTargetUnspecified, Gna2DeviceVersionSoftwareEmulation}, + {common::kGnaTarget2_0, Gna2DeviceVersion2_0}, + {common::kGnaTarget3_0, Gna2DeviceVersion3_0}, + {common::kGnaTarget3_5, Gna2DeviceVersion3_5}, + {common::kGnaTargetUnspecified, Gna2DeviceVersionSoftwareEmulation}, }; const auto f = targetMap.find(target); if (f != targetMap.end()) { @@ -254,13 +254,13 @@ Gna2DeviceVersion GNADeviceHelper::parseTarget(const std::string& target) { Gna2DeviceVersion GNADeviceHelper::getDefaultTarget() const { if (detectedGnaDevVersion == Gna2DeviceVersionSoftwareEmulation) - return parseTarget(GNAPluginNS::common::kGnaDefaultTarget); + return parseTarget(common::kGnaDefaultTarget); return detectedGnaDevVersion; } Gna2DeviceVersion GNADeviceHelper::getTargetDevice(const bool execTarget) const { const auto declared = execTarget ? executionTarget : compileTarget; - if (declared == GNAPluginNS::common::kGnaTargetUnspecified) { + if (declared == common::kGnaTargetUnspecified) { return execTarget ? getDefaultTarget() : getTargetDevice(true); } return parseTarget(declared); @@ -465,15 +465,15 @@ const std::map , const std::string> {{Gna2OperationTypeThreshold, 1}, "Output"} }; -GNAPluginNS::RequestStatus GNADeviceHelper::waitForRequest(uint32_t requestID, int64_t timeoutMilliseconds) { +RequestStatus GNADeviceHelper::waitForRequest(uint32_t requestID, int64_t timeoutMilliseconds) { std::unique_lock lockGnaCalls{ acrossPluginsSync }; const auto status = Gna2RequestWait(requestID, static_cast(timeoutMilliseconds)); if (status == Gna2StatusWarningDeviceBusy) { - return GNAPluginNS::RequestStatus::kPending; + return RequestStatus::kPending; } unwaitedRequestIds.erase(requestID); if (status == Gna2StatusDriverQoSTimeoutExceeded) { - return GNAPluginNS::RequestStatus::kAborted; + return RequestStatus::kAborted; } if (per_request_diagnostics) { @@ -485,7 +485,7 @@ GNAPluginNS::RequestStatus GNADeviceHelper::waitForRequest(uint32_t requestID, i // handle error case after updating statistics data. checkGna2Status(status, "Gna2RequestWait"); - return GNAPluginNS::RequestStatus::kCompleted; + return RequestStatus::kCompleted; } GNADeviceHelper::DumpResult GNADeviceHelper::dumpXnn(const uint32_t modelId) { @@ -559,7 +559,7 @@ void GNADeviceHelper::close() { for (auto requestId : requestsToClose) try { - if (waitForRequest(requestId) == GNAPluginNS::RequestStatus::kPending) + if (waitForRequest(requestId) == RequestStatus::kPending) log::warning() << "Request with Id " << requestId << " is still pending"; } catch (...) { log::warning() << "Request with Id " << requestId << " was not awaited successfully"; @@ -598,10 +598,10 @@ void GNADeviceHelper::getGnaPerfCounters(std::map targetMap = { - {Gna2DeviceVersion2_0, GNAPluginNS::common::kGnaTarget2_0}, - {Gna2DeviceVersion3_0, GNAPluginNS::common::kGnaTarget3_0}, - {Gna2DeviceVersion3_5, GNAPluginNS::common::kGnaTarget3_5}, - {Gna2DeviceVersionEmbedded3_5, GNAPluginNS::common::kGnaTarget3_5}, + {Gna2DeviceVersion2_0, common::kGnaTarget2_0}, + {Gna2DeviceVersion3_0, common::kGnaTarget3_0}, + {Gna2DeviceVersion3_5, common::kGnaTarget3_5}, + {Gna2DeviceVersionEmbedded3_5, common::kGnaTarget3_5}, }; const auto target = getTargetDevice(false); auto found = targetMap.find(target); @@ -616,7 +616,7 @@ uint32_t GNADeviceHelper::maxLayersCount() const { } uint32_t GNADeviceHelper::retrieveMaxLayersCount() { - using namespace GNAPluginNS::GNALimitations; + using namespace limitations; switch (getTargetDevice(true)) { case Gna2DeviceVersion1_0: diff --git a/src/plugins/intel_gna/src/gna_device.hpp b/src/plugins/intel_gna/src/gna_device.hpp index b3af40f821f..ad77989465a 100644 --- a/src/plugins/intel_gna/src/gna_device.hpp +++ b/src/plugins/intel_gna/src/gna_device.hpp @@ -34,7 +34,7 @@ /** * holds gna - style handle in RAII way */ -class GNADeviceHelper : public GNAPluginNS::GNADevice { +class GNADeviceHelper : public ov::intel_gna::GNADevice { using UnwaitedRequestIds = std::set; static std::mutex acrossPluginsSync; static std::string decoratedGnaLibVersion() { @@ -92,7 +92,7 @@ public: void dumpAllAllocations(uint64_t idx, const std::string& infix) const; uint8_t *alloc(uint32_t size_requested, uint32_t *size_granted); - void tagMemoryRegion(void* memPtr, const GNAPluginNS::memory::rRegion memoryTag); + void tagMemoryRegion(void* memPtr, const ov::intel_gna::memory::rRegion memoryTag); void releaseModel(const uint32_t model_id); static uint32_t getNumberOfGnaDevices(); @@ -155,7 +155,7 @@ public: /** * @see GNADevice::waitForRequest() */ - GNAPluginNS::RequestStatus waitForRequest(uint32_t requestID, int64_t timeoutMilliseconds = MAX_TIMEOUT) override; + ov::intel_gna::RequestStatus waitForRequest(uint32_t requestID, int64_t timeoutMilliseconds = MAX_TIMEOUT) override; /** * @see GNADevice::maxLayersCount() diff --git a/src/plugins/intel_gna/src/gna_device_allocation.hpp b/src/plugins/intel_gna/src/gna_device_allocation.hpp index 986d742e4ef..772cec5034d 100644 --- a/src/plugins/intel_gna/src/gna_device_allocation.hpp +++ b/src/plugins/intel_gna/src/gna_device_allocation.hpp @@ -20,7 +20,7 @@ #include "memory/gna_mem_regions.hpp" #include "gna_lib_ver_selector.hpp" -using GNAPluginNS::memory::rRegion; +using ov::intel_gna::memory::rRegion; struct GnaAllocation { void* ptr = nullptr; diff --git a/src/plugins/intel_gna/src/gna_device_interface.hpp b/src/plugins/intel_gna/src/gna_device_interface.hpp index e8620d9cb5f..a6dc4dad513 100644 --- a/src/plugins/intel_gna/src/gna_device_interface.hpp +++ b/src/plugins/intel_gna/src/gna_device_interface.hpp @@ -13,10 +13,12 @@ enum Gna2AccelerationMode; class Gna2Model; -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + // Interface name is different to the file naem due the lagacy reason. // 1. Implementation file names should be changed in next PR. -// 2. Implementation of interface should be moved to GNAPluginNS namespace +// 2. Implementation of interface should be moved to ov::intel_gna namespace /** * @interface Interface for invoking operation on GNA device. @@ -57,10 +59,10 @@ public: * @brief Wait for request to be finished. * @param requestID id of request enqueued on device * @param timeoutMilliseconds maximum timeout to be used for waiting - * @return status of request given to the methoid. @see GNAPluginNS::RequestStatus. + * @return status of request given to the methoid. @see RequestStatus. * @throw Exception in case of error */ - virtual GNAPluginNS::RequestStatus waitForRequest(uint32_t requestID, int64_t timeoutMilliseconds) = 0; + virtual RequestStatus waitForRequest(uint32_t requestID, int64_t timeoutMilliseconds) = 0; /** * @brief Return maximum number of layers supported by device. @@ -74,4 +76,5 @@ public: virtual void close() {} }; -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/gna_executable_network.hpp b/src/plugins/intel_gna/src/gna_executable_network.hpp index f1fb8503a0d..57cbece5c5b 100644 --- a/src/plugins/intel_gna/src/gna_executable_network.hpp +++ b/src/plugins/intel_gna/src/gna_executable_network.hpp @@ -15,7 +15,8 @@ #include #include -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { class GNAExecutableNetwork : public InferenceEngine::IExecutableNetworkInternal { std::shared_ptr plg; @@ -135,4 +136,5 @@ class GNAExecutableNetwork : public InferenceEngine::IExecutableNetworkInternal } }; -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/gna_fused_iterator.hpp b/src/plugins/intel_gna/src/gna_fused_iterator.hpp index 3764eca818b..cc6e172aec4 100644 --- a/src/plugins/intel_gna/src/gna_fused_iterator.hpp +++ b/src/plugins/intel_gna/src/gna_fused_iterator.hpp @@ -10,7 +10,9 @@ #include "gna_graph_tools.hpp" #include "layers/gna_layer_helpers.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + /** * @brief Modify child layers walking order to maintain strict ordering required for gna_fuse logic */ @@ -99,4 +101,5 @@ inline FuzedLayersContainer make_fuzed_order(InferenceEngine::CNNLayer* origin) return fusedCnt; } -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/gna_graph_compiler.cpp b/src/plugins/intel_gna/src/gna_graph_compiler.cpp index b20b5083343..b7376d5eb62 100644 --- a/src/plugins/intel_gna/src/gna_graph_compiler.cpp +++ b/src/plugins/intel_gna/src/gna_graph_compiler.cpp @@ -43,12 +43,11 @@ using namespace InferenceEngine; using namespace std; using namespace ov::intel_gna; -using namespace GNAPluginNS; using namespace ov::intel_gna::frontend; using namespace ov::intel_gna::common; using namespace memory; -static bool CheckIFLastComponentIsPrecededByConv2D(const GNAPluginNS::backend::DnnComponents::storage_type& components, +static bool CheckIFLastComponentIsPrecededByConv2D(const backend::DnnComponents::storage_type& components, bool verify_with_pooling = true) { bool proceded_by_conv2D = false; auto last_element = components.rbegin(); @@ -71,15 +70,15 @@ static bool CheckIFLastComponentIsPrecededByConv2D(const GNAPluginNS::backend::D GNAGraphCompiler::GNAGraphCompiler(const Config& gna_config) : gna_config(gna_config) {} -void GNAGraphCompiler::setGNAMemoryPtr(std::shared_ptr gnaMemPtr) { +void GNAGraphCompiler::setGNAMemoryPtr(std::shared_ptr gnaMemPtr) { this->gnamem = std::move(gnaMemPtr); } -void GNAGraphCompiler::setDNNPtr(std::shared_ptr dnnPtr) { +void GNAGraphCompiler::setDNNPtr(std::shared_ptr dnnPtr) { this->dnn = std::move(dnnPtr); } -void GNAGraphCompiler::setInputsPtr(std::shared_ptr inputsPtr) { +void GNAGraphCompiler::setInputsPtr(std::shared_ptr inputsPtr) { this->inputs_ptr_ = std::move(inputsPtr); } @@ -110,7 +109,7 @@ void GNAGraphCompiler::fillMemoryConnections(std::unordered_mapname; @@ -148,7 +147,7 @@ void GNAGraphCompiler::fillConcatConnections(InferenceEngine::CNNLayerPtr layer) void GNAGraphCompiler::fillSplitConnections(InferenceEngine::CNNLayerPtr layer) { // creating connection for each layer inputs as form of extramap - GNAPluginNS::GNASplitLayer layerInfoItem(layer); + GNASplitLayer layerInfoItem(layer); size_t split_size = 0; std::string& id = layer->name; IE_ASSERT(!layer->insData.empty()); @@ -214,16 +213,16 @@ void GNAGraphCompiler::fillSplitConnections(InferenceEngine::CNNLayerPtr layer) split_connection.emplace(id, layerInfoItem); } -void GNAPluginNS::GNAGraphCompiler::SetValidatorTarget(const std::string& target) { - auto temp = GNALimitations::Cnn2D::AbstractValidator::Create(target); +void GNAGraphCompiler::SetValidatorTarget(const std::string& target) { + auto temp = limitations::cnn2d::AbstractValidator::Create(target); cnn2dValidator.reset(temp.release()); } -bool GNAPluginNS::GNAGraphCompiler::ShouldUseOnlyConv2DGnaIface() const { +bool GNAGraphCompiler::ShouldUseOnlyConv2DGnaIface() const { return cnn2dValidator && cnn2dValidator->ShouldUseOnlyConv2DGnaIface(); } -void GNAPluginNS::GNAGraphCompiler::ValidateCnn2D(const std::string& name, +void GNAGraphCompiler::ValidateCnn2D(const std::string& name, const uint32_t inHeight, const uint32_t inWidth, const uint32_t inChannels, @@ -245,7 +244,7 @@ void GNAPluginNS::GNAGraphCompiler::ValidateCnn2D(const std::string& name, } } -void GNAPluginNS::GNAGraphCompiler::ValidatePooling2D(const std::string& name, +void GNAGraphCompiler::ValidatePooling2D(const std::string& name, const uint32_t windowH, const uint32_t windowW, const uint32_t strideH, @@ -280,9 +279,8 @@ void GNAGraphCompiler::ConstPrimitive(InferenceEngine::CNNLayerPtr constLayer) } void GNAGraphCompiler::assertConvolutionLayoutProper(const InferenceEngine::DataPtr& data) { - if (data->getLayout() != Layout::NHWC && - data->getLayout() != Layout::NCHW && - data->getLayout() != Layout::NC) { + if (data->getLayout() != InferenceEngine::Layout::NHWC && data->getLayout() != InferenceEngine::Layout::NCHW && + data->getLayout() != InferenceEngine::Layout::NC) { THROW_GNA_EXCEPTION << "layer: \"Convolution\" with layout " << data->getLayout() << " isn't currently supported on GNA"; } } @@ -338,10 +336,10 @@ void GNAGraphCompiler::ConvolutionPrimitive(InferenceEngine::CNNLayerPtr layer) // Map 2d convolution to 1d if it's possible. if (!ShouldUseOnlyConv2DGnaIface() && - GNAConvolutionLayer::isMappableFrom2DTo1D(in_height, in_width, in_channels, + gna_convolution_layer::isMappableFrom2DTo1D(in_height, in_width, in_channels, convolution._kernel_y, convolution._kernel_x, convolution._stride_y, convolution._stride_x)) { - transpose_h_w = GNAConvolutionLayer::should_transpose_h_w(in_height, + transpose_h_w = gna_convolution_layer::should_transpose_h_w(in_height, convolution._kernel_y, in_channels, convolution._stride_y); @@ -382,7 +380,7 @@ void GNAGraphCompiler::ConvolutionPrimitive(InferenceEngine::CNNLayerPtr layer) } if (ShouldUseOnlyConv2DGnaIface() || - GNAConvolutionLayer::is3DInputOr2DKernel(in_height, in_width, in_channels, convolution._kernel_y, convolution._kernel_x) || + gna_convolution_layer::is3DInputOr2DKernel(in_height, in_width, in_channels, convolution._kernel_y, convolution._kernel_x) || in_height != 1) { // TensorFlow default layout is NHWC // OpenVino Default layout is NCHW @@ -518,7 +516,7 @@ void GNAGraphCompiler::finalizeConvolution1DPrimitive(InferenceEngine::CNNLayerP // Keep both variants of kaldi models working: // Old one has layout which is different from NHWC // New one has layout NHWC, but it is mapped from 2d by H - if (inputs->getLayout() == Layout::NHWC && !transpose_h_w) { + if (inputs->getLayout() == InferenceEngine::Layout::NHWC && !transpose_h_w) { currentComponent.orientation_in = kDnnInterleavedOrientation; currentComponent.orientation_out = kDnnInterleavedOrientation; } @@ -536,7 +534,8 @@ void GNAGraphCompiler::finalizeConvolution1DPrimitive(InferenceEngine::CNNLayerP // TODO: convolution might be not the first layer in sorted order but connected via split for example - dont know how kaldi will handle that if (!dnn->do_rotate_input) { - if ((inputs->getLayout() != Layout::NHWC || transpose_h_w) && LayerInfo(connectedInputLayer).isInput()) { + if ((inputs->getLayout() != InferenceEngine::Layout::NHWC || transpose_h_w) && + LayerInfo(connectedInputLayer).isInput()) { // Kaldi features are opposite orientation dnn->do_rotate_input = true; dnn->num_rotate_rows = effectiveStride; @@ -699,7 +698,7 @@ void GNAGraphCompiler::finalizeConvolution2DPrimitive(InferenceEngine::CNNLayerP currentComponent.num_bytes_per_input = inputs->getPrecision().size(); currentComponent.num_bytes_per_output = outputs->getPrecision().size(); - if (inputs->getLayout() == Layout::NHWC) { + if (inputs->getLayout() == InferenceEngine::Layout::NHWC) { currentComponent.orientation_in = kDnnInterleavedOrientation; currentComponent.orientation_out = kDnnInterleavedOrientation; } @@ -713,7 +712,8 @@ void GNAGraphCompiler::finalizeConvolution2DPrimitive(InferenceEngine::CNNLayerP auto connectedInputLayer = connectInput(layer, ptr_inputs, num_data_bytes_in).input; // TODO: convolution might be not the first layer in sorted order but connected via split for example - dont know how kaldi will handle that - if (!dnn->do_rotate_input && inputs->getLayout() != Layout::NHWC && LayerInfo(connectedInputLayer).isInput()) { + if (!dnn->do_rotate_input && inputs->getLayout() != InferenceEngine::Layout::NHWC && + LayerInfo(connectedInputLayer).isInput()) { // Kaldi features are opposite orientation dnn->do_rotate_input = true; dnn->num_rotate_rows = in_channels; @@ -766,9 +766,9 @@ void GNAGraphCompiler::PowerPrimitive(InferenceEngine::CNNLayerPtr layer) { auto input = layer->insData[0].lock(); auto outputs = *layer->outData.begin(); - auto reshaped_dims = Get2DReshapedData(input, GNALimitations::GetMinBatchToFitInBuffer(input), 8)->getDims(); + auto reshaped_dims = Get2DReshapedData(input, limitations::GetMinBatchToFitInBuffer(input), 8)->getDims(); const uint32_t noOfInputsDivisor = gna_config.gnaFlags.input_low_precision ? - GNALimitations::noOfInputsLowPrecDivisor : GNALimitations::noOfInputsDivisor; + limitations::noOfInputsLowPrecDivisor : limitations::noOfInputsDivisor; uint32_t num_rows_in = reshaped_dims[1]; uint32_t num_columns_in = reshaped_dims[0]; uint32_t num_rows_out = num_rows_in; @@ -914,10 +914,10 @@ void GNAGraphCompiler::PoolingPrimitive(InferenceEngine::CNNLayerPtr layer) { const uint32_t c_dim_out = InferenceEngine::GetDataDimByName(outputs, InferenceEngine::DataDimName::C); if (w_dim_in == 1) { // swap dimensions if needed to support swapped 1D case - swap(h_dim_in, w_dim_in); - swap(h_dim_out, w_dim_out); - swap(pooling._kernel[X_AXIS], pooling._kernel[Y_AXIS]); - swap(pooling._stride[X_AXIS], pooling._stride[Y_AXIS]); + std::swap(h_dim_in, w_dim_in); + std::swap(h_dim_out, w_dim_out); + std::swap(pooling._kernel[X_AXIS], pooling._kernel[Y_AXIS]); + std::swap(pooling._stride[X_AXIS], pooling._stride[Y_AXIS]); } void* ptr_inputs = nullptr; @@ -968,9 +968,9 @@ void GNAGraphCompiler::PoolingPrimitive(InferenceEngine::CNNLayerPtr layer) { // but it does not use any specific new GNA features it should be correct to import and run using previous GNA HW if (!is2DPooling) { const auto hLegacy = - GNAPluginNS::GNAConvolutionLayer::outputFromPoolingLegacy(h_dim_in, pooling._stride[X_AXIS]); + gna_convolution_layer::outputFromPoolingLegacy(h_dim_in, pooling._stride[X_AXIS]); const auto wLegacy = - GNAPluginNS::GNAConvolutionLayer::outputFromPoolingLegacy(w_dim_in, pooling._stride[Y_AXIS]); + gna_convolution_layer::outputFromPoolingLegacy(w_dim_in, pooling._stride[Y_AXIS]); if (num_data_bytes_out < hLegacy * wLegacy * c_dim_out) { num_data_bytes_out = hLegacy * wLegacy * c_dim_out; } @@ -1007,7 +1007,7 @@ void GNAGraphCompiler::CopyPrimitive(InferenceEngine::CNNLayerPtr layer) { auto inputs = layer->insData.begin()->lock(); auto outputs = *layer->outData.begin(); - auto reshaped_dims = Get2DReshapedData(inputs, GNALimitations::GetMinBatchToFitInBuffer(inputs), 8)->getDims(); + auto reshaped_dims = Get2DReshapedData(inputs, limitations::GetMinBatchToFitInBuffer(inputs), 8)->getDims(); uint32_t num_rows_in = reshaped_dims[1]; uint32_t num_columns_in = reshaped_dims[0]; uint32_t num_rows_out = num_rows_in; @@ -1068,7 +1068,7 @@ void GNAGraphCompiler::ConcatPrimitive(InferenceEngine::CNNLayerPtr layer) { } // Concat axis validation - if (!GNALimitations::ValidateConvConcatAxis(concatLayer)) { + if (!limitations::ValidateConvConcatAxis(concatLayer)) { std::ostringstream in_dims_oss; auto in_dims = concatLayer->insData[0].lock()->getDims(); std::copy(in_dims.begin(), in_dims.end(), std::ostream_iterator(in_dims_oss, ",")); @@ -1147,7 +1147,7 @@ void GNAGraphCompiler::CropPrimitive(InferenceEngine::CNNLayerPtr layer) { if (!LayerInfo(cropLayer).isCropAffined()) { // leave crop as it is - GNAPluginNS::GNACropLayer cropLayerInfoItem(layer); + GNACropLayer cropLayerInfoItem(layer); std::string& id = layer->name; crop_connection.emplace(id, cropLayerInfoItem); auto cropLayerInfo = crop_connection.find(cropLayer->name); @@ -1178,7 +1178,7 @@ void GNAGraphCompiler::CropPrimitive(InferenceEngine::CNNLayerPtr layer) { uint32_t num_rows_out = InferenceEngine::details::product(begin(outputs->getDims()), end(outputs->getDims())); const uint32_t noOfInputsDivisor = gna_config.gnaFlags.input_low_precision ? - GNALimitations::noOfInputsLowPrecDivisor : GNALimitations::noOfInputsDivisor; + limitations::noOfInputsLowPrecDivisor : limitations::noOfInputsDivisor; uint32_t num_padding = ALIGN(num_rows_in, noOfInputsDivisor) - num_rows_in; void* ptr_inputs = nullptr; @@ -1234,7 +1234,7 @@ void GNAGraphCompiler::EltwisePrimitive(InferenceEngine::CNNLayerPtr layer) { auto& eltwise = dynamic_cast(*layer.get()); auto quantized = InferenceEngine::getInjectedData(layer); const uint32_t noOfInputsDivisor = gna_config.gnaFlags.input_low_precision ? - GNALimitations::noOfInputsLowPrecDivisor : GNALimitations::noOfInputsDivisor; + limitations::noOfInputsLowPrecDivisor : limitations::noOfInputsDivisor; // for eltwise sum/sub in 16-bit precision one input should be 4 bytes and one 2 bytes - detecting that below // the names of variables are left for clarity although not always reflecting the real precision/size @@ -1414,7 +1414,7 @@ void GNAGraphCompiler::GemmPrimitive(InferenceEngine::CNNLayerPtr layer) { auto input_2 = layer->insData[1].lock(); // the second input corresponds to ptr_weights in component auto outputs = *layer->outData.begin(); auto inputPrecision = quantized ? Precision(Precision::I16) : input_1->getPrecision(); - uint32_t noOfInputsDivisor = GNALimitations::noOfInputsDivisor; + uint32_t noOfInputsDivisor = limitations::noOfInputsDivisor; auto in_dims = input_1->getDims(); auto batch_size = (in_dims.size() == 1) ? 1 : in_dims.front(); @@ -1478,7 +1478,7 @@ void GNAGraphCompiler::AffinePrimitive(InferenceEngine::CNNLayerPtr layer, bool auto outputs = *layer->outData.begin(); const auto out_dims = outputs->getDims(); Precision inputPrecision; - uint32_t noOfInputsDivisor = GNALimitations::noOfInputsDivisor; + uint32_t noOfInputsDivisor = limitations::noOfInputsDivisor; if (!quantized) { inputPrecision = inputs->getPrecision(); @@ -1486,11 +1486,11 @@ void GNAGraphCompiler::AffinePrimitive(InferenceEngine::CNNLayerPtr layer, bool inputPrecision = Precision(Precision::I16); } else { inputPrecision = Precision(Precision::I8); - noOfInputsDivisor = GNALimitations::noOfInputsLowPrecDivisor; + noOfInputsDivisor = limitations::noOfInputsLowPrecDivisor; } auto input_data = HasTo2DReshapeData(layer) ? - Get2DReshapedData(inputs, GNALimitations::GetMinBatchToFitInBuffer(inputs), 8) : inputs; + Get2DReshapedData(inputs, limitations::GetMinBatchToFitInBuffer(inputs), 8) : inputs; auto in_dims = input_data->getDims(); auto batch_size = (in_dims.size() == 1) ? 1 : in_dims.front(); uint32_t num_rows_in = InferenceEngine::details::product(in_dims) / batch_size; @@ -1690,7 +1690,7 @@ void GNAGraphCompiler::ConcatAlignFilterPrimitive(InferenceEngine::CNNLayerPtr l auto inputs = layer->insData.begin()->lock(); const uint32_t noOfInputsDivisor = gna_config.gnaFlags.input_low_precision ? - GNALimitations::noOfInputsLowPrecDivisor : GNALimitations::noOfInputsDivisor; + limitations::noOfInputsLowPrecDivisor : limitations::noOfInputsDivisor; uint32_t num_columns_in = GetDimFromBack(inputs->getDims(), 2); uint32_t num_rows_out = GetDimFromBack(outputs->getDims(), 1); uint32_t num_rows_in = filterLayer->_weights->size() / num_rows_out; @@ -1826,7 +1826,7 @@ void GNAGraphCompiler::ConvolutionFilterPrimitive(InferenceEngine::CNNLayerPtr l auto inputs = layer->insData.begin()->lock(); const auto noOfInputsDivisor = gna_config.gnaFlags.input_low_precision ? - GNALimitations::noOfInputsLowPrecDivisor : GNALimitations::noOfInputsDivisor; + limitations::noOfInputsLowPrecDivisor : limitations::noOfInputsDivisor; const uint32_t orginalInputSize = InferenceEngine::details::product(std::next(inputs->getDims().begin()), inputs->getDims().end()); const uint32_t orginalOutputSize = @@ -1842,7 +1842,7 @@ void GNAGraphCompiler::ConvolutionFilterPrimitive(InferenceEngine::CNNLayerPtr l const auto minInputsNeeded = (minOutputsPerFilter - 1) * convolutionStride + filterWidth; const auto numInputsFullyPadedAndAligned = ALIGN(minInputsNeeded, noOfInputsDivisor); - auto numOutputs = GNAConvolutionLayer::outputFromConv(numInputsFullyPadedAndAligned, filterWidth, convolutionStride); + auto numOutputs = gna_convolution_layer::outputFromConv(numInputsFullyPadedAndAligned, filterWidth, convolutionStride); numOutputs *= numberOfFilters; const auto& biasPrecision = filterLayer->_biases ? filterLayer->_biases->getTensorDesc().getPrecision() : outputs->getPrecision(); auto& currentComponent = dnnComponents.addComponent(layer->name, "affine"); @@ -2154,7 +2154,7 @@ void GNAGraphCompiler::PermutePrimitive(InferenceEngine::CNNLayerPtr layer) { } const uint32_t noOfInputsDivisor = gna_config.gnaFlags.input_low_precision ? - GNALimitations::noOfInputsLowPrecDivisor : GNALimitations::noOfInputsDivisor; + limitations::noOfInputsLowPrecDivisor : limitations::noOfInputsDivisor; // now this can be run on GNA if (squeezedInputOrder[0] < squeezedInputOrder[1]) { // interleave case @@ -2359,7 +2359,7 @@ void GNAGraphCompiler::connectOutput(InferenceEngine::CNNLayerPtr layer, // find this input in vector sum all outputs in primitive auto it = std::find_if(concatLayerInfoItem.concatInputLayers.begin(), concatLayerInfoItem.concatInputLayers.end(), - [&name](GNAPluginNS::GNAConcatLayer::ConcatConnectedLayerInfo &item) { + [&name](GNAConcatLayer::ConcatConnectedLayerInfo &item) { return item.name == name; }); if (it != concatLayerInfoItem.concatInputLayers.end()) { @@ -2371,11 +2371,11 @@ void GNAGraphCompiler::connectOutput(InferenceEngine::CNNLayerPtr layer, std::find_if(concat_connection.begin(), concat_connection.end(), [&concatLayerInfo] - (const std::pair &concatItem) -> bool { + (const std::pair &concatItem) -> bool { auto it = std::find_if(concatItem.second.concatInputLayers.begin(), concatItem.second.concatInputLayers.end(), [&concatLayerInfo] - (const GNAPluginNS::GNAConcatLayer::ConcatConnectedLayerInfo &item) -> bool { + (const GNAConcatLayer::ConcatConnectedLayerInfo &item) -> bool { return item.name == concatLayerInfo->first; }); return it != concatItem.second.concatInputLayers.end(); @@ -2384,9 +2384,9 @@ void GNAGraphCompiler::connectOutput(InferenceEngine::CNNLayerPtr layer, auto outputSize = std::max(concatLayerInfoItem.reserved_size, num_data_bytes_out * 2); gnamem->getQueue(REGION_SCRATCH)->reserve_ptr(layer, &concatLayerInfoItem.gna_ptr, ALIGN64(outputSize), 64); - std::function allocate_input_recursively = + std::function allocate_input_recursively = [&allocate_input_recursively](GNAConcatLayer clayer, - GNAPluginNS::GnaInputs &inputs, + GnaInputs &inputs, ConcatConnection& concat_connection) { size_t concatInputIdx = 0; for (auto &&inputLayer : clayer.concatInputLayers) { @@ -2437,7 +2437,7 @@ void GNAGraphCompiler::connectOutput(InferenceEngine::CNNLayerPtr layer, gnamem->getQueue(mem_region)->reserve_ptr(layer, ptr, ALIGN64(num_data_bytes_out), 64); } -GNAPluginNS::ConnectionDetails GNAGraphCompiler::connectInput(CNNLayerPtr layer, +ConnectionDetails GNAGraphCompiler::connectInput(CNNLayerPtr layer, void *ptr, size_t num_data_bytes_in, int32_t offset, @@ -2465,7 +2465,7 @@ GNAPluginNS::ConnectionDetails GNAGraphCompiler::connectInput(CNNLayerPtr layer, auto minInput = inputs_ptr_->at(prevLayer->name).get_required_size(); if (num_data_bytes_in < minInput) { const uint32_t noOfInputsDivisor = gna_config.gnaFlags.input_low_precision ? - GNALimitations::noOfInputsLowPrecDivisor : GNALimitations::noOfInputsDivisor; + limitations::noOfInputsLowPrecDivisor : limitations::noOfInputsDivisor; log::debug() << "[INPUT] : requested bytes: " << num_data_bytes_in << ", extended to" << ALIGN(minInput, noOfInputsDivisor); num_data_bytes_in = ALIGN(minInput, noOfInputsDivisor); } @@ -2528,7 +2528,7 @@ GNAPluginNS::ConnectionDetails GNAGraphCompiler::connectInput(CNNLayerPtr layer, // find this input in vector sum all outputs in primitive auto it = std::find_if(splitLayerInfoItem.splitOutputLayers.begin(), splitLayerInfoItem.splitOutputLayers.end(), - [&idx, &layer](GNAPluginNS::GNASplitLayer::SplitConnectedLayerInfo &item) { + [&idx, &layer](GNASplitLayer::SplitConnectedLayerInfo &item) { return item.connectedTo == layer && item.insDataIdx == idx; }); diff --git a/src/plugins/intel_gna/src/gna_graph_compiler.hpp b/src/plugins/intel_gna/src/gna_graph_compiler.hpp index b542171c37a..37eae2fc644 100644 --- a/src/plugins/intel_gna/src/gna_graph_compiler.hpp +++ b/src/plugins/intel_gna/src/gna_graph_compiler.hpp @@ -15,7 +15,6 @@ #include "descriptions/gna_desc.hpp" #include "descriptions/gna_flags.hpp" #include "connection_details.hpp" -#include "backend/dnn.hpp" #include "memory/gna_memory.hpp" #include "layers/gna_memory_layer.hpp" #include "layers/gna_concat_layer.hpp" @@ -27,12 +26,14 @@ #include "gna_device.hpp" #include "gna_data_types.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + class GNAGraphCompiler { private: - std::shared_ptr dnn; - std::shared_ptr gnamem; - std::shared_ptr inputs_ptr_; + std::shared_ptr dnn; + std::shared_ptr gnamem; + std::shared_ptr inputs_ptr_; // layers with extra storage for connections and additional // non trivial processing @@ -49,20 +50,20 @@ private: static void assertConvolutionLayoutProper(const InferenceEngine::DataPtr&); std::vector static transposeMatrix(uint8_t* ptr_matrix, size_t element_size, uint32_t num_rows, uint32_t num_cols); - std::unique_ptr cnn2dValidator; + std::unique_ptr cnn2dValidator; bool ShouldUseOnlyConv2DGnaIface() const; public: - GNAPluginNS::backend::DnnComponents dnnComponents; + backend::DnnComponents dnnComponents; MemoryConnection memory_connection; ConcatConnection concat_connection; ConstConnections const_connections; GNAGraphCompiler(const Config& gna_config); - void setGNAMemoryPtr(std::shared_ptr gnaMemPtr); - void setDNNPtr(std::shared_ptr dnnPtr); - void setInputsPtr(std::shared_ptr inputsPtr); + void setGNAMemoryPtr(std::shared_ptr gnaMemPtr); + void setDNNPtr(std::shared_ptr dnnPtr); + void setInputsPtr(std::shared_ptr inputsPtr); void fillMemoryConnections(std::unordered_map> &memoryPairs); @@ -102,7 +103,7 @@ public: * in case when we would like to use zero offset and connect from pointer set this to negative * @return layer used as input */ - GNAPluginNS::ConnectionDetails connectInput(InferenceEngine::CNNLayerPtr layer, + ConnectionDetails connectInput(InferenceEngine::CNNLayerPtr layer, void *pVoid, size_t num_data_bytes_in, int32_t offset = 0, @@ -149,4 +150,6 @@ public: void Reset(); }; -} // namespace GNAPluginNS + +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/gna_graph_patterns.hpp b/src/plugins/intel_gna/src/gna_graph_patterns.hpp index f61f78226a1..f8c687a412b 100644 --- a/src/plugins/intel_gna/src/gna_graph_patterns.hpp +++ b/src/plugins/intel_gna/src/gna_graph_patterns.hpp @@ -11,7 +11,8 @@ #include "layers/gna_layer_info.hpp" #include "ops/util/util.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { /** * @brief checks if it's a reshape from 4d to 3d tensor @@ -104,7 +105,7 @@ inline std::pair Fin const auto layout = next->outData[0]->getLayout(); const auto order = next->GetParamAsInts("order"); if (layout != InferenceEngine::Layout::NCHW && layout != InferenceEngine::Layout::CHW || - order != GetPermuteOrder(InferenceEngine::Layout::NCHW, InferenceEngine::Layout::NHWC) && + order != permute::GetPermuteOrder(InferenceEngine::Layout::NCHW, InferenceEngine::Layout::NHWC) && order != std::vector{0, 2, 1} /* NCW to NWC */) { return std::make_pair(nullptr, nullptr); } @@ -155,7 +156,7 @@ inline std::pair Fin const auto layout = prev->outData[0]->getLayout(); const auto order = prev->GetParamAsInts("order"); if (layout != InferenceEngine::Layout::NCHW && layout != InferenceEngine::Layout::CHW || - order != GetPermuteOrder(InferenceEngine::Layout::NHWC, InferenceEngine::Layout::NCHW) && + order != permute::GetPermuteOrder(InferenceEngine::Layout::NHWC, InferenceEngine::Layout::NCHW) && order != std::vector{0, 2, 1} /* NWC to NCW */) { return std::make_pair(nullptr, nullptr); } @@ -427,4 +428,5 @@ inline std::vector FindTranspositionInfoFromNextLayers(Infere return findTranspositionInfoRecursive(layer); } -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/gna_groups.hpp b/src/plugins/intel_gna/src/gna_groups.hpp index 8433b62b56a..3fc99c03437 100644 --- a/src/plugins/intel_gna/src/gna_groups.hpp +++ b/src/plugins/intel_gna/src/gna_groups.hpp @@ -8,7 +8,9 @@ #include "gna_graph_tools.hpp" #include "layers/gna_layer_info.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + /** * @brief returns a pointer to 2D reshaped data to satisfy maximum size of zero dimension * @param input a pointer to data to be reshaped @@ -47,14 +49,15 @@ inline InferenceEngine::DataPtr Get2DReshapedData(InferenceEngine::DataPtr input * @param layer */ inline bool HasTo2DReshapeData(InferenceEngine::CNNLayerPtr layer) { - if (GNAPluginNS::LayerInfo(layer).isPower() || GNAPluginNS::LayerInfo(layer).isCopy()) + if (LayerInfo(layer).isPower() || LayerInfo(layer).isCopy()) return true; - if (!GNAPluginNS::LayerInfo(layer).isSyntheticScaleShift()) + if (!LayerInfo(layer).isSyntheticScaleShift()) return false; // Don't reshape diagonallayers with bias connection - return !GNAPluginNS::LayerInfo(getCreatorLayer(layer->insData.front().lock()).lock()).has32BOutput(); + return !LayerInfo(getCreatorLayer(layer->insData.front().lock()).lock()).has32BOutput(); } -} // namespace GNAPluginNS \ No newline at end of file +} // namespace intel_gna +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_gna/src/gna_infer_request.cpp b/src/plugins/intel_gna/src/gna_infer_request.cpp index 45b72ab0f3f..a8f5125b6a7 100644 --- a/src/plugins/intel_gna/src/gna_infer_request.cpp +++ b/src/plugins/intel_gna/src/gna_infer_request.cpp @@ -6,7 +6,9 @@ #include "gna_plugin.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + GNAInferRequest::GNAInferRequest(const std::shared_ptr& plg, const std::vector>& inputs, @@ -170,4 +172,5 @@ void GNAInferRequest::CreateInferRequest() { } } -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/gna_infer_request.hpp b/src/plugins/intel_gna/src/gna_infer_request.hpp index bcd94c0c5c5..2d235ec5706 100644 --- a/src/plugins/intel_gna/src/gna_infer_request.hpp +++ b/src/plugins/intel_gna/src/gna_infer_request.hpp @@ -9,7 +9,9 @@ #include "cpp_interfaces/interface/ie_iinfer_request_internal.hpp" #include "request_status.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + class GNAPlugin; class GNAInferRequest : public InferenceEngine::IInferRequestInternal { @@ -60,4 +62,6 @@ private: uint32_t _infer_request_idx = kRequestIndexInvalid; std::shared_ptr plg; }; -} // namespace GNAPluginNS + +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/gna_itt.hpp b/src/plugins/intel_gna/src/gna_itt.hpp index cc641392bd8..ba188ad8159 100644 --- a/src/plugins/intel_gna/src/gna_itt.hpp +++ b/src/plugins/intel_gna/src/gna_itt.hpp @@ -11,11 +11,15 @@ #include -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace itt { namespace domains { + OV_ITT_DOMAIN(GNAPlugin); OV_ITT_DOMAIN(GNA_LT); -} -} -} + +} // namespace domains +} // namespace itt +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/gna_lib_ver_selector.hpp b/src/plugins/intel_gna/src/gna_lib_ver_selector.hpp index 8d7147f73bc..3a63d3b5ed8 100644 --- a/src/plugins/intel_gna/src/gna_lib_ver_selector.hpp +++ b/src/plugins/intel_gna/src/gna_lib_ver_selector.hpp @@ -28,12 +28,15 @@ */ #define ALIGN64(number) ALIGN(number, 64) -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace tools { + template std::unique_ptr make_unique(Args&&... args) { return std::unique_ptr(new T(std::forward(args)...)); } -} // namespace tools -} // namespace GNAPluginNS +} // namespace tools +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/gna_model_serial.cpp b/src/plugins/intel_gna/src/gna_model_serial.cpp index 231d09cc8b5..966abe3c53f 100644 --- a/src/plugins/intel_gna/src/gna_model_serial.cpp +++ b/src/plugins/intel_gna/src/gna_model_serial.cpp @@ -29,7 +29,7 @@ #include "serial/headers/latest/gna_model_header.hpp" #include "common/versioning.hpp" -using namespace GNAPluginNS; +using namespace ov::intel_gna; inline void writeNBytes(const void *ptr, uint32_t size, std::ostream & os) { os.write(static_cast(ptr), size); @@ -108,7 +108,7 @@ std::string GNAVersionSerializer::Import(std::istream& is) const { const int gna_header_magic = is_little_endian() ? 0x4d414e47 : 0x474e414d; -GNAPluginNS::HeaderLatest::ModelHeader GNAModelSerial::ReadHeader(std::istream &is) { +header_latest::ModelHeader GNAModelSerial::ReadHeader(std::istream &is) { is.exceptions(std::istream::failbit); auto startPos = is.tellg(); if (startPos == -1) { @@ -122,11 +122,11 @@ GNAPluginNS::HeaderLatest::ModelHeader GNAModelSerial::ReadHeader(std::istream & stream_len -= startPos; is.seekg(startPos, is.beg); - HeaderLatest::ModelHeader header; + header_latest::ModelHeader header; header.version.major = 0u; header.version.minor = 0u; - auto size_of_headers_header = sizeof(HeaderLatest::ModelHeader::gnam) + sizeof(HeaderLatest::ModelHeader::headerSize) - + sizeof(HeaderLatest::ModelHeader::Version); + auto size_of_headers_header = sizeof(header_latest::ModelHeader::gnam) + sizeof(header_latest::ModelHeader::headerSize) + + sizeof(header_latest::ModelHeader::Version); if (stream_len > size_of_headers_header) { readNBytes(&header, static_cast(size_of_headers_header), is); } else { @@ -142,34 +142,34 @@ GNAPluginNS::HeaderLatest::ModelHeader GNAModelSerial::ReadHeader(std::istream & } is.seekg(startPos, is.beg); - Header2dot1::ModelHeader tempHeader2dot1; + header_2_dot_1::ModelHeader tempheader_2_dot_1; switch (header.version.major) { case 2: switch (header.version.minor) { case 1: - readBits(tempHeader2dot1, is); - header = HeaderLatest::ModelHeader(tempHeader2dot1); + readBits(tempheader_2_dot_1, is); + header = header_latest::ModelHeader(tempheader_2_dot_1); break; case 2: case 3: { - Header2dot3::ModelHeader tempHeader2dot3; - readBits(tempHeader2dot3, is); - header = HeaderLatest::ModelHeader(tempHeader2dot3); + header_2_dot_3::ModelHeader tempheader_2_dot_3; + readBits(tempheader_2_dot_3, is); + header = header_latest::ModelHeader(tempheader_2_dot_3); break; } case 4: { - Header2dot4::ModelHeader tempHeader2dot4; - readBits(tempHeader2dot4, is); - header = HeaderLatest::ModelHeader(tempHeader2dot4); + header_2_dot_4::ModelHeader tempheader_2_dot_4; + readBits(tempheader_2_dot_4, is); + header = header_latest::ModelHeader(tempheader_2_dot_4); break; } case 5: case 6: case 7: case 8: - readNBytes(&header, sizeof(HeaderLatest::ModelHeader), is); + readNBytes(&header, sizeof(header_latest::ModelHeader), is); break; default: THROW_GNA_EXCEPTION << "Imported file unsupported. minor version should have values in range 1 to 8 and is: " << header.version.minor; @@ -190,10 +190,10 @@ GNAPluginNS::HeaderLatest::ModelHeader GNAModelSerial::ReadHeader(std::istream & return header; } -GNAPluginNS::HeaderLatest::RuntimeEndPoint GNAModelSerial::ReadEndPoint(std::istream &is) { +header_latest::RuntimeEndPoint GNAModelSerial::ReadEndPoint(std::istream &is) { is.exceptions(std::istream::failbit); - HeaderLatest::RuntimeEndPoint endPoint; + header_latest::RuntimeEndPoint endPoint; switch (model_header_.version.major) { case 2: switch (model_header_.version.minor) { @@ -204,20 +204,20 @@ GNAPluginNS::HeaderLatest::RuntimeEndPoint GNAModelSerial::ReadEndPoint(std::ist case 5: case 6: { - Header2dot6::RuntimeEndPoint tempEndPoint2dot6; + header_2_dot_6::RuntimeEndPoint tempEndPoint2dot6; readBits(tempEndPoint2dot6, is); - endPoint = HeaderLatest::RuntimeEndPoint(tempEndPoint2dot6, model_header_.nGroup); + endPoint = header_latest::RuntimeEndPoint(tempEndPoint2dot6, model_header_.nGroup); break; } case 7: { - Header2dot7::RuntimeEndPoint tempEndPoint2dot7; + header_2_dot_7::RuntimeEndPoint tempEndPoint2dot7; readBits(tempEndPoint2dot7, is); - endPoint = HeaderLatest::RuntimeEndPoint(tempEndPoint2dot7); + endPoint = header_latest::RuntimeEndPoint(tempEndPoint2dot7); break; } case 8: - readNBytes(&endPoint, sizeof(HeaderLatest::RuntimeEndPoint), is); + readNBytes(&endPoint, sizeof(header_latest::RuntimeEndPoint), is); break; default: THROW_GNA_EXCEPTION << "Imported file unsupported. minor version should have values in range 1 to 8 and is: " @@ -259,8 +259,8 @@ static const std::map> GnaParamSize{ void GNAModelSerial::Import(void *basePointer, size_t gnaGraphSize, std::istream &is, - GNAPluginNS::GnaInputs &inputs, - GNAPluginNS::GnaOutputs &outputs, + GnaInputs &inputs, + GnaOutputs &outputs, TranspositionInfoMap &inputsTranspositionInfo, TranspositionInfoMap &outputsTranspositionInfo, std::string & libVersionFromFile) { @@ -269,7 +269,7 @@ void GNAModelSerial::Import(void *basePointer, if (model_header_.version.major == 2) { for (auto inputIndex = 0; inputIndex < model_header_.nInputs; inputIndex++) { std::string name = (model_header_.version.minor >= 3) ? readString(is) : std::string("input" + std::to_string(inputIndex)); - inputs[name] = GNAPluginNS::InputDesc(name); + inputs[name] = InputDesc(name); } if (model_header_.version.minor >= 5) { // 3. Read transposition input info @@ -294,7 +294,7 @@ void GNAModelSerial::Import(void *basePointer, if (model_header_.version.major == 2) { for (auto outputIndex = 0; outputIndex < model_header_.nOutputs; outputIndex++) { std::string name = (model_header_.version.minor >= 3) ? readString(is) : std::string("output" + std::to_string(outputIndex)); - outputs[name] = GNAPluginNS::OutputDesc(name); + outputs[name] = OutputDesc(name); } } // 7. Read outputs @@ -416,8 +416,8 @@ void GNAModelSerial::Export(const GnaAllocations& allocations, std::ostream& os) return out; }; - auto convert_to_serial = [&allocationsOrdered](const GNAPluginNS::GnaDesc& desc) { - HeaderLatest::RuntimeEndPoint ep; + auto convert_to_serial = [&allocationsOrdered](const GnaDesc& desc) { + header_latest::RuntimeEndPoint ep; ep.elements_count = desc.num_elements; ep.scaleFactor = desc.scale_factor; ep.element_size = desc.tensor_precision.size(); @@ -441,12 +441,12 @@ void GNAModelSerial::Export(const GnaAllocations& allocations, std::ostream& os) /** * writing header */ - HeaderLatest::ModelHeader header; + header_latest::ModelHeader header; header.gnam[0] = 'G'; header.gnam[1] = 'N'; header.gnam[2] = 'A'; header.gnam[3] = 'M'; - header.headerSize = sizeof(HeaderLatest::ModelHeader); + header.headerSize = sizeof(header_latest::ModelHeader); header.gnaMemSize = gnaGraphSize; header.layersCount = layers.size(); header.nGroup = 1; // just to support the old models @@ -561,9 +561,9 @@ void GNAModelSerial::Export(const GnaAllocations& allocations, std::ostream& os) version_.Export(os); } -void GNAModelSerial::ImportInputs(std::istream &is, void* basePtr, GNAPluginNS::GnaInputs &inputs) { +void GNAModelSerial::ImportInputs(std::istream &is, void* basePtr, GnaInputs &inputs) { for (auto &input : inputs.Get()) { - HeaderLatest::RuntimeEndPoint ep = ReadEndPoint(is); + header_latest::RuntimeEndPoint ep = ReadEndPoint(is); input.ptrs.push_back(reinterpret_cast(reinterpret_cast (basePtr) + ep.descriptor_offset)); input.orientation = ep.orientation; @@ -589,9 +589,9 @@ void GNAModelSerial::ImportInputs(std::istream &is, void* basePtr, GNAPluginNS:: } } -void GNAModelSerial::ImportOutputs(std::istream &is, void* basePtr, GNAPluginNS::GnaOutputs &outputs) { +void GNAModelSerial::ImportOutputs(std::istream &is, void* basePtr, GnaOutputs &outputs) { for (auto &output : outputs.Get()) { - HeaderLatest::RuntimeEndPoint ep = ReadEndPoint(is); + header_latest::RuntimeEndPoint ep = ReadEndPoint(is); output.ptrs.push_back(reinterpret_cast(reinterpret_cast (basePtr) + ep.descriptor_offset)); output.orientation = ep.orientation; @@ -648,9 +648,9 @@ void GNAModelSerial::ExportTranspositionInfo(std::ostream &os, } void GNAModelSerial::AppendTensorNameIfNeeded(GnaDesc& nodeDesc) const { - static constexpr Header2dot8::ModelHeader::Version kHasTensorNamesVersion; + static constexpr header_2_dot_8::ModelHeader::Version kHasTensorNamesVersion; - if (HeaderLatest::IsFirstVersionLower(model_header_.version, kHasTensorNamesVersion) && + if (header_latest::IsFirstVersionLower(model_header_.version, kHasTensorNamesVersion) && nodeDesc.tensor_names.empty()) { nodeDesc.tensor_names.insert(nodeDesc.name); } diff --git a/src/plugins/intel_gna/src/gna_model_serial.hpp b/src/plugins/intel_gna/src/gna_model_serial.hpp index 1ecb2bc7a8a..6c5b340150a 100644 --- a/src/plugins/intel_gna/src/gna_model_serial.hpp +++ b/src/plugins/intel_gna/src/gna_model_serial.hpp @@ -34,16 +34,16 @@ public: private: Gna2Model * gna2model_; MemoryType states, *pstates_ = nullptr; - GNAPluginNS::GnaInputs inputs_; - GNAPluginNS::GnaOutputs outputs_; + ov::intel_gna::GnaInputs inputs_; + ov::intel_gna::GnaOutputs outputs_; TranspositionInfoMap inputs_transpose_info_; TranspositionInfoMap outputs_transpose_info_; - GNAPluginNS::HeaderLatest::ModelHeader model_header_; + ov::intel_gna::header_latest::ModelHeader model_header_; GNAVersionSerializer version_; - void ImportInputs(std::istream &is, void* basePtr, GNAPluginNS::GnaInputs &inputs); + void ImportInputs(std::istream &is, void* basePtr, ov::intel_gna::GnaInputs &inputs); - void ImportOutputs(std::istream &is, void* basePtr, GNAPluginNS::GnaOutputs &outputs); + void ImportOutputs(std::istream &is, void* basePtr, ov::intel_gna::GnaOutputs &outputs); void ImportTranspositionInfo(std::istream &is, std::string &name, std::vector &transpositionInfo); @@ -53,7 +53,7 @@ private: * @brief Update input or output description to support importing of < 2.8 format where tensor_names were not present * @param nodeDesc input or output description to be appended */ - void AppendTensorNameIfNeeded(GNAPluginNS::GnaDesc& nodeDesc) const; + void AppendTensorNameIfNeeded(ov::intel_gna::GnaDesc& nodeDesc) const; public: GNAModelSerial(Gna2Model* model, MemoryType& states_holder) @@ -62,14 +62,14 @@ private: } GNAModelSerial(Gna2Model* model, - GNAPluginNS::GnaInputs& inputs, - GNAPluginNS::GnaOutputs& outputs) + ov::intel_gna::GnaInputs& inputs, + ov::intel_gna::GnaOutputs& outputs) : gna2model_(model), inputs_(inputs), outputs_(outputs) { } - void setHeader(GNAPluginNS::HeaderLatest::ModelHeader header) { + void setHeader(ov::intel_gna::header_latest::ModelHeader header) { model_header_ = header; } @@ -100,9 +100,9 @@ private: * @param is - opened input stream * @return */ - static GNAPluginNS::HeaderLatest::ModelHeader ReadHeader(std::istream &is); + static ov::intel_gna::header_latest::ModelHeader ReadHeader(std::istream &is); - GNAPluginNS::HeaderLatest::RuntimeEndPoint ReadEndPoint(std::istream &is); + ov::intel_gna::header_latest::RuntimeEndPoint ReadEndPoint(std::istream &is); /** * @brief Import model from FS into preallocated buffer, @@ -114,8 +114,8 @@ private: void Import(void *basePointer, size_t gnaGraphSize, std::istream &is, - GNAPluginNS::GnaInputs &inputs, - GNAPluginNS::GnaOutputs &outputs, + ov::intel_gna::GnaInputs &inputs, + ov::intel_gna::GnaOutputs &outputs, TranspositionInfoMap& inputstranspositionInfo, TranspositionInfoMap& outputstranspositionInfo, std::string& modelLibVersion); diff --git a/src/plugins/intel_gna/src/gna_plugin.cpp b/src/plugins/intel_gna/src/gna_plugin.cpp index 0cf12502d97..d9af0851196 100644 --- a/src/plugins/intel_gna/src/gna_plugin.cpp +++ b/src/plugins/intel_gna/src/gna_plugin.cpp @@ -125,8 +125,8 @@ inline uint32_t ToByteSize(const Gna2DataType type) { using namespace std; using namespace InferenceEngine; using namespace InferenceEngine::details; -using namespace GNAPluginNS; -using namespace GNAPluginNS::memory; + +using namespace ov::intel_gna::memory; using namespace ov::intel_gna::frontend; namespace InferenceEngine { @@ -355,9 +355,9 @@ GNAPlugin::GNAPlugin(const std::map& configMap) : void GNAPlugin::Init() { OV_ITT_SCOPED_TASK(itt::domains::GNAPlugin, "Init"); dnn = std::make_shared(backend::AMIntelDNN()); - gnaFlags = std::make_shared(GNAPluginNS::GNAFlags()); - inputs_ptr_ = std::make_shared(GNAPluginNS::GnaInputs()); - outputs_ = GNAPluginNS::GnaOutputs(); + gnaFlags = std::make_shared(GNAFlags()); + inputs_ptr_ = std::make_shared(GnaInputs()); + outputs_ = GnaOutputs(); graphCompiler.setDNNPtr(dnn); graphCompiler.setInputsPtr(inputs_ptr_); @@ -508,7 +508,7 @@ bool GNAPlugin::TryToInitOutput(const std::string &portName, InferenceEngine::CN outputs_.at(portName).ptrs.resize(gnaFlags->num_requests); outputs_.at(portName).orientation = orientation; outputs_.at(portName).set_precision(numBytesPerElem); - outputs_.at(portName).scale_factor = quantized != nullptr ? quantized->_dst_quant.GetScale() : GNAPluginNS::kScaleFactorDefault; + outputs_.at(portName).scale_factor = quantized != nullptr ? quantized->_dst_quant.GetScale() : kScaleFactorDefault; outputs_.at(portName).num_elements = numElem; // binding ptr for first infer request - then others will be setup during relocation @@ -787,7 +787,7 @@ void GNAPlugin::LoadNetwork(const CNNNetwork& _network) { // Check the network std::string error; - if (!GNAPluginNS::GNALimitations::AreLayersSupported(network, error)) { + if (!limitations::AreLayersSupported(network, error)) { THROW_GNA_EXCEPTION << error.c_str(); } @@ -1082,7 +1082,7 @@ void GNAPlugin::LoadNetwork(const CNNNetwork& _network) { // update orientation of model intput layer for (auto& inputLayer : inputLayers) { if (LayerInfo(inputLayer).isInput()) { - ov::intela_gna::helpers::updateModelInputOrientationWithoutConvolution(*inputLayer, + ov::intel_gna::helpers::updateModelInputOrientationWithoutConvolution(*inputLayer, graphCompiler.dnnComponents, *inputs_ptr_); } @@ -1092,7 +1092,7 @@ void GNAPlugin::LoadNetwork(const CNNNetwork& _network) { for (auto&& outPort : outputs_data_map_) { auto outLayer = getCreatorLayer(outPort.second).lock(); if (outLayer && LayerInfo(outLayer).isOutput()) { - ov::intela_gna::helpers::updateModelOutputOrientation(outPort.first, + ov::intel_gna::helpers::updateModelOutputOrientation(outPort.first, outLayer->name, graphCompiler.dnnComponents, outputs_); @@ -1113,11 +1113,11 @@ void GNAPlugin::LoadNetwork(const CNNNetwork& _network) { #endif } -bool GNAPluginNS::GNAPlugin::isFP32ModeActive() const { +bool GNAPlugin::isFP32ModeActive() const { return gnaFlags->sw_fp32 || !gnadevice; } -std::string GNAPluginNS::GNAPlugin::effectiveGnaCompileTarget() const { +std::string GNAPlugin::effectiveGnaCompileTarget() const { if (gnadevice) { return gnadevice->GetCompileTarget(); } else if (!config.gnaCompileTarget.empty()) { @@ -1161,7 +1161,7 @@ std::shared_ptr GNAPlugin::createModelWrapperForLoadNetwo THROW_GNA_EXCEPTION << "dnn is nullptr cannot load network"; } - std::weak_ptr weakDnn = dnn; + std::weak_ptr weakDnn = dnn; auto compileTarget = effectiveGnaCompileTarget(); auto initializer = [weakDnn, compileTarget](Gna2Model* model) { if (auto dnn = weakDnn.lock()) { @@ -1174,7 +1174,7 @@ std::shared_ptr GNAPlugin::createModelWrapperForLoadNetwo return request::ModelWrapperFactory::createInitialized(std::move(initializer)); } -std::shared_ptr GNAPluginNS::GNAPlugin::createModelWrapperForImportNetwork( +std::shared_ptr GNAPlugin::createModelWrapperForImportNetwork( uint32_t numberOfOperations) { return request::ModelWrapperFactory::createWithNumberOfEmptyOperations(numberOfOperations); } @@ -1238,20 +1238,21 @@ uint32_t GNAPlugin::QueueInference(const InferenceEngine::BlobMap& inputs, Infer int inputNum = 0; for (auto& input : inputs) { auto inputLayout = input.second->getTensorDesc().getLayout(); - if (inputLayout != Layout::C && inputLayout != Layout::NC && inputLayout != Layout::CN && - inputLayout != Layout::CHW && inputLayout != Layout::NCHW) { + if (inputLayout != InferenceEngine::Layout::C && inputLayout != InferenceEngine::Layout::NC && + inputLayout != InferenceEngine::Layout::CN && inputLayout != InferenceEngine::Layout::CHW && + inputLayout != InferenceEngine::Layout::NCHW) { THROW_GNA_EXCEPTION << "Expected input blob to have Layout::C, Layout::NC, Layout::CN, Layout::NCHW or " "Layout::CHW. But was: " << input.second->getTensorDesc().getLayout(); } - if (inputLayout == Layout::NCHW || inputLayout == Layout::CHW) { + if (inputLayout == InferenceEngine::Layout::NCHW || inputLayout == InferenceEngine::Layout::CHW) { // specific case that can be squeezed to 2d - inputLayout = Layout::NC; + inputLayout = InferenceEngine::Layout::NC; } - auto is1D = input.second->getTensorDesc().getLayout() == Layout::C; - auto is3D = input.second->getTensorDesc().getLayout() == Layout::CHW; + auto is1D = input.second->getTensorDesc().getLayout() == InferenceEngine::Layout::C; + auto is3D = input.second->getTensorDesc().getLayout() == InferenceEngine::Layout::CHW; if (inputs_ptr_->at(input.first).ptrs.empty()) { // should not happen in user code however might happen if there any non executable network based integration @@ -1297,7 +1298,7 @@ uint32_t GNAPlugin::QueueInference(const InferenceEngine::BlobMap& inputs, Infer ImportFrames(inputs_ptr_->at(input.first).ptrs[index], input.second->cbuffer().as(), input.second->getTensorDesc().getPrecision(), - gnaFlags->sw_fp32 ? GNAPluginNS::kScaleFactorDefault : inputs_ptr_->at(input.first).scale_factor, + gnaFlags->sw_fp32 ? kScaleFactorDefault : inputs_ptr_->at(input.first).scale_factor, inputOrientation, importedFrames, targetGroups, @@ -1394,21 +1395,21 @@ RequestStatus GNAPlugin::WaitFor(uint32_t request_idx, int64_t millisTimeout) { for (auto&& outputBlobIt : requestResult) { auto& outputBlob = outputBlobIt.second; auto& outputDesc = outputs_.at(outputBlobIt.first); - if (outputBlob->getTensorDesc().getLayout() != Layout::C && - outputBlob->getTensorDesc().getLayout() != Layout::NC && - outputBlob->getTensorDesc().getLayout() != Layout::CN && - outputBlob->getTensorDesc().getLayout() != Layout::NCHW && - outputBlob->getTensorDesc().getLayout() != Layout::CHW && - outputBlob->getTensorDesc().getLayout() != Layout::SCALAR) { + if (outputBlob->getTensorDesc().getLayout() != InferenceEngine::Layout::C && + outputBlob->getTensorDesc().getLayout() != InferenceEngine::Layout::NC && + outputBlob->getTensorDesc().getLayout() != InferenceEngine::Layout::CN && + outputBlob->getTensorDesc().getLayout() != InferenceEngine::Layout::NCHW && + outputBlob->getTensorDesc().getLayout() != InferenceEngine::Layout::CHW && + outputBlob->getTensorDesc().getLayout() != InferenceEngine::Layout::SCALAR) { THROW_GNA_EXCEPTION << "Expected output blob to have Layout::C, Layout::NC, Layout::CN, Layout::NCHW or " "Layout::CHW. But was " << outputBlob->getTensorDesc().getLayout(); } auto dims = outputBlob->getTensorDesc().getDims(); - auto is1D = outputBlob->getTensorDesc().getLayout() == Layout::C; - auto isScalar = outputBlob->getTensorDesc().getLayout() == Layout::SCALAR; - auto is3D = outputBlob->getTensorDesc().getLayout() == Layout::CHW; + auto is1D = outputBlob->getTensorDesc().getLayout() == InferenceEngine::Layout::C; + auto isScalar = outputBlob->getTensorDesc().getLayout() == InferenceEngine::Layout::SCALAR; + auto is3D = outputBlob->getTensorDesc().getLayout() == InferenceEngine::Layout::CHW; auto batchSize = (is1D || isScalar || is3D) ? 1 : dims[0]; auto elementsPerBatch = isScalar ? 1 @@ -1635,7 +1636,7 @@ InferenceEngine::IExecutableNetworkInternal::Ptr GNAPlugin::ImportNetwork(std::i SetNetworkInputs(); SetNetworkOutputs(); - ov::intela_gna::helpers::ApplyInputScaleFactors(config, header, *inputs_ptr_); + ov::intel_gna::helpers::ApplyInputScaleFactors(config, header, *inputs_ptr_); auto getOrientation = [](Gna2Operation& gnaOperation) { return gnaOperation.Type == Gna2OperationTypeConvolution ? kDnnNonInterleavedOrientation diff --git a/src/plugins/intel_gna/src/gna_plugin.hpp b/src/plugins/intel_gna/src/gna_plugin.hpp index 4894a883e22..07a292c854b 100644 --- a/src/plugins/intel_gna/src/gna_plugin.hpp +++ b/src/plugins/intel_gna/src/gna_plugin.hpp @@ -26,8 +26,10 @@ #include #include -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { + class ModelWrapper; class WorkerPool; class Worker; @@ -38,13 +40,13 @@ protected: std::string _pluginName = "GNA"; Config config {}; - std::shared_ptr dnn; - std::shared_ptr gnaFlags; - std::shared_ptr gnamem; - std::shared_ptr inputs_ptr_; - GNAPluginNS::GnaOutputs outputs_; + std::shared_ptr dnn; + std::shared_ptr gnaFlags; + std::shared_ptr gnamem; + std::shared_ptr inputs_ptr_; + GnaOutputs outputs_; - GNAPluginNS::GNAGraphCompiler graphCompiler; + GNAGraphCompiler graphCompiler; uint32_t activeLayerIndex = 0xffffffff; TranspositionInfoMap transpose_inputs_info; @@ -237,4 +239,5 @@ protected: #endif }; -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/gna_plugin_config.cpp b/src/plugins/intel_gna/src/gna_plugin_config.cpp index 3ab7a862247..26c62783809 100644 --- a/src/plugins/intel_gna/src/gna_plugin_config.cpp +++ b/src/plugins/intel_gna/src/gna_plugin_config.cpp @@ -19,10 +19,11 @@ using namespace InferenceEngine; using namespace InferenceEngine::details; -using namespace ov::intel_gna; using namespace ov::intel_gna::common; -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + const uint8_t Config::max_num_requests; OPENVINO_SUPPRESS_DEPRECATED_START @@ -127,7 +128,7 @@ void Config::UpdateFromMap(const std::map& config) { check_scale_factor(scale_factor); // missing scale factors are set to be 1.0f if (inputScaleFactors.size() <= input_index) { - inputScaleFactors.resize(input_index + 1, GNAPluginNS::kScaleFactorDefault); + inputScaleFactors.resize(input_index + 1, kScaleFactorDefault); } inputScaleFactors[input_index] = InferenceEngine::CNNLayer::ie_parse_float(value); } else if (key == GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE) || key == ov::intel_gna::firmware_model_image_path) { @@ -414,4 +415,6 @@ std::vector Config::GetSupportedKeys() const { } return result; } -} // namespace GNAPluginNS + +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/gna_plugin_config.hpp b/src/plugins/intel_gna/src/gna_plugin_config.hpp index 4d58d59debf..e93f207030d 100644 --- a/src/plugins/intel_gna/src/gna_plugin_config.hpp +++ b/src/plugins/intel_gna/src/gna_plugin_config.hpp @@ -14,7 +14,8 @@ #include #include -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { static const float kScaleFactorDefault = 1.f; @@ -76,4 +77,5 @@ struct Config { static const uint8_t max_num_requests = 127; }; -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/gna_plugin_entry_points.cpp b/src/plugins/intel_gna/src/gna_plugin_entry_points.cpp index ab9648930f9..9548f77187c 100644 --- a/src/plugins/intel_gna/src/gna_plugin_entry_points.cpp +++ b/src/plugins/intel_gna/src/gna_plugin_entry_points.cpp @@ -7,7 +7,6 @@ using namespace InferenceEngine; using namespace std; -using namespace GNAPluginNS; static const Version gnaPluginDescription = { {2, 1}, diff --git a/src/plugins/intel_gna/src/gna_plugin_internal.hpp b/src/plugins/intel_gna/src/gna_plugin_internal.hpp index d70c390b9a1..f4a228ec1cf 100644 --- a/src/plugins/intel_gna/src/gna_plugin_internal.hpp +++ b/src/plugins/intel_gna/src/gna_plugin_internal.hpp @@ -13,7 +13,8 @@ #include "gna_plugin_config.hpp" #include -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { class GNAPluginInternal : public InferenceEngine::IInferencePlugin { private: @@ -104,4 +105,5 @@ public: } }; -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/gna_plugin_query_api.cpp b/src/plugins/intel_gna/src/gna_plugin_query_api.cpp index 60e6124749e..6287f887e16 100644 --- a/src/plugins/intel_gna/src/gna_plugin_query_api.cpp +++ b/src/plugins/intel_gna/src/gna_plugin_query_api.cpp @@ -13,7 +13,6 @@ #include #include -using namespace GNAPluginNS; using namespace InferenceEngine; using namespace InferenceEngine::PluginConfigParams; diff --git a/src/plugins/intel_gna/src/gna_slope_scale.cpp b/src/plugins/intel_gna/src/gna_slope_scale.cpp index 4cb00c4002f..ccce302f701 100644 --- a/src/plugins/intel_gna/src/gna_slope_scale.cpp +++ b/src/plugins/intel_gna/src/gna_slope_scale.cpp @@ -5,7 +5,7 @@ #include #include -#include "gna_slope_scale.h" +#include "gna_slope_scale.hpp" pwl_gna_slope_scale_t gna_slope(const double slope, const double in_scale, diff --git a/src/plugins/intel_gna/src/gna_slope_scale.h b/src/plugins/intel_gna/src/gna_slope_scale.hpp similarity index 100% rename from src/plugins/intel_gna/src/gna_slope_scale.h rename to src/plugins/intel_gna/src/gna_slope_scale.hpp diff --git a/src/plugins/intel_gna/src/gna_tensor_tools.hpp b/src/plugins/intel_gna/src/gna_tensor_tools.hpp index 941b27e36c0..5e709ef8ca2 100644 --- a/src/plugins/intel_gna/src/gna_tensor_tools.hpp +++ b/src/plugins/intel_gna/src/gna_tensor_tools.hpp @@ -5,7 +5,8 @@ #include #include "gna_data_types.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { /** * @brief convert a tensor or its parts from NCHW to NHWC order on the base of transposition information. @@ -79,4 +80,5 @@ inline void ConvertTensorFromNCHWToNHWC(size_t precision, size_t rows, size_t co } } -} // namespace GNAPluginNS \ No newline at end of file +} // namespace intel_gna +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_gna/src/gna_upstream_iterator.hpp b/src/plugins/intel_gna/src/gna_upstream_iterator.hpp index 895773855ed..c4f511ddb2b 100644 --- a/src/plugins/intel_gna/src/gna_upstream_iterator.hpp +++ b/src/plugins/intel_gna/src/gna_upstream_iterator.hpp @@ -9,7 +9,9 @@ #include #include "gna_graph_tools.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + /** * @brief implements upstream search for BFS routine */ @@ -113,5 +115,5 @@ inline UpstreamLayersContainer make_upstream_order(InferenceEngine::CNNLayer* or return fusedCnt; } - -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/layers/gna_concat_layer.hpp b/src/plugins/intel_gna/src/layers/gna_concat_layer.hpp index fd18323c340..a051151ac84 100644 --- a/src/plugins/intel_gna/src/layers/gna_concat_layer.hpp +++ b/src/plugins/intel_gna/src/layers/gna_concat_layer.hpp @@ -9,7 +9,9 @@ #include -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + class GNAConcatLayer { InferenceEngine::CNNLayerPtr concatLayer; @@ -46,4 +48,6 @@ public: std::vector concatInputLayers; }; -} // namespace GNAPluginNS + +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/layers/gna_convolution_layer.cpp b/src/plugins/intel_gna/src/layers/gna_convolution_layer.cpp index 5b88ba3f47a..ae1ec81cd14 100644 --- a/src/plugins/intel_gna/src/layers/gna_convolution_layer.cpp +++ b/src/plugins/intel_gna/src/layers/gna_convolution_layer.cpp @@ -14,8 +14,10 @@ #include "gna_graph_tools.hpp" #include "log/debug.hpp" -namespace GNAPluginNS { -namespace GNAConvolutionLayer { +namespace ov { +namespace intel_gna { +namespace gna_convolution_layer { + bool should_transpose_h_w(const uint32_t in_height, const uint32_t kernel_height, const uint32_t in_channels, @@ -23,9 +25,13 @@ bool should_transpose_h_w(const uint32_t in_height, return in_height == kernel_height && in_channels == 1 && stride_height == 1; } -bool isMappableFrom2DTo1D(const uint32_t inHeight, const uint32_t inWidth, const uint32_t in_channels, - const uint32_t kernelHeight, const uint32_t kernelWidth, - const uint32_t strideHeight, const uint32_t strideWidth) { +bool isMappableFrom2DTo1D(const uint32_t inHeight, + const uint32_t inWidth, + const uint32_t in_channels, + const uint32_t kernelHeight, + const uint32_t kernelWidth, + const uint32_t strideHeight, + const uint32_t strideWidth) { if (inHeight <= 1 || inWidth <= 1) { // Mapping not needed since input is already 1D return false; @@ -34,8 +40,11 @@ bool isMappableFrom2DTo1D(const uint32_t inHeight, const uint32_t inWidth, const should_transpose_h_w(inHeight, kernelHeight, in_channels, strideHeight); } -bool is3DInputOr2DKernel(const uint32_t inHeight, const uint32_t inWidth, const uint32_t inDepth, - const uint32_t kernelHeight, const uint32_t kernelWidth) { +bool is3DInputOr2DKernel(const uint32_t inHeight, + const uint32_t inWidth, + const uint32_t inDepth, + const uint32_t kernelHeight, + const uint32_t kernelWidth) { return (kernelHeight > 1 && kernelWidth > 1) || (inHeight > 1 && inWidth > 1 && inDepth > 1); } @@ -46,18 +55,27 @@ double getWeightsReducer(InferenceEngine::ConvolutionLayer& conv) { // for kernelSize >= 14 -> 1.7 // for kernelSize >= 9 -> 1.3 // for kernelSize in {7, 8} -> 1.2 - const std::vector< KRT > reducers{ {49, 3.0}, {36, 2.6}, {21, 2.3}, {14, 1.7}, {9, 1.3}, {7, 1.2} }; + const std::vector reducers{{49, 3.0}, {36, 2.6}, {21, 2.3}, {14, 1.7}, {9, 1.3}, {7, 1.2}}; auto reducer = 1.0; - const auto inDepth = InferenceEngine::GetDataDimByName(conv.insData.front().lock(), InferenceEngine::DataDimName::C); + const auto inDepth = + InferenceEngine::GetDataDimByName(conv.insData.front().lock(), InferenceEngine::DataDimName::C); const auto inHeight = InferenceEngine::GetDataDimByName(conv.insData.front().lock(), InferenceEngine::DataDimName::H); const auto inWidth = InferenceEngine::GetDataDimByName(conv.insData.front().lock(), InferenceEngine::DataDimName::W); if (is3DInputOr2DKernel(inHeight, inWidth, inDepth, conv._kernel_y, conv._kernel_x) && - !isMappableFrom2DTo1D(inHeight, inWidth, inDepth, conv._kernel_y, conv._kernel_x, conv._stride_y, conv._stride_x)) { + !isMappableFrom2DTo1D(inHeight, + inWidth, + inDepth, + conv._kernel_y, + conv._kernel_x, + conv._stride_y, + conv._stride_x)) { const auto kernelSize = conv._kernel_x * conv._kernel_y; - auto r = std::lower_bound(reducers.begin(), reducers.end(), kernelSize, - [](const KRT& l, const KRT::first_type& r) {return l.first > r; }); + auto r = + std::lower_bound(reducers.begin(), reducers.end(), kernelSize, [](const KRT& l, const KRT::first_type& r) { + return l.first > r; + }); if (r != reducers.end()) reducer = r->second; } @@ -80,7 +98,8 @@ uint32_t outputFromPooling(const uint32_t in, const uint32_t window, const uint3 if (window > in || window == 0 || stride == 0) { THROW_GNA_EXCEPTION << "Invalid (input, window, stride) = (" << in << "," << window << "," << stride << ")"; } - if (window == in) return 1; + if (window == in) + return 1; return (in - window - 1) / stride + 2; } @@ -94,5 +113,6 @@ uint32_t outputFromPoolingLegacy(const uint32_t in, const uint32_t stride) { return (in - 1) / stride + 1; } -} // namespace GNAConvolutionLayer -} // namespace GNAPluginNS +} // namespace gna_convolution_layer +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/layers/gna_convolution_layer.hpp b/src/plugins/intel_gna/src/layers/gna_convolution_layer.hpp index a733a2c04c3..656cfb1a449 100644 --- a/src/plugins/intel_gna/src/layers/gna_convolution_layer.hpp +++ b/src/plugins/intel_gna/src/layers/gna_convolution_layer.hpp @@ -8,20 +8,28 @@ #include -namespace GNAPluginNS { -namespace GNAConvolutionLayer { +namespace ov { +namespace intel_gna { +namespace gna_convolution_layer { bool should_transpose_h_w(const uint32_t in_height, const uint32_t kernel_height, const uint32_t in_channels, const uint32_t stride_height); -bool isMappableFrom2DTo1D(const uint32_t inHeight, const uint32_t inWidth, const uint32_t inChannels, - const uint32_t kernelHeight, const uint32_t kernelWidth, - const uint32_t strideHeight, const uint32_t strideWidth); +bool isMappableFrom2DTo1D(const uint32_t inHeight, + const uint32_t inWidth, + const uint32_t inChannels, + const uint32_t kernelHeight, + const uint32_t kernelWidth, + const uint32_t strideHeight, + const uint32_t strideWidth); -bool is3DInputOr2DKernel(const uint32_t inHeight, const uint32_t inWidth, const uint32_t inDepth, - const uint32_t kernelHeight, const uint32_t kernelWidth); +bool is3DInputOr2DKernel(const uint32_t inHeight, + const uint32_t inWidth, + const uint32_t inDepth, + const uint32_t kernelHeight, + const uint32_t kernelWidth); double getWeightsReducer(InferenceEngine::ConvolutionLayer& conv); @@ -31,5 +39,6 @@ uint32_t outputFromPooling(const uint32_t in, const uint32_t window, const uint3 uint32_t outputFromPoolingLegacy(const uint32_t in, const uint32_t stride); -} // namespace GNAConvolutionLayer -} // namespace GNAPluginNS +} // namespace gna_convolution_layer +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/layers/gna_copy_layer.hpp b/src/plugins/intel_gna/src/layers/gna_copy_layer.hpp index 8d1d1170c24..f10b4b71101 100644 --- a/src/plugins/intel_gna/src/layers/gna_copy_layer.hpp +++ b/src/plugins/intel_gna/src/layers/gna_copy_layer.hpp @@ -4,7 +4,9 @@ #pragma once -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + /** * GNA primitive created in sorting order for this copy layer */ @@ -14,4 +16,5 @@ static constexpr auto CopyLayerName = "Copy"; */ static constexpr auto DelayedCopyLayerName = "DelayedCopy"; -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/layers/gna_crop_layer.cpp b/src/plugins/intel_gna/src/layers/gna_crop_layer.cpp index b10c16619af..6c2727d74b5 100644 --- a/src/plugins/intel_gna/src/layers/gna_crop_layer.cpp +++ b/src/plugins/intel_gna/src/layers/gna_crop_layer.cpp @@ -7,9 +7,8 @@ #include "log/log.hpp" #include "log/debug.hpp" -using namespace ov::intel_gna; - -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { SimpleCrop get_crop_params(const std::vector& axis_in, const std::vector& offset_in, @@ -57,4 +56,5 @@ SimpleCrop GetCropParams(InferenceEngine::CropLayer* cropLayer) { return out_val; } -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/layers/gna_crop_layer.hpp b/src/plugins/intel_gna/src/layers/gna_crop_layer.hpp index 0472839ac3f..48a388cf7fd 100644 --- a/src/plugins/intel_gna/src/layers/gna_crop_layer.hpp +++ b/src/plugins/intel_gna/src/layers/gna_crop_layer.hpp @@ -8,7 +8,9 @@ #include #include -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + class GNACropLayer { InferenceEngine::CNNLayerPtr cropLayer; @@ -41,4 +43,5 @@ SimpleCrop get_crop_params(const std::vector& axis_in, SimpleCrop GetCropParams(InferenceEngine::CropLayer* cropLayer); -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/layers/gna_fake_quantize_layer.hpp b/src/plugins/intel_gna/src/layers/gna_fake_quantize_layer.hpp index 3e6609dee1a..66de149ed89 100644 --- a/src/plugins/intel_gna/src/layers/gna_fake_quantize_layer.hpp +++ b/src/plugins/intel_gna/src/layers/gna_fake_quantize_layer.hpp @@ -12,12 +12,14 @@ using ov::intel_gna::frontend::make_fp32_blob; -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + class GNAFakeQuantizeLayer { InferenceEngine::CNNLayerPtr fqLayer; - public : - GNAFakeQuantizeLayer(InferenceEngine::CNNLayerPtr fqLayer) - : fqLayer(fqLayer) { + +public: + GNAFakeQuantizeLayer(InferenceEngine::CNNLayerPtr fqLayer) : fqLayer(fqLayer) { if (!LayerInfo(fqLayer).isFakeQuantize()) { THROW_GNA_LAYER_EXCEPTION(fqLayer) << "cannot parse as fake quantize"; } @@ -30,7 +32,7 @@ class GNAFakeQuantizeLayer { DnnActivation fqActivation{}; fqActivation.fqParams.levels = fqLayer->GetParamAsSizeT("levels"); - auto inputShape = getShapeForRange(fqLayer, 1); + auto inputShape = getShapeForRange(fqLayer, 1); auto outputShape = getShapeForRange(fqLayer, 3); // TODO: check shapes broadcasting to shape of input at 0 @@ -40,26 +42,27 @@ class GNAFakeQuantizeLayer { fqActivation.fqParams.set = true; fqActivation.fqParams.inputPerChannel = inputRangeSize != 1; - fqActivation.fqParams.input_low = getParamFromInputAsFloats(fqLayer, 1); - fqActivation.fqParams.input_high = getParamFromInputAsFloats(fqLayer, 2); + fqActivation.fqParams.input_low = getParamFromInputAsFloats(fqLayer, 1); + fqActivation.fqParams.input_high = getParamFromInputAsFloats(fqLayer, 2); fqActivation.fqParams.outputPerChannel = outputRangeSize != 1; - fqActivation.fqParams.output_low = getParamFromInputAsFloats(fqLayer, 3); + fqActivation.fqParams.output_low = getParamFromInputAsFloats(fqLayer, 3); fqActivation.fqParams.output_high = getParamFromInputAsFloats(fqLayer, 4); fqActivation.type = kActFakeQuantize; return fqActivation; - } + } /** * @brief Retrieve input blob for FQ layer that connected to const layer */ InferenceEngine::Blob::Ptr getConstInputData() const { - return LayerUtils::getParamFromInputAsBlob(fqLayer, 0); + return layer_utils::getParamFromInputAsBlob(fqLayer, 0); } /** - * @brief Fake quantize has 5 input layers, while 4 of them always constant layer, and 1 might be a tensor - connection + * @brief Fake quantize has 5 input layers, while 4 of them always constant layer, and 1 might be a tensor - + * connection */ InferenceEngine::CNNLayerPtr getInputLayer() const { return getInputLayerAt(fqLayer, 0); @@ -77,24 +80,24 @@ class GNAFakeQuantizeLayer { return getRange(fqLayer, 3); } - operator InferenceEngine::CNNLayerPtr () const { + operator InferenceEngine::CNNLayerPtr() const { return fqLayer; } - InferenceEngine::CNNLayerPtr operator -> () const { + InferenceEngine::CNNLayerPtr operator->() const { return fqLayer; } - InferenceEngine::CNNLayerPtr operator * () const { + InferenceEngine::CNNLayerPtr operator*() const { return fqLayer; } - protected : +protected: static std::pair, std::vector> getRange(InferenceEngine::CNNLayerPtr input, size_t idx) { - auto shape = getShapeForRange(input, idx); + auto shape = getShapeForRange(input, idx); auto rangeSize = InferenceEngine::details::product(shape.begin(), shape.end()); - auto dataMin = LayerUtils::getParamFromInputAsBlob(input, idx); - auto dataMax = LayerUtils::getParamFromInputAsBlob(input, idx + 1); + auto dataMin = layer_utils::getParamFromInputAsBlob(input, idx); + auto dataMax = layer_utils::getParamFromInputAsBlob(input, idx + 1); std::vector minValues(rangeSize), maxValues(rangeSize); switch (dataMin->getTensorDesc().getPrecision()) { case InferenceEngine::Precision::FP32: { @@ -112,46 +115,46 @@ class GNAFakeQuantizeLayer { } default: THROW_GNA_LAYER_EXCEPTION(input) << "cannot cast custom blob to type FP32, since it is of type: " - << dataMin->getTensorDesc().getPrecision(); + << dataMin->getTensorDesc().getPrecision(); break; } return {minValues, maxValues}; } - static float* getParamFromInputAsFloats(InferenceEngine::CNNLayerPtr input, size_t idx) { - auto data = LayerUtils::getParamFromInputAsBlob(input, idx); + static float* getParamFromInputAsFloats(InferenceEngine::CNNLayerPtr input, size_t idx) { + auto data = layer_utils::getParamFromInputAsBlob(input, idx); if (data->getTensorDesc().getPrecision() != InferenceEngine::Precision::FP32) { THROW_GNA_LAYER_EXCEPTION(input) << "cannot cast custom blob to type FP32, since it is of type: " - << data->getTensorDesc().getPrecision(); + << data->getTensorDesc().getPrecision(); } return data->buffer().as(); } - static InferenceEngine::SizeVector getShapeFromInput(InferenceEngine::CNNLayerPtr input, size_t idx) { - auto data = LayerUtils::getParamFromInputAsBlob(input, idx); + static InferenceEngine::SizeVector getShapeFromInput(InferenceEngine::CNNLayerPtr input, size_t idx) { + auto data = layer_utils::getParamFromInputAsBlob(input, idx); return data->getTensorDesc().getDims(); } - static InferenceEngine::CNNLayerPtr getInputLayerAt(InferenceEngine::CNNLayerPtr input, size_t idx) { + static InferenceEngine::CNNLayerPtr getInputLayerAt(InferenceEngine::CNNLayerPtr input, size_t idx) { if (input->insData.size() <= idx) { THROW_GNA_LAYER_EXCEPTION(input) << "cannot get data from " << idx << "input"; } auto iLayerData = input->insData[idx].lock(); if (!iLayerData) { - THROW_GNA_LAYER_EXCEPTION(input) << "cannot get data from " << idx - << ", input: cannot dereference data weak-pointer"; + THROW_GNA_LAYER_EXCEPTION(input) + << "cannot get data from " << idx << ", input: cannot dereference data weak-pointer"; } auto iLayer = getCreatorLayer(iLayerData).lock(); if (!iLayer) { - THROW_GNA_LAYER_EXCEPTION(input) << "cannot get data from " << idx - << ", input: cannot dereference creator layer weak-pointer"; + THROW_GNA_LAYER_EXCEPTION(input) + << "cannot get data from " << idx << ", input: cannot dereference creator layer weak-pointer"; } return iLayer; } static InferenceEngine::SizeVector getShapeForRange(InferenceEngine::CNNLayerPtr input, size_t idx) { - auto lowShape = getShapeFromInput(input, idx); + auto lowShape = getShapeFromInput(input, idx); auto highShape = getShapeFromInput(input, idx + 1); if (lowShape.size() != highShape.size()) { THROW_GNA_LAYER_EXCEPTION(input) << "shapes mismatch for " << idx << " and " << idx + 1 << " inputs"; @@ -162,6 +165,8 @@ class GNAFakeQuantizeLayer { } } return lowShape; - } + } }; -} // namespace GNAPluginNS + +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/layers/gna_layer_helpers.hpp b/src/plugins/intel_gna/src/layers/gna_layer_helpers.hpp index 5601b71a519..baf41102722 100644 --- a/src/plugins/intel_gna/src/layers/gna_layer_helpers.hpp +++ b/src/plugins/intel_gna/src/layers/gna_layer_helpers.hpp @@ -6,8 +6,10 @@ #include "gna_layer_info.hpp" -namespace GNAPluginNS { -namespace LayerUtils { +namespace ov { +namespace intel_gna { +namespace layer_utils { + /** * @brief retrievs blob from const layer connected to certain layer * @param input @@ -38,5 +40,7 @@ inline InferenceEngine::Blob::Ptr getParamFromInputAsBlob(InferenceEngine::CNNLa return iLayer->blobs["custom"]; } -} // namespace LayerUtils -} // namespace GNAPluginNS + +} // namespace layer_utils +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/layers/gna_layer_info.hpp b/src/plugins/intel_gna/src/layers/gna_layer_info.hpp index 454a080abf2..52068d2677c 100644 --- a/src/plugins/intel_gna/src/layers/gna_layer_info.hpp +++ b/src/plugins/intel_gna/src/layers/gna_layer_info.hpp @@ -10,7 +10,7 @@ #include #include "caseless.hpp" #include "ie_algorithm.hpp" -#include "backend/gna_types.h" +#include "backend/gna_types.hpp" #include "gna_permute.hpp" #include "gna_lib_ver_selector.hpp" #include "gna_copy_layer.hpp" @@ -21,7 +21,8 @@ #include "backend/gna_limitations.hpp" #include "transformations/rt_info/gna_transpose_fusable.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { /** * @brief detecting of const pointer for dynamic cast operations @@ -321,7 +322,7 @@ class LayerInfo { auto inputs = layer->insData.begin()->lock(); auto inputsOrder = inputs->getTensorDesc().getDims(); - return GNAPluginNS::isTrivialPermute(std::vector{begin(layerOrder), end(layerOrder)}, + return permute::isTrivialPermute(std::vector{begin(layerOrder), end(layerOrder)}, inputsOrder); } bool isNonValuesChangable() const { @@ -356,7 +357,7 @@ class LayerInfo { auto cropLayer = dynamic_cast (layer); if (cropLayer != nullptr && !cropLayer->offset.empty()) { const auto crop_params = GetCropParams(cropLayer); - return GNAPluginNS::GNALimitations::isCropAffinedOffset(crop_params.start_offset); + return limitations::isCropAffinedOffset(crop_params.start_offset); } return false; } @@ -425,4 +426,5 @@ inline std::ostream & operator <<(std::ostream &os, const LayerInfo & info) { return os; } -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/layers/gna_layer_type.cpp b/src/plugins/intel_gna/src/layers/gna_layer_type.cpp index 038578c6bca..6a997ea0ed0 100644 --- a/src/plugins/intel_gna/src/layers/gna_layer_type.cpp +++ b/src/plugins/intel_gna/src/layers/gna_layer_type.cpp @@ -8,10 +8,16 @@ #include "gna_layer_type.hpp" #include "gna_layer_info.hpp" -GNAPluginNS::LayerType GNAPluginNS::LayerTypeFromStr(const std::string &str) { +namespace ov { +namespace intel_gna { + +LayerType LayerTypeFromStr(const std::string& str) { auto it = LayerNameToType.find(str); if (it != LayerNameToType.end()) return it->second; else return LayerType::NO_TYPE; } + +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/layers/gna_layer_type.hpp b/src/plugins/intel_gna/src/layers/gna_layer_type.hpp index b9549157ea4..29ee78ce16d 100644 --- a/src/plugins/intel_gna/src/layers/gna_layer_type.hpp +++ b/src/plugins/intel_gna/src/layers/gna_layer_type.hpp @@ -9,9 +9,11 @@ #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" + +namespace ov { +namespace intel_gna { -namespace GNAPluginNS { enum class LayerType { Input, Convolution, @@ -54,7 +56,7 @@ enum class LayerType { NO_TYPE }; -static const InferenceEngine::details::caseless_map LayerNameToType = { +static const InferenceEngine::details::caseless_map LayerNameToType = { { "Input" , LayerType::Input }, { "Convolution" , LayerType::Convolution }, { "ReLU" , LayerType::ReLU }, @@ -94,5 +96,7 @@ static const InferenceEngine::details::caseless_map class PermuteSequence { public: @@ -20,14 +23,14 @@ private: cnt_type permutes; public: - explicit PermuteSequence(std::vector && orderVecIn) : orderVec(std::move(orderVecIn)) { + explicit PermuteSequence(std::vector&& orderVecIn) : orderVec(std::move(orderVecIn)) { std::vector counter(orderVec.size()); - for (auto && x : this->orderVec) { + for (auto&& x : this->orderVec) { if (x < 0) { THROW_GNA_EXCEPTION << "invalid order: element " << x << " should be >= 0"; } if (x >= counter.size()) { - THROW_GNA_EXCEPTION << "invalid order: element " << x << " should be < "<< counter.size(); + THROW_GNA_EXCEPTION << "invalid order: element " << x << " should be < " << counter.size(); } if (counter[x]) { THROW_GNA_EXCEPTION << "invalid order: element " << x << " present more than once"; @@ -65,13 +68,13 @@ public: i++; } - for (auto && cycle : permuteCycles) { + for (auto&& cycle : permuteCycles) { for (int i = 0; i + 1 < cycle.size(); i++) { permutes.push_back(cycle[i]); } } } - const cnt_type & cnt() const noexcept { + const cnt_type& cnt() const noexcept { return permutes; } }; @@ -83,22 +86,22 @@ public: */ template inline typename PermuteSequence::value_type>::cnt_type genPermutations( - Iterator beg, Iterator en) { - static_assert( - std::is_same::iterator_category>::value, - "The genPermutations() function only accepts random access iterators or raw pointers to an array.\n"); + Iterator beg, + Iterator en) { + static_assert(std::is_same::iterator_category>::value, + "The genPermutations() function only accepts random access iterators or raw pointers to an array.\n"); using value_type = typename std::iterator_traits::value_type; std::vector v; for (; beg != en; beg++) { v.push_back(*beg); } - auto permute = PermuteSequence (std::move(v)); + auto permute = PermuteSequence(std::move(v)); return permute.cnt(); } template -inline typename PermuteSequence::cnt_type genPermutations(const std::initializer_list & lst) { +inline typename PermuteSequence::cnt_type genPermutations(const std::initializer_list& lst) { return genPermutations(lst.begin(), lst.end()); } @@ -121,14 +124,12 @@ inline bool isTrivialPermute(const std::vector order, const std::vector // cases when all permutations happened either between 1 and X shape where no other dims in between auto transpose_seq = genPermutations(order.begin(), order.end()); auto input_order_transformed = input_shape; - for (auto && transp : transpose_seq) { + for (auto&& transp : transpose_seq) { // check dims of transposed - if (input_order_transformed[transp.first] == 1 && - input_order_transformed[transp.second] == 1) { + if (input_order_transformed[transp.first] == 1 && input_order_transformed[transp.second] == 1) { return true; } - if (input_order_transformed[transp.first] != 1 && - input_order_transformed[transp.second] != 1) { + if (input_order_transformed[transp.first] != 1 && input_order_transformed[transp.second] != 1) { return false; } // check dims in between @@ -143,4 +144,6 @@ inline bool isTrivialPermute(const std::vector order, const std::vector return true; } -} // namespace GNAPluginNS +} // namespace permute +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/layers/gna_split_layer.hpp b/src/plugins/intel_gna/src/layers/gna_split_layer.hpp index 44edbe75f1a..0da4204c0c0 100644 --- a/src/plugins/intel_gna/src/layers/gna_split_layer.hpp +++ b/src/plugins/intel_gna/src/layers/gna_split_layer.hpp @@ -9,7 +9,9 @@ #include #include "backend/gna_limitations.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + // Split, Slice class GNASplitLayer { InferenceEngine::CNNLayerPtr splitLayer; @@ -48,7 +50,7 @@ public: }; // @brief Returns sizes of split outputs to split the input tensor to aligned parts not greater than the specified size -static std::vector GetAlignedSplitSizes(uint32_t totalSize, uint32_t maxSplitSize, uint32_t alignment = GNALimitations::inputByteAlignment) { +static std::vector GetAlignedSplitSizes(uint32_t totalSize, uint32_t maxSplitSize, uint32_t alignment = limitations::inputByteAlignment) { std::vector splitSizes; uint32_t maxAlignedSplitSize = std::max(maxSplitSize - maxSplitSize % alignment, alignment); uint32_t usedSize = 0; @@ -68,7 +70,7 @@ static std::pair> AlignedSplitSizesPerAxis(Infere IE_ASSERT(firstValuableDim != std::end(dims)); auto splittedElementsSize = *firstValuableDim; auto splittedDimIx = std::distance(std::begin(dims), firstValuableDim); - auto alignment = GNALimitations::inputByteAlignment; + auto alignment = limitations::inputByteAlignment; // Split output size should be multiple by 64 to avoid align filters insertion, // but we need to check if our input size to split exceeds 64; if not we can always @@ -81,8 +83,9 @@ static std::pair> AlignedSplitSizesPerAxis(Infere } } splitSizes = GetAlignedSplitSizes(splittedElementsSize, - GNALimitations::bufferMaxSize * splittedElementsSize / totalElementsSize, alignment); + limitations::bufferMaxSize * splittedElementsSize / totalElementsSize, alignment); return {splittedDimIx, splitSizes}; } -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/layers/layers_builder.hpp b/src/plugins/intel_gna/src/layers/layers_builder.hpp index f5858ddea5d..f00e21155df 100644 --- a/src/plugins/intel_gna/src/layers/layers_builder.hpp +++ b/src/plugins/intel_gna/src/layers/layers_builder.hpp @@ -11,7 +11,9 @@ #include #include "gna_graph_compiler.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + class LayersBuilder { using CreatorFnc = std::function; @@ -26,4 +28,6 @@ public: return LayerBuilder; } }; -} // namespace GNAPluginNS + +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/memory/gna_allocator.hpp b/src/plugins/intel_gna/src/memory/gna_allocator.hpp index df12e90bfe3..e4b2cd27d8f 100644 --- a/src/plugins/intel_gna/src/memory/gna_allocator.hpp +++ b/src/plugins/intel_gna/src/memory/gna_allocator.hpp @@ -12,7 +12,8 @@ #include "gna_device.hpp" #include "memory/gna_mem_requests.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace memory { /** * wrap GNA interface into c++ allocator friendly one @@ -35,9 +36,11 @@ class GNAAllocator { void deallocate(uint8_t *p, std::size_t n) { _device->free(p); } - void setTag(void* memPtr, GNAPluginNS::memory::rRegion tagValue) { + void setTag(void* memPtr, memory::rRegion tagValue) { _device->tagMemoryRegion(memPtr, tagValue); } }; + } // namespace memory -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/memory/gna_mem_regions.hpp b/src/plugins/intel_gna/src/memory/gna_mem_regions.hpp index a15b5e0a0b4..9861aa41cb9 100644 --- a/src/plugins/intel_gna/src/memory/gna_mem_regions.hpp +++ b/src/plugins/intel_gna/src/memory/gna_mem_regions.hpp @@ -9,7 +9,8 @@ #include "log/debug.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace memory { /** @@ -47,4 +48,5 @@ inline std::string rRegionToStr(const rRegion region) { } } // namespace memory -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/memory/gna_mem_requests.hpp b/src/plugins/intel_gna/src/memory/gna_mem_requests.hpp index 286ce730631..50a2459de8b 100644 --- a/src/plugins/intel_gna/src/memory/gna_mem_requests.hpp +++ b/src/plugins/intel_gna/src/memory/gna_mem_requests.hpp @@ -10,7 +10,8 @@ #include "gna_mem_regions.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace memory { enum rType : uint8_t { @@ -126,5 +127,7 @@ struct MemRequest { _initializer(initializer) { } }; + } // namespace memory -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/memory/gna_mem_requests_queue.hpp b/src/plugins/intel_gna/src/memory/gna_mem_requests_queue.hpp index 944e95e26b9..7c1173126d0 100644 --- a/src/plugins/intel_gna/src/memory/gna_mem_requests_queue.hpp +++ b/src/plugins/intel_gna/src/memory/gna_mem_requests_queue.hpp @@ -19,7 +19,8 @@ using namespace ov::intel_gna; -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace memory { /** @@ -200,7 +201,7 @@ public: } template - void iterate_binded(GNAPluginNS::memory::MemRequest & reference, const T & visitor) { + void iterate_binded(memory::MemRequest & reference, const T & visitor) { for (auto &re : _mem_requests) { if ((re._type & REQUEST_BIND) && (re._ptr_in == reference._ptr_out)) { log::trace() << " [binded=" << re._type << ", ptr=" << re._ptr_out <<"]\n"; @@ -284,4 +285,5 @@ public: }; } // namespace memory -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/memory/gna_memory.hpp b/src/plugins/intel_gna/src/memory/gna_memory.hpp index ac67ae9ca37..91389acc961 100644 --- a/src/plugins/intel_gna/src/memory/gna_memory.hpp +++ b/src/plugins/intel_gna/src/memory/gna_memory.hpp @@ -26,12 +26,13 @@ #include #endif -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace memory { class GNAFloatAllocator : public std::allocator < uint8_t > { public: - void setTag(void*, GNAPluginNS::memory::rRegion) { + void setTag(void*, memory::rRegion) { } }; @@ -154,7 +155,7 @@ protected: } template - void iterate_binded(GNAPluginNS::memory::MemRequest & reference, const T & visitor) { + void iterate_binded(memory::MemRequest & reference, const T & visitor) { for (auto &re : getQueue(REGION_AUTO)->_mem_requests) { if ((re._type & REQUEST_BIND) && (re._ptr_in == reference._ptr_out)) { // log::trace() << " [binded=" << rTypeToStr(re._type) << ", ptr=" << re._ptr_out <<"]\n"; @@ -291,4 +292,5 @@ protected: }; } // namespace memory -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/memory/gna_memory_state.cpp b/src/plugins/intel_gna/src/memory/gna_memory_state.cpp index ad33692a584..cb90eb80dd6 100644 --- a/src/plugins/intel_gna/src/memory/gna_memory_state.cpp +++ b/src/plugins/intel_gna/src/memory/gna_memory_state.cpp @@ -8,123 +8,127 @@ #include "ie_layouts.h" #include "gna_graph_tools.hpp" -namespace GNAPluginNS { - +namespace ov { +namespace intel_gna { namespace memory { - void GNAVariableState::Reset() { - state->Reset(); - } +void GNAVariableState::Reset() { + state->Reset(); +} - InferenceEngine::Precision GNAVariableState::getPrecision() const { - InferenceEngine::Precision state_precision; +InferenceEngine::Precision GNAVariableState::getPrecision() const { + InferenceEngine::Precision state_precision; - if (state->getInput()) { - state_precision = state->getInput()->precision; - } else { - auto element_size = state->elementSizeBytes(); - switch (element_size) { - case 4: - state_precision = InferenceEngine::Precision::FP32; - break; - case 2: - state_precision = InferenceEngine::Precision::I16; - break; - default: - THROW_GNA_EXCEPTION << "Incorrect state element size " << element_size << - " to determine precision for VariableState " << name; - } - } - - return state_precision; - } - - void GNAVariableState::SetState(const InferenceEngine::Blob::Ptr& newState) { - IE_ASSERT(newState != nullptr); - - auto data_ptr = newState->cbuffer().as(); - IE_ASSERT(data_ptr != nullptr); - auto data_size = newState->byteSize(); - auto data_elements = data_size / newState->element_size(); - if (ALIGN64(state->reserved_size) != ALIGN64((data_size / (newState->element_size() / state->elementSizeBytes())))) { - THROW_GNA_EXCEPTION << "Failed to SetState. Sizes of new and old states do not match. (" - << state->reserved_size << " != " << (newState->element_size() / state->elementSizeBytes()) << ")"; - } - - InferenceEngine::Precision state_precision = getPrecision(); - auto new_state_precision = newState->getTensorDesc().getPrecision(); - - if (state->gna_ptr == data_ptr) { - return; - } - - if (new_state_precision == state_precision) { - std::memcpy(state->gna_ptr, data_ptr, data_size); - return; - } - - switch (state_precision) { - case InferenceEngine::Precision::I16: { - if (new_state_precision == InferenceEngine::Precision::FP32) { - auto quantized = - InferenceEngine::getInjectedData(state->getInput()); - auto scale_factor = quantized != nullptr ? quantized->_dst_quant.GetScale() : state->scale_factor; - GNAPluginNS::ConvertToInt16(static_cast(state->gna_ptr), - newState->buffer().as(), - 1, - data_elements, - scale_factor); - } else { - THROW_GNA_EXCEPTION << "Failed to SetState for VariableState " << name - << ". If old state precision is I16 only I16 and FP32 are allowed as new state precisions." - << " Old state: " << state_precision << " New state: " << new_state_precision; - } + if (state->getInput()) { + state_precision = state->getInput()->precision; + } else { + auto element_size = state->elementSizeBytes(); + switch (element_size) { + case 4: + state_precision = InferenceEngine::Precision::FP32; + break; + case 2: + state_precision = InferenceEngine::Precision::I16; break; - } default: - THROW_GNA_EXCEPTION << "Failed to SetState for VariableState " << name - << ". Incorrect new/old precision pair" - << " Old state: " << state_precision << " New state: " << new_state_precision; + THROW_GNA_EXCEPTION << "Incorrect state element size " << element_size + << " to determine precision for VariableState " << name; } } - InferenceEngine::Blob::CPtr GNAVariableState::GetState() const { - auto elements = state->reserved_size / state->elementSizeBytes(); - InferenceEngine::Precision state_precision = getPrecision(); + return state_precision; +} - if (state->getInput() && state_precision == InferenceEngine::Precision::I16) { +void GNAVariableState::SetState(const InferenceEngine::Blob::Ptr& newState) { + IE_ASSERT(newState != nullptr); + + auto data_ptr = newState->cbuffer().as(); + IE_ASSERT(data_ptr != nullptr); + auto data_size = newState->byteSize(); + auto data_elements = data_size / newState->element_size(); + if (ALIGN64(state->reserved_size) != + ALIGN64((data_size / (newState->element_size() / state->elementSizeBytes())))) { + THROW_GNA_EXCEPTION << "Failed to SetState. Sizes of new and old states do not match. (" << state->reserved_size + << " != " << (newState->element_size() / state->elementSizeBytes()) << ")"; + } + + InferenceEngine::Precision state_precision = getPrecision(); + auto new_state_precision = newState->getTensorDesc().getPrecision(); + + if (state->gna_ptr == data_ptr) { + return; + } + + if (new_state_precision == state_precision) { + std::memcpy(state->gna_ptr, data_ptr, data_size); + return; + } + + switch (state_precision) { + case InferenceEngine::Precision::I16: { + if (new_state_precision == InferenceEngine::Precision::FP32) { auto quantized = InferenceEngine::getInjectedData(state->getInput()); auto scale_factor = quantized != nullptr ? quantized->_dst_quant.GetScale() : state->scale_factor; - - auto result_blob = make_blob_with_precision(InferenceEngine::TensorDesc(InferenceEngine::Precision::FP32, - InferenceEngine::SizeVector({ 1, elements }), - InferenceEngine::NC)); - - result_blob->allocate(); - auto buffer = result_blob->buffer().as(); - auto new_gna_ptr = static_cast(state->gna_ptr); - - for (int i = 0; i < elements; i++) { - buffer[i] = new_gna_ptr[i] / scale_factor; - } - - return result_blob; + ConvertToInt16(static_cast(state->gna_ptr), + newState->buffer().as(), + 1, + data_elements, + scale_factor); } else { - auto result_blob = make_blob_with_precision(InferenceEngine::TensorDesc(state_precision, - InferenceEngine::SizeVector({ 1, elements }), - InferenceEngine::NC)); - result_blob->allocate(); - std::memcpy(result_blob->buffer(), state->gna_ptr, state->reserved_size); - return result_blob; + THROW_GNA_EXCEPTION + << "Failed to SetState for VariableState " << name + << ". If old state precision is I16 only I16 and FP32 are allowed as new state precisions." + << " Old state: " << state_precision << " New state: " << new_state_precision; } + break; } + default: + THROW_GNA_EXCEPTION << "Failed to SetState for VariableState " << name << ". Incorrect new/old precision pair" + << " Old state: " << state_precision << " New state: " << new_state_precision; + } +} - float GNAVariableState::GetScaleFactor() const { +InferenceEngine::Blob::CPtr GNAVariableState::GetState() const { + auto elements = state->reserved_size / state->elementSizeBytes(); + InferenceEngine::Precision state_precision = getPrecision(); + + if (state->getInput() && state_precision == InferenceEngine::Precision::I16) { auto quantized = InferenceEngine::getInjectedData(state->getInput()); auto scale_factor = quantized != nullptr ? quantized->_dst_quant.GetScale() : state->scale_factor; - return scale_factor; + + auto result_blob = + make_blob_with_precision(InferenceEngine::TensorDesc(InferenceEngine::Precision::FP32, + InferenceEngine::SizeVector({1, elements}), + InferenceEngine::NC)); + + result_blob->allocate(); + auto buffer = result_blob->buffer().as(); + auto new_gna_ptr = static_cast(state->gna_ptr); + + for (int i = 0; i < elements; i++) { + buffer[i] = new_gna_ptr[i] / scale_factor; + } + + return result_blob; + } else { + auto result_blob = + make_blob_with_precision(InferenceEngine::TensorDesc(state_precision, + InferenceEngine::SizeVector({1, elements}), + InferenceEngine::NC)); + result_blob->allocate(); + std::memcpy(result_blob->buffer(), state->gna_ptr, state->reserved_size); + return result_blob; } +} + +float GNAVariableState::GetScaleFactor() const { + auto quantized = InferenceEngine::getInjectedData(state->getInput()); + auto scale_factor = quantized != nullptr ? quantized->_dst_quant.GetScale() : state->scale_factor; + return scale_factor; +} + } // namespace memory -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/memory/gna_memory_state.hpp b/src/plugins/intel_gna/src/memory/gna_memory_state.hpp index 493c0ca23f6..1fcaa677318 100644 --- a/src/plugins/intel_gna/src/memory/gna_memory_state.hpp +++ b/src/plugins/intel_gna/src/memory/gna_memory_state.hpp @@ -9,8 +9,10 @@ #include #include "gna_plugin.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace memory { + class GNAVariableState : public InferenceEngine::IVariableStateInternal { public: GNAVariableState(std::string name, std::shared_ptr state) @@ -33,5 +35,7 @@ private: */ InferenceEngine::Precision getPrecision() const; }; + } // namespace memory -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/memory/gna_memory_util.cpp b/src/plugins/intel_gna/src/memory/gna_memory_util.cpp index 5b561ec8735..8042a54ec60 100644 --- a/src/plugins/intel_gna/src/memory/gna_memory_util.cpp +++ b/src/plugins/intel_gna/src/memory/gna_memory_util.cpp @@ -7,13 +7,17 @@ #include #include "log/debug.hpp" -int32_t GNAPluginNS::memory::MemoryOffset(void *ptr_target, void *ptr_base) { +namespace ov { +namespace intel_gna { +namespace memory { + +int32_t MemoryOffset(void* ptr_target, void* ptr_base) { auto target = reinterpret_cast(ptr_target); auto base = reinterpret_cast(ptr_base); if (target == 0) { // handle NULL pointers separately return (-1); } else if (target < base) { - THROW_GNA_EXCEPTION << "Target address value " << target << " is less than base address " << base; + THROW_GNA_EXCEPTION << "Target address value " << target << " is less than base address " << base; } else { uint64_t diff = target - base; if (diff > 0x7fffffff) { @@ -23,3 +27,6 @@ int32_t GNAPluginNS::memory::MemoryOffset(void *ptr_target, void *ptr_base) { } } +} // namespace memory +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/memory/gna_memory_util.hpp b/src/plugins/intel_gna/src/memory/gna_memory_util.hpp index bd5390a707d..6928adef401 100644 --- a/src/plugins/intel_gna/src/memory/gna_memory_util.hpp +++ b/src/plugins/intel_gna/src/memory/gna_memory_util.hpp @@ -6,10 +6,12 @@ #include -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace memory { int32_t MemoryOffset(void *ptr_target, void *ptr_base); } // namespace memory -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/ops/util/util.hpp b/src/plugins/intel_gna/src/ops/util/util.hpp index 83aed83e38c..93521347280 100644 --- a/src/plugins/intel_gna/src/ops/util/util.hpp +++ b/src/plugins/intel_gna/src/ops/util/util.hpp @@ -84,7 +84,7 @@ static bool is_aligned_split(const std::shared_ptr input_op, size_ if (std::dynamic_pointer_cast(input_op) || std::dynamic_pointer_cast(input_op)) { for (size_t index = 0; index < input_op_out_index; index++) { size_t outputSize = ngraph::shape_size(input_op->get_output_shape(index)); - offset += outputSize * GNAPluginNS::GNALimitations::bytesPerSplitElement; + offset += outputSize * limitations::bytesPerSplitElement; } } return (offset == ALIGN64(offset)); @@ -93,7 +93,7 @@ static bool is_aligned_split(const std::shared_ptr input_op, size_ static bool is_crop_affined(std::shared_ptr node) { auto crop = std::dynamic_pointer_cast(node); if (crop != nullptr && !crop->offset.empty()) { - return GNAPluginNS::GNALimitations::isCropAffinedOffset(crop->offset.back()); + return limitations::isCropAffinedOffset(crop->offset.back()); } return false; } @@ -117,7 +117,7 @@ static bool is_trivial_transpose(std::shared_ptr node) { auto input = transpose->input(0).get_source_output().get_node_shared_ptr(); auto input_order = transpose->get_input_shape(0); - return GNAPluginNS::isTrivialPermute(node_order, input_order); + return permute::isTrivialPermute(node_order, input_order); } inline std::shared_ptr get_prev_node_skipping_certain(const std::shared_ptr& node, diff --git a/src/plugins/intel_gna/src/optimizer/gna_pass_manager.cpp b/src/plugins/intel_gna/src/optimizer/gna_pass_manager.cpp index ba95e65fd1d..3917a3820a9 100644 --- a/src/plugins/intel_gna/src/optimizer/gna_pass_manager.cpp +++ b/src/plugins/intel_gna/src/optimizer/gna_pass_manager.cpp @@ -24,7 +24,7 @@ #include #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include "log/debug.hpp" #include "log/log.hpp" #include "frontend/quantization.hpp" @@ -46,10 +46,12 @@ using namespace InferenceEngine; using namespace InferenceEngine::details; -using namespace GNAPluginNS; using namespace ov::intel_gna::frontend; using namespace ov::intel_gna::common; +namespace ov { +namespace intel_gna { + #define pass_trace() log::debug() << "[" << getName() << "] " std::shared_ptr BasePass::getPassManager() { @@ -98,14 +100,14 @@ static void insertDiagonalLayerBetween(InferenceEngine::CNNLayerPtr prevLayer, }); IE_ASSERT(inputLayer != nullptr); size_t weightsSize = LayerInfo(prevLayer).has32BOutput() ? nextLayer->outData[0]->getDims().back() : - Get2DReshapedData(nextLayer->outData[0], GNALimitations::GetMinBatchToFitInBuffer(nextLayer->outData[0]), 8)->getDims()[1]; + Get2DReshapedData(nextLayer->outData[0], limitations::GetMinBatchToFitInBuffer(nextLayer->outData[0]), 8)->getDims()[1]; std::vector weightsValues(weightsSize, fillValue); IE_ASSERT(diagLayer != nullptr); diagLayer->_weights = make_shared_blob( TensorDesc( nextLayer->outData[0]->getTensorDesc().getPrecision(), SizeVector({weightsValues.size()}), - Layout::C)); + InferenceEngine::Layout::C)); diagLayer->_weights->allocate(); CopyVectorToBlob(diagLayer->_weights, weightsValues); auto dataPtr = std::make_shared(diagName, nextLayer->outData[0]->getTensorDesc()); @@ -666,7 +668,7 @@ void RemovePermutationsNHWCToNCHWPass::run() { } // HWC layout enum is used here as the only available in CNNNetwork for 3D vectors, // but the real layout is NCW and it's the one used in order vector later - return dims_size == 4 ? Layout::NHWC : Layout::HWC; + return dims_size == 4 ? InferenceEngine::Layout::NHWC : InferenceEngine::Layout::HWC; }; auto setTransposedOrder = [getTransposedLayout](InferenceEngine::DataPtr data) { @@ -677,13 +679,17 @@ void RemovePermutationsNHWCToNCHWPass::run() { if (LayerInfo(current_layer).isConcat()) { auto concat_layer = dynamic_cast (current_layer.get()); auto dims_size = data->getDims().size(); - concat_layer->_axis = (dims_size == 4 ? GetPermuteOrder(Layout::NHWC, Layout::NCHW) : + concat_layer->_axis = (dims_size == 4 ? permute::GetPermuteOrder(InferenceEngine::Layout::NHWC, + InferenceEngine::Layout::NCHW) + : std::vector{0, 2, 1})[concat_layer->_axis]; } // NWC->NCW layouts are used here for order vector, see comments a few lines above auto dims = data->getDims(); - auto order = dims.size() == 4 ? GetPermuteOrder(Layout::NCHW, Layout::NHWC) : + auto order = dims.size() == 4 + ? permute::GetPermuteOrder(InferenceEngine::Layout::NCHW, InferenceEngine::Layout::NHWC) + : std::vector{0, 2, 1}; InferenceEngine::SizeVector new_dims; for (int i = 0; i < dims.size(); ++i) { @@ -1074,7 +1080,7 @@ void FlattenTrivialConcatPass::run() { auto concatInput = getLayerByIndex(input_idx, concatLayer); auto tensor = InferenceEngine::TensorDesc(concatInput->getTensorDesc()); - tensor.reshape(SizeVector({1, total_sizes[input_idx]}), Layout::NC); + tensor.reshape(SizeVector({1, total_sizes[input_idx]}), InferenceEngine::Layout::NC); auto reshapeName = l->name + "_input_"+ std::to_string(input_idx) +"_reshape"; auto reshape = CNNNetworkCreateReshape(tensor, reshapeName, quantized); @@ -1091,7 +1097,7 @@ void FlattenTrivialConcatPass::run() { auto total_size = std::accumulate(dims.begin(), dims.end(), size_t(1), std::multiplies()); auto new_tensor = output->getTensorDesc(); - new_tensor.reshape(SizeVector({1, total_size}), Layout::NC); + new_tensor.reshape(SizeVector({1, total_size}), InferenceEngine::Layout::NC); auto new_output = CNNReplaceDataWithChangedTensorDescription(output, new_tensor); log::debug() << "\tChanged " << output->getName() << " dims to 2D" << std::endl; @@ -1197,7 +1203,7 @@ void InsertConcatAligningFilterPass::run() { TensorDesc( concatInput->getTensorDesc().getPrecision(), SizeVector({filterWeights.size()}), - Layout::C)); + InferenceEngine::Layout::C)); concatAligningFilter->_weights->allocate(); if (!concatAligningFilter->_weights->buffer().as()) { THROW_GNA_EXCEPTION << "Failed to allocate weights of size " << filterWeights.size() << " for " << filterName; @@ -1208,10 +1214,10 @@ void InsertConcatAligningFilterPass::run() { // modifying output rows to be used - to avoid modification to original concat we are store num of elements in params dims[1] = num_rows_out; - if ((concatInput->getLayout() == Layout::NC && dims[0] > 8) || - (concatInput->getLayout() == Layout::CN && dims[1] > 8)) { - THROW_GNA_EXCEPTION << "unsupported batch number '" << - (concatInput->getLayout() == Layout::NC ? dims[0] : dims[1]) << + if ((concatInput->getLayout() == InferenceEngine::Layout::NC && dims[0] > 8) || + (concatInput->getLayout() == InferenceEngine::Layout::CN && dims[1] > 8)) { + THROW_GNA_EXCEPTION << "unsupported batch number '" << (concatInput->getLayout() == InferenceEngine::Layout::NC ? dims[0] : dims[1]) + << "' in layer '" << concatLayer->name << "'"; } @@ -1312,8 +1318,7 @@ void ReorderConcatInputsPass::run() { auto linkOutData = std::make_shared(linkName, TensorDesc(Precision::FP32, - SizeVector({ 1 }), - Layout::C)); + SizeVector({ 1 }), InferenceEngine::Layout::C)); getCreatorLayer(linkOutData) = link; link->outData.push_back(linkOutData); @@ -1340,7 +1345,7 @@ void InsertSplitAligningFilterPass::run() { } auto outFunctionalLayers = CNNNetGetAllNextLayersSkipCertain(l, -1, [](CNNLayerPtr next_layer) { - return GNAPluginNS::LayerInfo(next_layer).isNonFunctional(); + return LayerInfo(next_layer).isNonFunctional(); }); size_t padding = 0; for (auto &&outFunctionalLayer : outFunctionalLayers) { @@ -1387,16 +1392,16 @@ void InsertSplitAligningFilterPass::run() { IE_ASSERT(filterLayer != nullptr); // encodes offset to beginning of split layer input - filterLayer->params["offset"] = std::to_string(aligned64_offset / GNALimitations::bytesPerSplitElement); + filterLayer->params["offset"] = std::to_string(aligned64_offset / limitations::bytesPerSplitElement); auto dims = splitOutput->getTensorDesc().getDims(); if (dims.size() > 3) { THROW_GNA_EXCEPTION << "unsupported split layer dims size: " << dims.size(); } - const auto offsetOfUnalignment = (currentOffset - aligned64_offset) / GNALimitations::bytesPerSplitElement; + const auto offsetOfUnalignment = (currentOffset - aligned64_offset) / limitations::bytesPerSplitElement; // TODO consider to use a different number of filters do decrese the number of trailing zeros (additionalPaddingOfFilter) - const auto numberOfFilters = GNALimitations::convMinFiltersNum; - const auto filterSize = ALIGN(offsetOfUnalignment + numberOfFilters, GNALimitations::convFilterSizeDivider); + const auto numberOfFilters = limitations::convMinFiltersNum; + const auto filterSize = ALIGN(offsetOfUnalignment + numberOfFilters, limitations::convFilterSizeDivider); // filterWeights: numberOfFilters X (offsetOfUnalignment + additionalPaddingOfFilter + numberOfFilters) // offsetOfUnalignment - the leading zeros in the filter @@ -1424,7 +1429,7 @@ void InsertSplitAligningFilterPass::run() { filterLayer->_weights = make_shared_blob(TensorDesc( inputData->getTensorDesc().getPrecision(), SizeVector({filterWeights.size()}), - Layout::C)); + InferenceEngine::Layout::C)); filterLayer->_weights->allocate(); CopyVectorToBlob(filterLayer->_weights, filterWeights); @@ -1433,7 +1438,7 @@ void InsertSplitAligningFilterPass::run() { filterLayer->_biases = make_shared_blob(TensorDesc( inputData->getTensorDesc().getPrecision(), SizeVector({ biasWeights.size() }), - Layout::C)); + InferenceEngine::Layout::C)); filterLayer->_biases->allocate(); CopyVectorToBlob(filterLayer->_biases, biasWeights); @@ -1452,7 +1457,7 @@ void InsertSplitAligningFilterPass::run() { } // search data that starts from unaligned location - currentOffset += outputSize * GNALimitations::bytesPerSplitElement; + currentOffset += outputSize * limitations::bytesPerSplitElement; splitOutIndex++; } } @@ -1490,7 +1495,7 @@ void EltwiseSplitOverChannelsPass::run() { auto oData = l->outData.front(); auto oDims = oData->getDims(); auto totalElementsSize = details::product(std::begin(oDims), std::end(oDims)); - if (totalElementsSize <= GNALimitations::bufferMaxSize) { + if (totalElementsSize <= limitations::bufferMaxSize) { continue; } auto splitSizesPerAxis = AlignedSplitSizesPerAxis(oDims); @@ -1602,7 +1607,7 @@ void SubstituteScaleShiftBroadCastPass::run() { dataDims = reshaped_data[insData->getName()]; } else { dataDims = HasTo2DReshapeData(l) ? - Get2DReshapedData(insData, GNALimitations::GetMinBatchToFitInBuffer(insData), 8)->getDims() : + Get2DReshapedData(insData, limitations::GetMinBatchToFitInBuffer(insData), 8)->getDims() : insData->getDims(); } @@ -1634,7 +1639,7 @@ void SubstituteScaleShiftBroadCastPass::run() { } auto tensor = InferenceEngine::TensorDesc(insData->getTensorDesc()); - tensor.reshape(SizeVector{ batchSize, nElements }, Layout::NC); + tensor.reshape(SizeVector{batchSize, nElements}, InferenceEngine::Layout::NC); auto reshapeName = scaleShift->name + "_input_" + std::to_string(0) + "_reshape"; auto reshape = CNNNetworkCreateReshape(tensor, reshapeName, quantized); auto layer_before_scale_shift = getCreatorLayer(insData); @@ -1949,7 +1954,7 @@ void FuseFQIntoWeightsPass::run() { << LAYER_NAME(weightableLayer) << "\n"; auto biases = weightableLayer->insData.size() == 3 ? - LayerUtils::getParamFromInputAsBlob(weightableLayer, biasesIdx) : nullptr; + layer_utils::getParamFromInputAsBlob(weightableLayer, biasesIdx) : nullptr; auto quantizedWeights = gnaFakeQuantizeLayer.getConstInputData(); // 1. broke existing connections - by detaching fq subgraph from rest of graph @@ -2032,7 +2037,8 @@ void FuseFQIntoWeightsPass::run() { transform->func_id = gnaFakeQuantizeLayer.parseAsActivation(); auto quantizedWeightsData = quantizedWeights->buffer(); - auto dequantizedWeights = make_shared_blob(TensorDesc(Precision::FP32, { outputSize }, Layout::C)); + auto dequantizedWeights = + make_shared_blob(TensorDesc(Precision::FP32, {outputSize}, InferenceEngine::Layout::C)); dequantizedWeights->allocate(); auto resultBuffer = dequantizedWeights->buffer(); @@ -2460,3 +2466,6 @@ int PassManager::run(int index) { } return index; } + +} // namespace intel_gna +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_gna/src/optimizer/gna_pass_manager.hpp b/src/plugins/intel_gna/src/optimizer/gna_pass_manager.hpp index c484a366703..eb93db7848f 100644 --- a/src/plugins/intel_gna/src/optimizer/gna_pass_manager.hpp +++ b/src/plugins/intel_gna/src/optimizer/gna_pass_manager.hpp @@ -9,7 +9,9 @@ #include #include -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + /** * @brief interface for gna-pass, special transformer that will be run on input network in order to generate GNABlob */ @@ -244,4 +246,5 @@ public: int run(int index = 0); }; -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/orientation_helper.cpp b/src/plugins/intel_gna/src/orientation_helper.cpp index 4ed42f95dd9..0ea2fc009be 100644 --- a/src/plugins/intel_gna/src/orientation_helper.cpp +++ b/src/plugins/intel_gna/src/orientation_helper.cpp @@ -9,12 +9,12 @@ #include namespace ov { -namespace intela_gna { +namespace intel_gna { namespace helpers { void updateModelInputOrientationWithoutConvolution(const InferenceEngine::CNNLayer& inputLayer, - const GNAPluginNS::backend::DnnComponents& components, - GNAPluginNS::GnaInputs& inputs) { + const backend::DnnComponents& components, + GnaInputs& inputs) { // does not make sense to go further is there is no input to set auto input = inputs.find(inputLayer.name); @@ -84,8 +84,8 @@ void updateModelInputOrientationWithoutConvolution(const InferenceEngine::CNNLay void updateModelOutputOrientation(const std::string& outputName, const std::string& cnnlayerName, - const GNAPluginNS::backend::DnnComponents& components, - GNAPluginNS::GnaOutputs& outputs) { + const backend::DnnComponents& components, + GnaOutputs& outputs) { // if there is no output to set does not make sense to go further auto output = outputs.find(outputName); if (output == outputs.end()) { @@ -99,5 +99,5 @@ void updateModelOutputOrientation(const std::string& outputName, } } } // namespace helpers -} // namespace intela_gna +} // namespace intel_gna } // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_gna/src/orientation_helper.hpp b/src/plugins/intel_gna/src/orientation_helper.hpp index 9e81207a0cd..7a1568de2ba 100644 --- a/src/plugins/intel_gna/src/orientation_helper.hpp +++ b/src/plugins/intel_gna/src/orientation_helper.hpp @@ -13,7 +13,8 @@ #include "descriptions/gna_desc.hpp" namespace ov { -namespace intela_gna { +namespace intel_gna { + /** * @namespace helpers contains helpers tools for gna plugin. */ @@ -38,8 +39,8 @@ namespace helpers { * @throws if orientations of input for multiple layers are different */ void updateModelInputOrientationWithoutConvolution(const InferenceEngine::CNNLayer& inputLayer, - const GNAPluginNS::backend::DnnComponents& components, - GNAPluginNS::GnaInputs& inputs); + const backend::DnnComponents& components, + GnaInputs& inputs); /** * @brief Update expected orientation for model output of given \p outputName. It is needed to recognize if extra @@ -60,9 +61,9 @@ void updateModelInputOrientationWithoutConvolution(const InferenceEngine::CNNLay */ void updateModelOutputOrientation(const std::string& outputName, const std::string& cnnlayerName, - const GNAPluginNS::backend::DnnComponents& components, - GNAPluginNS::GnaOutputs& outputs); + const backend::DnnComponents& components, + GnaOutputs& outputs); } // namespace helpers -} // namespace intela_gna +} // namespace intel_gna } // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_gna/src/preprocessing.cpp b/src/plugins/intel_gna/src/preprocessing.cpp index 88f577f613a..29de86b8d19 100644 --- a/src/plugins/intel_gna/src/preprocessing.cpp +++ b/src/plugins/intel_gna/src/preprocessing.cpp @@ -4,7 +4,10 @@ #include "preprocessing.hpp" -int16_t GNAPluginNS::ConvertFloatToInt16(float src) { +namespace ov { +namespace intel_gna { + +int16_t ConvertFloatToInt16(float src) { float rounding_value = (src > 0) ? 0.5f : -0.5f; float value = src + rounding_value; if (value > 32767.0) { @@ -15,7 +18,7 @@ int16_t GNAPluginNS::ConvertFloatToInt16(float src) { return (int16_t)value; } -int8_t GNAPluginNS::ConvertFloatToInt8(float src) { +int8_t ConvertFloatToInt8(float src) { float rounding_value = (src > 0) ? 0.5f : -0.5f; float value = src + rounding_value; if (value > 127.0) { @@ -26,15 +29,18 @@ int8_t GNAPluginNS::ConvertFloatToInt8(float src) { return (int8_t)value; } -void GNAPluginNS::ConvertToInt16(int16_t *ptr_dst, - const float *ptr_src, - const uint32_t num_rows, - const uint32_t num_columns, - const float scale_factor) { +void ConvertToInt16(int16_t* ptr_dst, + const float* ptr_src, + const uint32_t num_rows, + const uint32_t num_columns, + const float scale_factor) { if (!ptr_dst || !ptr_src) { return; } - for (uint32_t i = 0; i < num_rows*num_columns; i++) { - ptr_dst[i] = ConvertFloatToInt16(ptr_src[i]*scale_factor); + for (uint32_t i = 0; i < num_rows * num_columns; i++) { + ptr_dst[i] = ConvertFloatToInt16(ptr_src[i] * scale_factor); } } + +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/preprocessing.hpp b/src/plugins/intel_gna/src/preprocessing.hpp index 990ce82b039..746f2e330bd 100644 --- a/src/plugins/intel_gna/src/preprocessing.hpp +++ b/src/plugins/intel_gna/src/preprocessing.hpp @@ -6,7 +6,8 @@ #include -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { void ConvertToInt16(int16_t *ptr_dst, const float *ptr_src, @@ -32,4 +33,5 @@ inline void UnscaleAndCast(T2 *ptr_dst, T1 *ptr_src, const uint32_t num_rows, co } } -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request/model_wrapper.cpp b/src/plugins/intel_gna/src/request/model_wrapper.cpp index 7ab74310053..85213f337b7 100644 --- a/src/plugins/intel_gna/src/request/model_wrapper.cpp +++ b/src/plugins/intel_gna/src/request/model_wrapper.cpp @@ -6,7 +6,8 @@ #include "gna2_model_helper.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { ModelWrapper::ModelWrapper(ConstructionPassKey) { @@ -33,4 +34,5 @@ const Gna2Model& ModelWrapper::object() const { } } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request/model_wrapper.hpp b/src/plugins/intel_gna/src/request/model_wrapper.hpp index 8e809ce1786..316db17e017 100644 --- a/src/plugins/intel_gna/src/request/model_wrapper.hpp +++ b/src/plugins/intel_gna/src/request/model_wrapper.hpp @@ -6,8 +6,10 @@ #include -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { + class ModelWrapperFactory; /** @@ -58,4 +60,5 @@ private: }; } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request/model_wrapper_factory.cpp b/src/plugins/intel_gna/src/request/model_wrapper_factory.cpp index fe6daaa4491..25dca9bf3a0 100644 --- a/src/plugins/intel_gna/src/request/model_wrapper_factory.cpp +++ b/src/plugins/intel_gna/src/request/model_wrapper_factory.cpp @@ -9,7 +9,8 @@ #include "backend/am_intel_dnn.hpp" #include "gna2_model_helper.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { std::shared_ptr ModelWrapperFactory::createTrivial() { @@ -49,4 +50,5 @@ std::shared_ptr ModelWrapperFactory::createInitialized(ModelInitia } } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request/model_wrapper_factory.hpp b/src/plugins/intel_gna/src/request/model_wrapper_factory.hpp index 741b01ba9bf..ba5c94572e9 100644 --- a/src/plugins/intel_gna/src/request/model_wrapper_factory.hpp +++ b/src/plugins/intel_gna/src/request/model_wrapper_factory.hpp @@ -9,7 +9,8 @@ #include "model_wrapper.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { class ModelWrapperFactory { @@ -22,4 +23,5 @@ public: }; } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request/subrequest.hpp b/src/plugins/intel_gna/src/request/subrequest.hpp index cfec7b0ef2b..6871778028f 100644 --- a/src/plugins/intel_gna/src/request/subrequest.hpp +++ b/src/plugins/intel_gna/src/request/subrequest.hpp @@ -9,7 +9,8 @@ #include "request_status.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { /** @@ -27,7 +28,7 @@ public: * @brief Callback invoked by wait operation. * @param requestID id of request to be used for wait * @param timeoutMilliseconds timeout of wait in milliseconds - * @return Status of subrequest @see GNAPluginNS::RequestStatus + * @return Status of subrequest @see RequestStatus * */ using WaitHandler = std::function; @@ -37,7 +38,7 @@ public: /** * @brief Wait until subrequest will be finished for given timeout. * @param timeoutMilliseconds timeout in milliseconds - * @return status of execution of subrequest @see GNAPluginNS::RequestStatus + * @return status of execution of subrequest @see RequestStatus */ virtual RequestStatus wait(int64_t timeoutMilliseconds) = 0; @@ -69,4 +70,5 @@ public: }; } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request/subrequest_impl.cpp b/src/plugins/intel_gna/src/request/subrequest_impl.cpp index 87ceae27c28..6c79ac3ebe5 100644 --- a/src/plugins/intel_gna/src/request/subrequest_impl.cpp +++ b/src/plugins/intel_gna/src/request/subrequest_impl.cpp @@ -9,7 +9,8 @@ #include "log/debug.hpp" #include "log/log.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { SubrequestImpl::SubrequestImpl(EnqueueHandler enqueueHandler, WaitHandler waitHandler) @@ -64,4 +65,5 @@ bool SubrequestImpl::isCompleted() const { } } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request/subrequest_impl.hpp b/src/plugins/intel_gna/src/request/subrequest_impl.hpp index 9dfe3de2c84..4f7c829fffa 100644 --- a/src/plugins/intel_gna/src/request/subrequest_impl.hpp +++ b/src/plugins/intel_gna/src/request/subrequest_impl.hpp @@ -6,7 +6,8 @@ #include "subrequest.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { /** @@ -34,7 +35,7 @@ public: /** * @brief Wait until subrequest will be finished for given timeout. * @param timeoutMilliseconds timeout in milliseconds - * @return status of execution of subrequest @see GNAPluginNS::RequestStatus + * @return status of execution of subrequest @see RequestStatus */ RequestStatus wait(int64_t timeoutMilliseconds) override; @@ -72,4 +73,5 @@ private: }; } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request/worker.hpp b/src/plugins/intel_gna/src/request/worker.hpp index a645ade30dd..162da19f876 100644 --- a/src/plugins/intel_gna/src/request/worker.hpp +++ b/src/plugins/intel_gna/src/request/worker.hpp @@ -12,7 +12,8 @@ #include "request_status.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { class ModelWrapper; @@ -46,7 +47,7 @@ public: /** * @brief Wait untril request will be not finished for give timeout. * @param timeoutMilliseconds timeout in milliseconds - * @return status of execution of ongoing request. @see GNAPluginNS::RequestStatus + * @return status of execution of ongoing request. @see RequestStatus */ virtual RequestStatus wait(int64_t timeoutMilliseconds) = 0; @@ -85,4 +86,5 @@ public: }; } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request/worker_factory.cpp b/src/plugins/intel_gna/src/request/worker_factory.cpp index 2efa6c0eaa6..d43d603dad9 100644 --- a/src/plugins/intel_gna/src/request/worker_factory.cpp +++ b/src/plugins/intel_gna/src/request/worker_factory.cpp @@ -12,7 +12,8 @@ #include "subrequest_impl.hpp" #include "worker_impl.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { constexpr const uint32_t WorkerFactory::kFakeRequestID; @@ -24,7 +25,7 @@ std::shared_ptr WorkerFactory::createWorker(std::shared_ptr WorkerFactory::createWorkerFP32(std::shared_ptr model, - std::shared_ptr dnn) { + std::shared_ptr dnn) { return std::make_shared(model, createModelSubrequestsFP32(std::move(dnn))); } @@ -88,14 +89,14 @@ std::vector> WorkerFactory::createModelSubrequests( } std::vector> WorkerFactory::createModelSubrequestsFP32( - std::shared_ptr dnn) { + std::shared_ptr dnn) { if (!dnn) { THROW_GNA_EXCEPTION << "dnn is nullptr"; } std::vector> subrequests; - std::weak_ptr weak_dnn = dnn; + std::weak_ptr weak_dnn = dnn; auto enqueFP32 = [weak_dnn]() -> uint32_t { if (auto dnn = weak_dnn.lock()) { @@ -132,4 +133,5 @@ std::vector> WorkerFactory::createModelSubrequestsTr } } // namespace request -} // namespace GNAPluginNS \ No newline at end of file +} // namespace intel_gna +} // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_gna/src/request/worker_factory.hpp b/src/plugins/intel_gna/src/request/worker_factory.hpp index e89b04fc325..85073b8d2dc 100644 --- a/src/plugins/intel_gna/src/request/worker_factory.hpp +++ b/src/plugins/intel_gna/src/request/worker_factory.hpp @@ -10,7 +10,9 @@ #include "worker.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { + class GNADevice; namespace backend { @@ -30,7 +32,7 @@ public: std::shared_ptr device, const Gna2AccelerationMode accelerationMode); static std::shared_ptr createWorkerFP32(std::shared_ptr model, - std::shared_ptr dnn); + std::shared_ptr dnn); static std::shared_ptr createWorkerTrivialTopology(std::shared_ptr model); static std::vector> createModelSubrequests(std::shared_ptr model, @@ -45,4 +47,5 @@ private: }; } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request/worker_impl.cpp b/src/plugins/intel_gna/src/request/worker_impl.cpp index 5abe6471524..d9128d428b0 100644 --- a/src/plugins/intel_gna/src/request/worker_impl.cpp +++ b/src/plugins/intel_gna/src/request/worker_impl.cpp @@ -11,7 +11,8 @@ #include "model_wrapper.hpp" #include "subrequest.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { WorkerImpl::WorkerImpl(std::shared_ptr model, std::vector> modelSubrequests) @@ -129,4 +130,5 @@ void WorkerImpl::cleanup_subrequests() { } } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request/worker_impl.hpp b/src/plugins/intel_gna/src/request/worker_impl.hpp index d7a68a57cee..ebf1b21ce56 100644 --- a/src/plugins/intel_gna/src/request/worker_impl.hpp +++ b/src/plugins/intel_gna/src/request/worker_impl.hpp @@ -13,7 +13,8 @@ #include "worker.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { class ModelWrapper; @@ -102,4 +103,5 @@ private: }; } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request/worker_pool.hpp b/src/plugins/intel_gna/src/request/worker_pool.hpp index 243513c09ce..0e3b1ee76fa 100644 --- a/src/plugins/intel_gna/src/request/worker_pool.hpp +++ b/src/plugins/intel_gna/src/request/worker_pool.hpp @@ -9,7 +9,8 @@ #include "worker.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { /** @@ -86,4 +87,5 @@ public: }; } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request/worker_pool_impl.cpp b/src/plugins/intel_gna/src/request/worker_pool_impl.cpp index 9d2b874a29a..da032d32c6c 100644 --- a/src/plugins/intel_gna/src/request/worker_pool_impl.cpp +++ b/src/plugins/intel_gna/src/request/worker_pool_impl.cpp @@ -7,7 +7,8 @@ #include "log/debug.hpp" #include "worker.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { void WorkerPoolImpl::addModelWorker(std::shared_ptr worker) { @@ -81,4 +82,5 @@ void WorkerPoolImpl::checkWorkerNotEmpty() const { } } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request/worker_pool_impl.hpp b/src/plugins/intel_gna/src/request/worker_pool_impl.hpp index 0c6b7726a90..a7cef68ed75 100644 --- a/src/plugins/intel_gna/src/request/worker_pool_impl.hpp +++ b/src/plugins/intel_gna/src/request/worker_pool_impl.hpp @@ -10,7 +10,8 @@ #include "worker.hpp" #include "worker_pool.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { /** @@ -81,4 +82,5 @@ private: }; } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/request_status.hpp b/src/plugins/intel_gna/src/request_status.hpp index 96f27808131..89a052c3b02 100644 --- a/src/plugins/intel_gna/src/request_status.hpp +++ b/src/plugins/intel_gna/src/request_status.hpp @@ -4,7 +4,8 @@ #pragma once -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { /** * @brief Enum representing status of request @@ -17,4 +18,5 @@ enum class RequestStatus { kCompletedWithError = 4 /// request was completed with error }; -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/runtime/cnn.cpp b/src/plugins/intel_gna/src/runtime/cnn.cpp index 8b89672d6f3..2da5c04880d 100644 --- a/src/plugins/intel_gna/src/runtime/cnn.cpp +++ b/src/plugins/intel_gna/src/runtime/cnn.cpp @@ -8,14 +8,14 @@ #include #include "cnn.h" -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include "backend/gna_limitations.hpp" #include "frontend/quantization.hpp" #include "gna_lib_ver_selector.hpp" #include "layers/gna_convolution_layer.hpp" #include "log/debug.hpp" -using namespace GNAPluginNS::GNAConvolutionLayer; +using namespace ov::intel_gna::gna_convolution_layer; void CNNFilter32(intel_dnn_component_t *component) { auto filters = reinterpret_cast(component->op.conv1D.ptr_filters); @@ -268,7 +268,7 @@ void CNN2DFilter32(intel_dnn_component_t* component) { } } // kernel padded to 16B = 4 * sizeof(float) - kernelIndex += ALIGN(kh * kw * kc, GNAPluginNS::GNALimitations::convEachKernelByteAlignment / sizeof(float)); + kernelIndex += ALIGN(kh * kw * kc, ov::intel_gna::limitations::convEachKernelByteAlignment / sizeof(float)); } } diff --git a/src/plugins/intel_gna/src/runtime/cnn.h b/src/plugins/intel_gna/src/runtime/cnn.h index fd04148deeb..c849345ac2d 100644 --- a/src/plugins/intel_gna/src/runtime/cnn.h +++ b/src/plugins/intel_gna/src/runtime/cnn.h @@ -7,7 +7,7 @@ #include #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #define CNN_MAX_POOL_SIZE 6 diff --git a/src/plugins/intel_gna/src/runtime/gna_float_runtime.cpp b/src/plugins/intel_gna/src/runtime/gna_float_runtime.cpp index cf31bb6c1ae..b575e0b5a90 100644 --- a/src/plugins/intel_gna/src/runtime/gna_float_runtime.cpp +++ b/src/plugins/intel_gna/src/runtime/gna_float_runtime.cpp @@ -3,13 +3,13 @@ // #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include "gna_float_runtime.hpp" #include "log/debug.hpp" -using namespace GNAPluginNS; -using namespace GNAPluginNS::runtime; - +namespace ov { +namespace intel_gna { +namespace runtime { void FP::infer() { if (!dnn) { @@ -17,75 +17,80 @@ void FP::infer() { } for (uint32_t i = 0; i < dnn->component.size(); i++) { - intel_dnn_component_t *comp = &dnn->component[i]; - uint32_t *ptr_active_outputs = nullptr; - uint32_t num_active_outputs = (comp->orientation_out == kDnnInterleavedOrientation) - ? comp->num_rows_out : comp->num_columns_out; + intel_dnn_component_t* comp = &dnn->component[i]; + uint32_t* ptr_active_outputs = nullptr; + uint32_t num_active_outputs = + (comp->orientation_out == kDnnInterleavedOrientation) ? comp->num_rows_out : comp->num_columns_out; if (i == dnn->component.size() - 1) { // active list applies to last component ptr_active_outputs = dnn->ptr_active_outputs(); num_active_outputs = dnn->num_active_outputs(); } else if (i == dnn->component.size() - 2) { // also applies to last two components when last is PWL - if ((dnn->component[i].operation == kDnnAffineOp) && (dnn->component[i + 1].operation == kDnnPiecewiselinearOp)) { + if ((dnn->component[i].operation == kDnnAffineOp) && + (dnn->component[i + 1].operation == kDnnPiecewiselinearOp)) { ptr_active_outputs = dnn->ptr_active_outputs(); - num_active_outputs = dnn->num_active_outputs(); } + num_active_outputs = dnn->num_active_outputs(); + } } switch (comp->operation) { - case kDnnAffineOp : { - ApplyAffineTransform(comp, ptr_active_outputs, num_active_outputs); - break; - } - case kDnnDiagonalOp: { - ApplyDiagonalTransform(comp); - break; - } - case kDnnRecurrentOp: { - if ((i < dnn->component.size() - 1) && (dnn->component[i + 1].operation == kDnnPiecewiselinearOp)) { - intel_dnn_component_t *comp_pwl = &dnn->component[i + 1]; - for (uint32_t j = 0; j < comp->num_rows_in; j++) { - void *ptr_feedbacks = - reinterpret_cast(reinterpret_cast(comp->op.recurrent.ptr_feedbacks) - + j * comp_pwl->num_columns_out); - ApplyRecurrentTransform(comp, j, ptr_feedbacks); - ApplyPiecewiseLinearTransform(comp_pwl, kDnnFloat, num_active_outputs, j); - } - i++; // skip next component - } else { - THROW_GNA_EXCEPTION << "Missing PiecewiseLinear component after Recurrent component in Propagate!"; + case kDnnAffineOp: { + ApplyAffineTransform(comp, ptr_active_outputs, num_active_outputs); + break; + } + case kDnnDiagonalOp: { + ApplyDiagonalTransform(comp); + break; + } + case kDnnRecurrentOp: { + if ((i < dnn->component.size() - 1) && (dnn->component[i + 1].operation == kDnnPiecewiselinearOp)) { + intel_dnn_component_t* comp_pwl = &dnn->component[i + 1]; + for (uint32_t j = 0; j < comp->num_rows_in; j++) { + void* ptr_feedbacks = reinterpret_cast( + reinterpret_cast(comp->op.recurrent.ptr_feedbacks) + j * comp_pwl->num_columns_out); + ApplyRecurrentTransform(comp, j, ptr_feedbacks); + ApplyPiecewiseLinearTransform(comp_pwl, kDnnFloat, num_active_outputs, j); } - break; + i++; // skip next component + } else { + THROW_GNA_EXCEPTION << "Missing PiecewiseLinear component after Recurrent component in Propagate!"; } - case kDnnConvolutional1dOp: { - ApplyConvolutional1DTransform(comp); - break; - } - case kDnnConvolutional2dOp: { - ApplyConvolutional2DTransform(comp); - break; - } - case kDnnPiecewiselinearOp: { - ApplyPiecewiseLinearTransform(comp, kDnnFloat, num_active_outputs); - break; - } - case kDnnMaxPoolOp: { - ApplyMaxPoolTransform(comp, kDnnFloat); - break; - } - case kDnnInterleaveOp: { - ApplyTranspose(comp); - break; - } - case kDnnDeinterleaveOp: { - ApplyTranspose(comp); - break; - } - case kDnnCopyOp: { - ApplyCopy(comp); - break; - } - default: - THROW_GNA_EXCEPTION << "[GNA FP32 RUNTIME] Bad operation " << comp->operation; + break; + } + case kDnnConvolutional1dOp: { + ApplyConvolutional1DTransform(comp); + break; + } + case kDnnConvolutional2dOp: { + ApplyConvolutional2DTransform(comp); + break; + } + case kDnnPiecewiselinearOp: { + ApplyPiecewiseLinearTransform(comp, kDnnFloat, num_active_outputs); + break; + } + case kDnnMaxPoolOp: { + ApplyMaxPoolTransform(comp, kDnnFloat); + break; + } + case kDnnInterleaveOp: { + ApplyTranspose(comp); + break; + } + case kDnnDeinterleaveOp: { + ApplyTranspose(comp); + break; + } + case kDnnCopyOp: { + ApplyCopy(comp); + break; + } + default: + THROW_GNA_EXCEPTION << "[GNA FP32 RUNTIME] Bad operation " << comp->operation; } } } + +} // namespace runtime +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/runtime/gna_float_runtime.hpp b/src/plugins/intel_gna/src/runtime/gna_float_runtime.hpp index 5294d3e37b3..1fe08e085d3 100644 --- a/src/plugins/intel_gna/src/runtime/gna_float_runtime.hpp +++ b/src/plugins/intel_gna/src/runtime/gna_float_runtime.hpp @@ -5,8 +5,10 @@ #pragma once #include -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace runtime { + /** * @brief floating runtime for gna-plugin, in most case it uses same gna-primitives description as integer runtime, but execute them on CPU */ @@ -39,5 +41,5 @@ class FP { }; } // namespace runtime - -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/runtime/gna_float_runtime_op.cpp b/src/plugins/intel_gna/src/runtime/gna_float_runtime_op.cpp index af51c8c703f..288f3534d23 100644 --- a/src/plugins/intel_gna/src/runtime/gna_float_runtime_op.cpp +++ b/src/plugins/intel_gna/src/runtime/gna_float_runtime_op.cpp @@ -7,10 +7,11 @@ #include "cnn.h" #include "floatmath.h" -using namespace GNAPluginNS; -using namespace GNAPluginNS::runtime; +namespace ov { +namespace intel_gna { +namespace runtime { -void FP::ApplyAffineTransform(intel_dnn_component_t *component, uint32_t *list, uint32_t listsize) { +void FP::ApplyAffineTransform(intel_dnn_component_t* component, uint32_t* list, uint32_t listsize) { if (4 != component->num_bytes_per_input) { THROW_GNA_EXCEPTION << "Bad data width: " << component->num_bytes_per_input; } @@ -23,10 +24,10 @@ void FP::ApplyAffineTransform(intel_dnn_component_t *component, uint32_t *list, uint32_t ldb = component->num_columns_in; uint32_t ldc = component->num_columns_out; - auto A = reinterpret_cast(transform->ptr_weights); - auto B = reinterpret_cast(component->ptr_inputs); - auto C = reinterpret_cast(component->ptr_outputs); - auto bias = reinterpret_cast(transform->ptr_biases); + auto A = reinterpret_cast(transform->ptr_weights); + auto B = reinterpret_cast(component->ptr_inputs); + auto C = reinterpret_cast(component->ptr_outputs); + auto bias = reinterpret_cast(transform->ptr_biases); if (list == nullptr) { for (uint32_t i = 0; i < m; i++) { for (uint32_t j = 0; j < n; j++) { @@ -60,7 +61,7 @@ void FP::ApplyAffineTransform(intel_dnn_component_t *component, uint32_t *list, } } -void FP::ApplyDiagonalTransform(intel_dnn_component_t *component) { +void FP::ApplyDiagonalTransform(intel_dnn_component_t* component) { if (4 != component->num_bytes_per_input) { THROW_GNA_EXCEPTION << "Bad data width: " << component->num_bytes_per_input; } @@ -70,10 +71,10 @@ void FP::ApplyDiagonalTransform(intel_dnn_component_t *component) { uint32_t n = component->num_columns_in; uint32_t ldc = component->num_columns_out; - auto A = reinterpret_cast(transform->ptr_weights); - auto B = reinterpret_cast(component->ptr_inputs); - auto C = reinterpret_cast(component->ptr_outputs); - auto bias = reinterpret_cast(transform->ptr_biases); + auto A = reinterpret_cast(transform->ptr_weights); + auto B = reinterpret_cast(component->ptr_inputs); + auto C = reinterpret_cast(component->ptr_outputs); + auto bias = reinterpret_cast(transform->ptr_biases); for (uint32_t i = 0; i < m; i++) { for (uint32_t j = 0; j < n; j++) { C[i * ldc + j] = bias[i]; @@ -81,19 +82,19 @@ void FP::ApplyDiagonalTransform(intel_dnn_component_t *component) { } std::vector Arow(n); for (uint32_t i = 0; i < m; i++) { - float *Brow = B + i * n; - float *Crow = C + i * ldc; + float* Brow = B + i * n; + float* Crow = C + i * ldc; std::fill(std::begin(Arow), std::end(Arow), A[i]); cblas_ssbmv1(CblasRowMajor, CblasLower, n, 0, 1.0, Arow.data(), 1, Brow, 1, 1.0, Crow, 1); } } -void FP::ApplyRecurrentTransform(intel_dnn_component_t *component, uint32_t row, void *ptr_feedbacks) { +void FP::ApplyRecurrentTransform(intel_dnn_component_t* component, uint32_t row, void* ptr_feedbacks) { if (4 != component->num_bytes_per_input) { THROW_GNA_EXCEPTION << "Bad data width: " << component->num_bytes_per_input; } - intel_recurrent_t *transform = &component->op.recurrent; + intel_recurrent_t* transform = &component->op.recurrent; int k1 = component->num_columns_in; int k2 = component->num_columns_out; int n = k2; @@ -101,15 +102,15 @@ void FP::ApplyRecurrentTransform(intel_dnn_component_t *component, uint32_t row, if (component->op.recurrent.ptr_feedbacks == nullptr) { THROW_GNA_EXCEPTION << "nullptr feedback pointer"; } - auto A1 = reinterpret_cast(component->ptr_inputs) + row * component->num_columns_in; - auto A2 = reinterpret_cast(ptr_feedbacks); - auto X = reinterpret_cast(transform->ptr_weights); - auto B = reinterpret_cast(transform->ptr_biases); - auto C = reinterpret_cast(component->ptr_outputs) + row * component->num_columns_out; + auto A1 = reinterpret_cast(component->ptr_inputs) + row * component->num_columns_in; + auto A2 = reinterpret_cast(ptr_feedbacks); + auto X = reinterpret_cast(transform->ptr_weights); + auto B = reinterpret_cast(transform->ptr_biases); + auto C = reinterpret_cast(component->ptr_outputs) + row * component->num_columns_out; sgemv_split(n, k1, k2, A1, A2, X, B, C); } -void FP::ApplyConvolutional1DTransform(intel_dnn_component_t *component) { +void FP::ApplyConvolutional1DTransform(intel_dnn_component_t* component) { if (4 != component->num_bytes_per_input) { THROW_GNA_EXCEPTION << "Bad data width: " << component->num_bytes_per_input; } @@ -120,33 +121,33 @@ void FP::ApplyConvolutional2DTransform(intel_dnn_component_t* component) { CNN2DFilter32(component); } -void FP::ApplyPiecewiseLinearTransform(intel_dnn_component_t *component, - intel_dnn_number_type_t number_type, - uint32_t listsize) { +void FP::ApplyPiecewiseLinearTransform(intel_dnn_component_t* component, + intel_dnn_number_type_t number_type, + uint32_t listsize) { if (kDnnFloat != number_type) { THROW_GNA_EXCEPTION << "Bad number type: " << number_type; } PwlApply32(component, listsize); } -void FP::ApplyPiecewiseLinearTransform(intel_dnn_component_t *component, - intel_dnn_number_type_t number_type, - uint32_t listsize, - uint32_t num_row) { +void FP::ApplyPiecewiseLinearTransform(intel_dnn_component_t* component, + intel_dnn_number_type_t number_type, + uint32_t listsize, + uint32_t num_row) { if (kDnnFloat != number_type) { THROW_GNA_EXCEPTION << "Bad number type: " << number_type; } PwlApply32(component, num_row, num_row, 0, listsize - 1); } -void FP::ApplyMaxPoolTransform(intel_dnn_component_t *component, intel_dnn_number_type_t number_type) { +void FP::ApplyMaxPoolTransform(intel_dnn_component_t* component, intel_dnn_number_type_t number_type) { if (4 != component->num_bytes_per_input) { THROW_GNA_EXCEPTION << "Bad data width: " << component->num_bytes_per_input; } CNNMaxPool(component, number_type); } -void FP::ApplyTranspose(intel_dnn_component_t *component) { +void FP::ApplyTranspose(intel_dnn_component_t* component) { if (4 != component->num_bytes_per_input) { THROW_GNA_EXCEPTION << "Bad data width: " << component->num_bytes_per_input; } @@ -156,8 +157,8 @@ void FP::ApplyTranspose(intel_dnn_component_t *component) { uint32_t lda = component->num_columns_in; uint32_t ldb = component->num_columns_out; // B = Transpose(A) where A is mxn and B is nxm - auto A = reinterpret_cast(component->ptr_inputs); - auto B = reinterpret_cast(component->ptr_outputs); + auto A = reinterpret_cast(component->ptr_inputs); + auto B = reinterpret_cast(component->ptr_outputs); for (uint32_t row = 0; row < m; row++) { for (uint32_t col = 0; col < n; col++) { B[col * ldb + row] = A[row * lda + col]; @@ -165,13 +166,13 @@ void FP::ApplyTranspose(intel_dnn_component_t *component) { } } -void FP::ApplyCopy(intel_dnn_component_t *component) { +void FP::ApplyCopy(intel_dnn_component_t* component) { if (4 != component->num_bytes_per_input) { THROW_GNA_EXCEPTION << "Bad data width: " << component->num_bytes_per_input; } - auto src = reinterpret_cast(component->ptr_inputs); - auto dst = reinterpret_cast(component->ptr_outputs); + auto src = reinterpret_cast(component->ptr_inputs); + auto dst = reinterpret_cast(component->ptr_outputs); uint32_t m = component->op.copy.num_copy_rows; uint32_t n = component->op.copy.num_copy_columns; uint32_t lda = component->num_columns_in; @@ -179,11 +180,15 @@ void FP::ApplyCopy(intel_dnn_component_t *component) { if (m > component->num_rows_in) { THROW_GNA_EXCEPTION << "Error: attempt to copy more columns than matrix has"; } - auto A = reinterpret_cast(src); - auto B = reinterpret_cast(dst); + auto A = reinterpret_cast(src); + auto B = reinterpret_cast(dst); for (uint32_t row = 0; row < m; row++) { for (uint32_t col = 0; col < n; col++) { B[row * ldb + col] = A[row * lda + col]; } } } + +} // namespace runtime +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/runtime/pwl.cpp b/src/plugins/intel_gna/src/runtime/pwl.cpp index 4fcae51c20f..4b066b6fed2 100644 --- a/src/plugins/intel_gna/src/runtime/pwl.cpp +++ b/src/plugins/intel_gna/src/runtime/pwl.cpp @@ -28,7 +28,7 @@ #include "pwl.h" #include "log/debug.hpp" #include "log/log.hpp" -#include "gna_slope_scale.h" +#include "gna_slope_scale.hpp" #include "common/numerical_utils.hpp" #include "ops/reference/pwl.hpp" diff --git a/src/plugins/intel_gna/src/runtime/pwl.h b/src/plugins/intel_gna/src/runtime/pwl.h index d2355c5e772..099cc79d748 100644 --- a/src/plugins/intel_gna/src/runtime/pwl.h +++ b/src/plugins/intel_gna/src/runtime/pwl.h @@ -8,8 +8,8 @@ #include #include -#include "backend/dnn_types.h" -#include "backend/gna_types.h" +#include "backend/dnn_types.hpp" +#include "backend/gna_types.hpp" #define SIGMOID_NUM_SEGMENTS 65 #define SIGMOID_DOMAIN 10.0f // portion of input to be approximated (-10,10) diff --git a/src/plugins/intel_gna/src/scale_factor_helper.cpp b/src/plugins/intel_gna/src/scale_factor_helper.cpp index e63aa183e76..5dcbdab72ac 100644 --- a/src/plugins/intel_gna/src/scale_factor_helper.cpp +++ b/src/plugins/intel_gna/src/scale_factor_helper.cpp @@ -9,7 +9,7 @@ #include "log/log.hpp" namespace ov { -namespace intela_gna { +namespace intel_gna { using namespace common; namespace helpers { @@ -20,7 +20,7 @@ static bool IsCustomInputScaleFactorAvailableLegacy(const std::vector& in bool is_scale_factor_custom = false; for (const auto& scale_factor : input_scale_factors) { - if (!AreFpEq(scale_factor, GNAPluginNS::kScaleFactorDefault)) { + if (!AreFpEq(scale_factor, kScaleFactorDefault)) { is_scale_factor_custom = true; break; } @@ -29,7 +29,7 @@ static bool IsCustomInputScaleFactorAvailableLegacy(const std::vector& in return is_scale_factor_custom; } -static void ApplyScaleFactorsLegacy(const std::vector& input_scale_factors, GNAPluginNS::GnaInputs& inputs) { +static void ApplyScaleFactorsLegacy(const std::vector& input_scale_factors, GnaInputs& inputs) { if (input_scale_factors.size() > inputs.size()) { IE_THROW() << "Configuration input scale factors count is bigger than inputs count"; } @@ -48,7 +48,7 @@ static bool IsCustomInputScaleFactorPerInputAvailable(const std::map& per_input_scale_factors, - GNAPluginNS::GnaInputs& inputs) { + GnaInputs& inputs) { if (per_input_scale_factors.size() > inputs.size()) { IE_THROW() << "Configuration per input scale factors count is bigger than inputs count"; } @@ -74,9 +74,9 @@ static void ApplyScaleFactorsPerInput(const std::map& per_in } } -static bool CheckIfCanApplyCustomScaleFactor(const GNAPluginNS::HeaderLatest::ModelHeader& header) { - static constexpr GNAPluginNS::Header2dot8::ModelHeader::Version sc_forbid_override_scale_factor; - if (!GNAPluginNS::HeaderLatest::IsFirstVersionLower(header.version, sc_forbid_override_scale_factor)) { +static bool CheckIfCanApplyCustomScaleFactor(const header_latest::ModelHeader& header) { + static constexpr header_2_dot_8::ModelHeader::Version sc_forbid_override_scale_factor; + if (!header_latest::IsFirstVersionLower(header.version, sc_forbid_override_scale_factor)) { ::log::warning() << "Cannot apply custom scale factor for model versions >= " << sc_forbid_override_scale_factor.major << "." << sc_forbid_override_scale_factor.minor << std::endl; @@ -85,9 +85,9 @@ static bool CheckIfCanApplyCustomScaleFactor(const GNAPluginNS::HeaderLatest::Mo return true; } -void ApplyInputScaleFactors(const GNAPluginNS::Config& config, - const GNAPluginNS::HeaderLatest::ModelHeader& header, - GNAPluginNS::GnaInputs& inputs) { +void ApplyInputScaleFactors(const Config& config, + const header_latest::ModelHeader& header, + GnaInputs& inputs) { // If scale factors are defined in configuration we still need to use them instead of imported values, // for example to change the scale factors for the old models. const bool custom_scale_factor_per_input = @@ -102,7 +102,7 @@ void ApplyInputScaleFactors(const GNAPluginNS::Config& config, return; } - // Due the fact inputScaleFactors is set by defuault construcor of GNAPluginNS::Config + // Due the fact inputScaleFactors is set by defuault construcor of Config // we need to check is_intput_scale_factor_per_input_given as first. if (custom_scale_factor_per_input) { ApplyScaleFactorsPerInput(config.inputScaleFactorsPerInput, inputs); @@ -113,5 +113,5 @@ void ApplyInputScaleFactors(const GNAPluginNS::Config& config, } } // namespace helpers -} // namespace intela_gna +} // namespace intel_gna } // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_gna/src/scale_factor_helper.hpp b/src/plugins/intel_gna/src/scale_factor_helper.hpp index f84997a5553..5a9bac6eaf4 100644 --- a/src/plugins/intel_gna/src/scale_factor_helper.hpp +++ b/src/plugins/intel_gna/src/scale_factor_helper.hpp @@ -9,21 +9,20 @@ #include "descriptions/gna_desc.hpp" #include "serial/headers/latest/gna_model_header.hpp" -namespace GNAPluginNS { -class Config; -}; // namespace GNAPluginNS - namespace ov { -namespace intela_gna { +namespace intel_gna { + +class Config; + /** * @namespace helpers contains helpers tools for gna plugin. */ namespace helpers { -void ApplyInputScaleFactors(const GNAPluginNS::Config& config, - const GNAPluginNS::HeaderLatest::ModelHeader& header, - GNAPluginNS::GnaInputs& inputs); +void ApplyInputScaleFactors(const Config& config, + const header_latest::ModelHeader& header, + GnaInputs& inputs); } // namespace helpers -} // namespace intela_gna +} // namespace intel_gna } // namespace ov \ No newline at end of file diff --git a/src/plugins/intel_gna/src/serial/headers/2dot1/gna_model_header.hpp b/src/plugins/intel_gna/src/serial/headers/2dot1/gna_model_header.hpp index 3cc4ce232c0..91b9e684cdb 100644 --- a/src/plugins/intel_gna/src/serial/headers/2dot1/gna_model_header.hpp +++ b/src/plugins/intel_gna/src/serial/headers/2dot1/gna_model_header.hpp @@ -5,14 +5,14 @@ #pragma once #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #pragma pack(push, 1) -namespace GNAPluginNS { -namespace Header2dot1 { - +namespace ov { +namespace intel_gna { +namespace header_2_dot_1 { /** * @brief Header version 2.1 @@ -89,7 +89,7 @@ struct RuntimeEndPoint { uint32_t elements_count = 0; /** * Offset in bytes of pointer descriptor - */ + */ uint64_t descriptor_offset = 0ull; intel_dnn_orientation_t orientation = kDnnUnknownOrientation; @@ -99,12 +99,14 @@ struct RuntimeEndPoint { void* descriptor_ptr, uint32_t element_size, uint32_t elements_count, - intel_dnn_orientation_t orientation) : scaleFactor(static_cast(scaleFactor)), - descriptor_ptr(descriptor_ptr), - element_size(element_size), - elements_count(elements_count), - orientation(orientation) { - } + intel_dnn_orientation_t orientation) + : scaleFactor(static_cast(scaleFactor)), + descriptor_ptr(descriptor_ptr), + element_size(element_size), + elements_count(elements_count), + orientation(orientation) {} }; -} // namespace Header2dot1 -} // namespace GNAPluginNS + +} // namespace header_2_dot_1 +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/serial/headers/2dot2/gna_model_header.hpp b/src/plugins/intel_gna/src/serial/headers/2dot2/gna_model_header.hpp index 2eba8207799..7ae9926b2ff 100644 --- a/src/plugins/intel_gna/src/serial/headers/2dot2/gna_model_header.hpp +++ b/src/plugins/intel_gna/src/serial/headers/2dot2/gna_model_header.hpp @@ -5,15 +5,15 @@ #pragma once #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include "serial/headers/2dot1/gna_model_header.hpp" #pragma pack(push, 1) -namespace GNAPluginNS { -namespace Header2dot2 { - +namespace ov { +namespace intel_gna { +namespace heaser_2_dot_2 { /** * @brief Header version 2.2 @@ -67,7 +67,7 @@ struct ModelHeader { * Reserved Data might be here */ ModelHeader() = default; - ModelHeader(GNAPluginNS::Header2dot1::ModelHeader const &old) { + ModelHeader(header_2_dot_1::ModelHeader const& old) { gnaMemSize = old.gnaMemSize; layersCount = old.layersCount; nGroup = old.nGroup; @@ -101,7 +101,7 @@ struct RuntimeEndPoint { uint32_t elements_count = 0; /** * Offset in bytes of pointer descriptor - */ + */ uint64_t descriptor_offset = 0ull; intel_dnn_orientation_t orientation = kDnnUnknownOrientation; @@ -111,12 +111,14 @@ struct RuntimeEndPoint { void* descriptor_ptr, uint32_t element_size, uint32_t elements_count, - intel_dnn_orientation_t orientation) : scaleFactor(scaleFactor), - descriptor_ptr(descriptor_ptr), - element_size(element_size), - elements_count(elements_count), - orientation(orientation) { - } + intel_dnn_orientation_t orientation) + : scaleFactor(scaleFactor), + descriptor_ptr(descriptor_ptr), + element_size(element_size), + elements_count(elements_count), + orientation(orientation) {} }; -} // namespace Header2dot2 -} // namespace GNAPluginNS + +} // namespace heaser_2_dot_2 +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/serial/headers/2dot3/gna_model_header.hpp b/src/plugins/intel_gna/src/serial/headers/2dot3/gna_model_header.hpp index ede9a9aecd9..80fe8f0b9b4 100644 --- a/src/plugins/intel_gna/src/serial/headers/2dot3/gna_model_header.hpp +++ b/src/plugins/intel_gna/src/serial/headers/2dot3/gna_model_header.hpp @@ -5,15 +5,15 @@ #pragma once #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include "serial/headers/2dot1/gna_model_header.hpp" #pragma pack(push, 1) -namespace GNAPluginNS { -namespace Header2dot3 { - +namespace ov { +namespace intel_gna { +namespace header_2_dot_3 { /** * @brief Header version 2.3 @@ -67,7 +67,7 @@ struct ModelHeader { * Reserved Data might be here */ ModelHeader() = default; - ModelHeader(GNAPluginNS::Header2dot1::ModelHeader const &old) { + ModelHeader(header_2_dot_1::ModelHeader const& old) { gnaMemSize = old.gnaMemSize; layersCount = old.layersCount; nGroup = old.nGroup; @@ -101,7 +101,7 @@ struct RuntimeEndPoint { uint32_t elements_count = 0; /** * Offset in bytes of pointer descriptor - */ + */ uint64_t descriptor_offset = 0ull; intel_dnn_orientation_t orientation = kDnnUnknownOrientation; @@ -111,12 +111,14 @@ struct RuntimeEndPoint { void* descriptor_ptr, uint32_t element_size, uint32_t elements_count, - intel_dnn_orientation_t orientation) : scaleFactor(static_cast(scaleFactor)), - descriptor_ptr(descriptor_ptr), - element_size(element_size), - elements_count(elements_count), - orientation(orientation) { - } + intel_dnn_orientation_t orientation) + : scaleFactor(static_cast(scaleFactor)), + descriptor_ptr(descriptor_ptr), + element_size(element_size), + elements_count(elements_count), + orientation(orientation) {} }; -} // namespace Header2dot3 -} // namespace GNAPluginNS + +} // namespace header_2_dot_3 +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/serial/headers/2dot4/gna_model_header.hpp b/src/plugins/intel_gna/src/serial/headers/2dot4/gna_model_header.hpp index 88ab261b695..8d2edcdfa15 100644 --- a/src/plugins/intel_gna/src/serial/headers/2dot4/gna_model_header.hpp +++ b/src/plugins/intel_gna/src/serial/headers/2dot4/gna_model_header.hpp @@ -5,15 +5,15 @@ #pragma once #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include "serial/headers/2dot3/gna_model_header.hpp" #pragma pack(push, 1) -namespace GNAPluginNS { -namespace Header2dot4 { - +namespace ov { +namespace intel_gna { +namespace header_2_dot_4 { /** * @brief Header version 2.4 @@ -74,7 +74,7 @@ struct ModelHeader { * Reserved Data might be here */ ModelHeader() = default; - ModelHeader(GNAPluginNS::Header2dot1::ModelHeader const &old) { + ModelHeader(header_2_dot_1::ModelHeader const& old) { gnaMemSize = old.gnaMemSize; layersCount = old.layersCount; nGroup = old.nGroup; @@ -84,7 +84,7 @@ struct ModelHeader { nOutputs = old.nOutputs; version.minor = old.version.minor; } - ModelHeader(GNAPluginNS::Header2dot3::ModelHeader const &old) { + ModelHeader(header_2_dot_3::ModelHeader const& old) { gnaMemSize = old.gnaMemSize; layersCount = old.layersCount; nGroup = old.nGroup; @@ -119,7 +119,7 @@ struct RuntimeEndPoint { uint32_t elements_count = 0; /** * Offset in bytes of pointer descriptor - */ + */ uint64_t descriptor_offset = 0ull; intel_dnn_orientation_t orientation = kDnnUnknownOrientation; @@ -129,11 +129,14 @@ struct RuntimeEndPoint { void* descriptor_ptr, uint32_t element_size, uint32_t elements_count, - intel_dnn_orientation_t orientation) : scaleFactor(static_cast(scaleFactor)), - descriptor_ptr(descriptor_ptr), - element_size(element_size), - elements_count(elements_count), - orientation(orientation) { } + intel_dnn_orientation_t orientation) + : scaleFactor(static_cast(scaleFactor)), + descriptor_ptr(descriptor_ptr), + element_size(element_size), + elements_count(elements_count), + orientation(orientation) {} }; -} // namespace Header2dot4 -} // namespace GNAPluginNS + +} // namespace header_2_dot_4 +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/serial/headers/2dot5/gna_model_header.hpp b/src/plugins/intel_gna/src/serial/headers/2dot5/gna_model_header.hpp index 87122189299..96c020d415c 100644 --- a/src/plugins/intel_gna/src/serial/headers/2dot5/gna_model_header.hpp +++ b/src/plugins/intel_gna/src/serial/headers/2dot5/gna_model_header.hpp @@ -6,13 +6,14 @@ #include #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include "serial/headers/2dot4/gna_model_header.hpp" #include "gna_data_types.hpp" #pragma pack(push, 1) -namespace GNAPluginNS { -namespace Header2dot5 { +namespace ov { +namespace intel_gna { +namespace header_2_dot_5 { /** * @brief Header version 2.5 @@ -77,7 +78,7 @@ struct ModelHeader { * Reserved Data might be here */ ModelHeader() = default; - ModelHeader(GNAPluginNS::Header2dot1::ModelHeader const &old) { + ModelHeader(header_2_dot_1::ModelHeader const& old) { gnaMemSize = old.gnaMemSize; layersCount = old.layersCount; nGroup = old.nGroup; @@ -87,7 +88,7 @@ struct ModelHeader { nOutputs = old.nOutputs; version.minor = old.version.minor; } - ModelHeader(GNAPluginNS::Header2dot4::ModelHeader const &old) { + ModelHeader(header_2_dot_4::ModelHeader const& old) { gnaMemSize = old.gnaMemSize; layersCount = old.layersCount; nGroup = old.nGroup; @@ -100,7 +101,7 @@ struct ModelHeader { doRotateOutput = old.doRotateOutput; version.minor = old.version.minor; } - ModelHeader(GNAPluginNS::Header2dot3::ModelHeader const &old) { + ModelHeader(header_2_dot_3::ModelHeader const& old) { gnaMemSize = old.gnaMemSize; layersCount = old.layersCount; nGroup = old.nGroup; @@ -135,7 +136,7 @@ struct RuntimeEndPoint { uint32_t elements_count = 0; /** * Offset in bytes of pointer descriptor - */ + */ uint64_t descriptor_offset = 0ull; intel_dnn_orientation_t orientation = kDnnUnknownOrientation; @@ -145,11 +146,14 @@ struct RuntimeEndPoint { void* descriptor_ptr, uint32_t element_size, uint32_t elements_count, - intel_dnn_orientation_t orientation) : scaleFactor(scaleFactor), - descriptor_ptr(descriptor_ptr), - element_size(element_size), - elements_count(elements_count), - orientation(orientation) { } + intel_dnn_orientation_t orientation) + : scaleFactor(scaleFactor), + descriptor_ptr(descriptor_ptr), + element_size(element_size), + elements_count(elements_count), + orientation(orientation) {} }; -} // namespace Header2dot5 -} // namespace GNAPluginNS + +} // namespace header_2_dot_5 +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/serial/headers/2dot6/gna_model_header.hpp b/src/plugins/intel_gna/src/serial/headers/2dot6/gna_model_header.hpp index 4b079bacd55..57d22717853 100644 --- a/src/plugins/intel_gna/src/serial/headers/2dot6/gna_model_header.hpp +++ b/src/plugins/intel_gna/src/serial/headers/2dot6/gna_model_header.hpp @@ -6,13 +6,14 @@ #include #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include "serial/headers/2dot4/gna_model_header.hpp" #include "gna_data_types.hpp" #pragma pack(push, 1) -namespace GNAPluginNS { -namespace Header2dot6 { +namespace ov { +namespace intel_gna { +namespace header_2_dot_6 { /** * @brief Header version 2.6 @@ -77,7 +78,7 @@ struct ModelHeader { * Reserved Data might be here */ ModelHeader() = default; - ModelHeader(GNAPluginNS::Header2dot1::ModelHeader const &old) { + ModelHeader(header_2_dot_1::ModelHeader const& old) { gnaMemSize = old.gnaMemSize; layersCount = old.layersCount; nGroup = old.nGroup; @@ -87,7 +88,7 @@ struct ModelHeader { nOutputs = old.nOutputs; version.minor = old.version.minor; } - ModelHeader(GNAPluginNS::Header2dot4::ModelHeader const &old) { + ModelHeader(header_2_dot_4::ModelHeader const& old) { gnaMemSize = old.gnaMemSize; layersCount = old.layersCount; nGroup = old.nGroup; @@ -125,7 +126,7 @@ struct RuntimeEndPoint { uint32_t elements_count = 0; /** * Offset in bytes of pointer descriptor - */ + */ uint64_t descriptor_offset = 0ull; intel_dnn_orientation_t orientation = kDnnUnknownOrientation; @@ -135,11 +136,14 @@ struct RuntimeEndPoint { void* descriptor_ptr, uint32_t element_size, uint32_t elements_count, - intel_dnn_orientation_t orientation) : scaleFactor(static_cast(scaleFactor)), - descriptor_ptr(descriptor_ptr), - element_size(element_size), - elements_count(elements_count), - orientation(orientation) { } + intel_dnn_orientation_t orientation) + : scaleFactor(static_cast(scaleFactor)), + descriptor_ptr(descriptor_ptr), + element_size(element_size), + elements_count(elements_count), + orientation(orientation) {} }; -} // namespace Header2dot6 -} // namespace GNAPluginNS + +} // namespace header_2_dot_6 +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/serial/headers/2dot7/gna_model_header.hpp b/src/plugins/intel_gna/src/serial/headers/2dot7/gna_model_header.hpp index b590cbe6d0d..64acce7d377 100644 --- a/src/plugins/intel_gna/src/serial/headers/2dot7/gna_model_header.hpp +++ b/src/plugins/intel_gna/src/serial/headers/2dot7/gna_model_header.hpp @@ -6,15 +6,16 @@ #include #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include "serial/headers/2dot4/gna_model_header.hpp" #include "serial/headers/2dot6/gna_model_header.hpp" #include "gna_data_types.hpp" #pragma pack(push, 1) -namespace GNAPluginNS { -namespace Header2dot7 { +namespace ov { +namespace intel_gna { +namespace header_2_dot_7 { /** Maximal number of supported shape dimensions. @@ -85,7 +86,7 @@ struct ModelHeader { * Reserved Data might be here */ ModelHeader() = default; - ModelHeader(GNAPluginNS::Header2dot1::ModelHeader const &old) { + ModelHeader(header_2_dot_1::ModelHeader const& old) { gnaMemSize = old.gnaMemSize; layersCount = old.layersCount; nGroup = old.nGroup; @@ -95,7 +96,7 @@ struct ModelHeader { nOutputs = old.nOutputs; version.minor = old.version.minor; } - ModelHeader(GNAPluginNS::Header2dot4::ModelHeader const &old) { + ModelHeader(header_2_dot_4::ModelHeader const& old) { gnaMemSize = old.gnaMemSize; layersCount = old.layersCount; nGroup = old.nGroup; @@ -133,7 +134,7 @@ struct RuntimeEndPoint { uint32_t elements_count = 0; /** * Offset in bytes of pointer descriptor - */ + */ uint64_t descriptor_offset = 0ull; /** Shape specifying dimension values. @@ -161,7 +162,7 @@ struct RuntimeEndPoint { intel_dnn_orientation_t orientation = kDnnUnknownOrientation; RuntimeEndPoint() = default; - RuntimeEndPoint(const GNAPluginNS::Header2dot6::RuntimeEndPoint &old, uint32_t ngroup) { + RuntimeEndPoint(const header_2_dot_6::RuntimeEndPoint& old, uint32_t ngroup) { scaleFactor = old.scaleFactor; descriptor_ptr = old.descriptor_ptr; element_size = old.element_size; @@ -183,15 +184,17 @@ struct RuntimeEndPoint { Shape shape, uint8_t layout, uint8_t precision, - intel_dnn_orientation_t orientation) : scaleFactor(static_cast(scaleFactor)), - descriptor_ptr(descriptor_ptr), - element_size(element_size), - elements_count(elements_count), - shape(shape), - layout(layout), - precision(precision), - orientation(orientation) { } + intel_dnn_orientation_t orientation) + : scaleFactor(static_cast(scaleFactor)), + descriptor_ptr(descriptor_ptr), + element_size(element_size), + elements_count(elements_count), + shape(shape), + layout(layout), + precision(precision), + orientation(orientation) {} }; -} // namespace Header2dot7 -} // namespace GNAPluginNS +} // namespace header_2_dot_7 +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/serial/headers/2dot8/gna_model_header.hpp b/src/plugins/intel_gna/src/serial/headers/2dot8/gna_model_header.hpp index dc6e332c61c..ab24a4e715d 100644 --- a/src/plugins/intel_gna/src/serial/headers/2dot8/gna_model_header.hpp +++ b/src/plugins/intel_gna/src/serial/headers/2dot8/gna_model_header.hpp @@ -6,14 +6,15 @@ #include #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include "serial/headers/2dot7/gna_model_header.hpp" #include "gna_data_types.hpp" #pragma pack(push, 1) -namespace GNAPluginNS { -namespace Header2dot8 { +namespace ov { +namespace intel_gna { +namespace header_2_dot_8 { /** Maximal number of supported shape dimensions. @@ -86,7 +87,7 @@ struct ModelHeader { ModelHeader() = default; - ModelHeader(GNAPluginNS::Header2dot1::ModelHeader const &old) { + ModelHeader(header_2_dot_1::ModelHeader const& old) { gnaMemSize = old.gnaMemSize; layersCount = old.layersCount; nGroup = old.nGroup; @@ -97,7 +98,7 @@ struct ModelHeader { version.minor = old.version.minor; } - ModelHeader(GNAPluginNS::Header2dot4::ModelHeader const &old) { + ModelHeader(header_2_dot_4::ModelHeader const& old) { gnaMemSize = old.gnaMemSize; layersCount = old.layersCount; nGroup = old.nGroup; @@ -135,7 +136,7 @@ struct RuntimeEndPoint { uint32_t elements_count = 0; /** * Offset in bytes of pointer descriptor - */ + */ uint64_t descriptor_offset = 0ull; /** Shape specifying dimension values. @@ -169,12 +170,12 @@ struct RuntimeEndPoint { RuntimeEndPoint() = default; // support of previous versions - RuntimeEndPoint(const GNAPluginNS::Header2dot6::RuntimeEndPoint &old, uint32_t ngroup) { - GNAPluginNS::Header2dot7::RuntimeEndPoint ep_v7 = GNAPluginNS::Header2dot7::RuntimeEndPoint(old, ngroup); - *this = GNAPluginNS::Header2dot8::RuntimeEndPoint(ep_v7); + RuntimeEndPoint(const header_2_dot_6::RuntimeEndPoint& old, uint32_t ngroup) { + header_2_dot_7::RuntimeEndPoint ep_v7 = header_2_dot_7::RuntimeEndPoint(old, ngroup); + *this = header_2_dot_8::RuntimeEndPoint(ep_v7); } - RuntimeEndPoint(GNAPluginNS::Header2dot7::RuntimeEndPoint &old) { + RuntimeEndPoint(header_2_dot_7::RuntimeEndPoint& old) { scaleFactor = old.scaleFactor; descriptor_ptr = old.descriptor_ptr; element_size = old.element_size; @@ -198,15 +199,18 @@ struct RuntimeEndPoint { uint8_t layout, uint8_t precision, uint8_t tensor_names_count, - intel_dnn_orientation_t orientation) : scaleFactor(static_cast(scaleFactor)), - descriptor_ptr(descriptor_ptr), - element_size(element_size), - elements_count(elements_count), - shape(shape), - layout(layout), - precision(precision), - tensor_names_count(tensor_names_count), - orientation(orientation) { } + intel_dnn_orientation_t orientation) + : scaleFactor(static_cast(scaleFactor)), + descriptor_ptr(descriptor_ptr), + element_size(element_size), + elements_count(elements_count), + shape(shape), + layout(layout), + precision(precision), + tensor_names_count(tensor_names_count), + orientation(orientation) {} }; -} // namespace Header2dot8 -} // namespace GNAPluginNS + +} // namespace header_2_dot_8 +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/serial/headers/latest/gna_model_header.hpp b/src/plugins/intel_gna/src/serial/headers/latest/gna_model_header.hpp index f2429264550..993f9f0142c 100644 --- a/src/plugins/intel_gna/src/serial/headers/latest/gna_model_header.hpp +++ b/src/plugins/intel_gna/src/serial/headers/latest/gna_model_header.hpp @@ -6,14 +6,18 @@ #include "serial/headers/2dot8/gna_model_header.hpp" -namespace GNAPluginNS { -namespace HeaderLatest { -using ModelHeader = GNAPluginNS::Header2dot8::ModelHeader; -using RuntimeEndPoint = GNAPluginNS::Header2dot8::RuntimeEndPoint; +namespace ov { +namespace intel_gna { +namespace header_latest { + +using ModelHeader = header_2_dot_8::ModelHeader; +using RuntimeEndPoint = header_2_dot_8::RuntimeEndPoint; template bool IsFirstVersionLower(const A& first, const B& second) { return first.major < second.major || (first.major == second.major && first.minor < second.minor); } -} // namespace HeaderLatest -} // namespace GNAPluginNS + +} // namespace header_latest +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/transformations/convert_matmul_to_pointwise_convolution.cpp b/src/plugins/intel_gna/src/transformations/convert_matmul_to_pointwise_convolution.cpp index 7c8a20a29b6..3d1d4e1b986 100644 --- a/src/plugins/intel_gna/src/transformations/convert_matmul_to_pointwise_convolution.cpp +++ b/src/plugins/intel_gna/src/transformations/convert_matmul_to_pointwise_convolution.cpp @@ -47,10 +47,10 @@ static std::tuple VerifyAndGetConvParams(std const uint32_t width = input1_shape.front(); const uint32_t in_channels = input2_shape.back(); const uint32_t out_channels = input2_shape.front(); - if (input1_shape.front() <= GNAPluginNS::GNALimitations::affineMaxBatchSize || - out_channels % GNAPluginNS::GNALimitations::convFiltersNumDivider != 0 || - out_channels > GNAPluginNS::GNALimitations::convMaxFiltersNum || - in_channels > GNAPluginNS::GNALimitations::convFilterMaxSize) { + if (input1_shape.front() <= limitations::affineMaxBatchSize || + out_channels % limitations::convFiltersNumDivider != 0 || + out_channels > limitations::convMaxFiltersNum || + in_channels > limitations::convFilterMaxSize) { return std::make_tuple(false, 0, 0, 0); } @@ -79,7 +79,7 @@ static bool Convert(std::shared_ptr matmul_node, auto transpose_before = std::make_shared(reshape_before, ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape{4}, - GNAPluginNS::GetPermuteOrder(InferenceEngine::Layout::NHWC, InferenceEngine::Layout::NCHW))); + permute::GetPermuteOrder(InferenceEngine::Layout::NHWC, InferenceEngine::Layout::NCHW))); transpose_before->set_friendly_name(base_name + "/transpose_in"); ngraph::copy_runtime_info(matmul_node, transpose_before); @@ -124,7 +124,7 @@ static bool Convert(std::shared_ptr matmul_node, auto transpose_after = std::make_shared(conv_node, ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape{4}, - GNAPluginNS::GetPermuteOrder(InferenceEngine::Layout::NCHW, InferenceEngine::Layout::NHWC))); + permute::GetPermuteOrder(InferenceEngine::Layout::NCHW, InferenceEngine::Layout::NHWC))); transpose_after->set_friendly_name(base_name + "/transpose_out"); ngraph::copy_runtime_info(conv_node, transpose_after); diff --git a/src/plugins/intel_gna/src/transformations/decompose_2d_convolution.cpp b/src/plugins/intel_gna/src/transformations/decompose_2d_convolution.cpp index bce630a44a1..a907b503f5c 100644 --- a/src/plugins/intel_gna/src/transformations/decompose_2d_convolution.cpp +++ b/src/plugins/intel_gna/src/transformations/decompose_2d_convolution.cpp @@ -17,10 +17,12 @@ #include "backend/gna_limitations.hpp" #include "layers/gna_convolution_layer.hpp" - -using namespace ov::intel_gna::pass; using namespace ov::intel_gna::pass::helper; +namespace ov { +namespace intel_gna { +namespace pass { + struct GraphData { std::shared_ptrleading_transpose; std::shared_ptrfq_filters; @@ -53,7 +55,7 @@ static bool VerifyAndGetConvData(std::shared_ptr co size_t filter_height = filters.get_shape()[2]; size_t filter_width = filters.get_shape()[3]; - if (filter_width > GNAPluginNS::GNALimitations::copyMaxGrouping || filter_height > GNAPluginNS::GNALimitations::copyMaxGrouping) { + if (filter_width > limitations::copyMaxGrouping || filter_height > limitations::copyMaxGrouping) { return false; } @@ -75,7 +77,7 @@ static bool VerifyMaxPool(GraphData& graph_data, std::shared_ptrget_pads_begin() != ngraph::Shape({0, 0}) || max_pool->get_pads_end() != ngraph::Shape({0, 0}))) || pool_filter.size() != 2 || pool_strides.size() != 2 || pool_filter[0] > 1 || pool_strides[0] > 1 || - pool_filter[0] > GNAPluginNS::GNALimitations::maxPoolMaxWindowSize) + pool_filter[0] > limitations::maxPoolMaxWindowSize) return false; graph_data.pool_size_width = pool_filter[1]; @@ -86,7 +88,7 @@ static bool VerifyMaxPool(GraphData& graph_data, std::shared_ptr GNAPluginNS::GNALimitations::convFilterMaxSize || + while (total_factorized_conv_channel_count / conv_count > limitations::convFilterMaxSize || total_factorized_conv_channel_count % conv_count != 0 || conv_data.filter_channel_count % conv_count != 0) conv_count++; @@ -126,14 +128,14 @@ static bool ShouldDecompose(GraphData& graph_data, const ConvData& conv_data) { // Concat (copy) layer limitation allows to split up to a certain limit // Currently we are able to split only convolutions without pooling in horizontal dimension - if (graph_data.conv_count > GNAPluginNS::GNALimitations::copyMaxGrouping || + if (graph_data.conv_count > limitations::copyMaxGrouping || ((graph_data.pool_size_width > 1 || graph_data.pool_stride_width > 1) && graph_data.conv_count > 1)) return false; // GNA supported features or handled otherwise - there is no need to decompose such convolution if (graph_data.conv_count == 1 && (((conv_data.input_height == 1 || conv_data.input_width == 1) && conv_data.filter_dilation_width == 1 && conv_data.filter_dilation_height == 1) || - GNAPluginNS::GNAConvolutionLayer::isMappableFrom2DTo1D(conv_data.input_height, conv_data.input_width, conv_data.input_channel_count, + gna_convolution_layer::isMappableFrom2DTo1D(conv_data.input_height, conv_data.input_width, conv_data.input_channel_count, conv_data.filter_height, conv_data.filter_width, conv_data.filter_stride_height, conv_data.filter_stride_width))) return false; @@ -682,3 +684,7 @@ Decompose2DConvTransposedWithBiasAF::Decompose2DConvTransposedWithBiasAF(const s auto m = std::make_shared(af, matcher_name); this->register_matcher(m, callback); } + +} // namespace pass +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/transformations/decompose_mvn.cpp b/src/plugins/intel_gna/src/transformations/decompose_mvn.cpp index d13f55a8663..b1e43e9ef03 100644 --- a/src/plugins/intel_gna/src/transformations/decompose_mvn.cpp +++ b/src/plugins/intel_gna/src/transformations/decompose_mvn.cpp @@ -12,10 +12,12 @@ #include #include "backend/gna_limitations.hpp" - -using namespace ov::intel_gna::pass; using namespace ngraph; +namespace ov { +namespace intel_gna { +namespace pass { + struct MVNData { size_t N; size_t C; @@ -59,8 +61,8 @@ static bool GetVerifiedMVNData(const std::shared_ptr mvn, MVNData& IE_ASSERT(axes_const); auto element_type = axes_const->get_element_type(); - if (!(element_type == element::Type_t::i64 ? ValidateAxes(axes_const, mvn_shape_size) : - ValidateAxes(axes_const, mvn_shape_size))) + if (!(element_type == element::Type_t::i64 ? ValidateAxes(axes_const, mvn_shape_size) + : ValidateAxes(axes_const, mvn_shape_size))) return false; if (mvn_shape_size == 4) { @@ -79,7 +81,7 @@ static bool GetVerifiedMVNData(const std::shared_ptr mvn, MVNData& // Check if average must be split mvn_data.num_parts = 1; - while (mvn_data.W / mvn_data.num_parts > GNAPluginNS::GNALimitations::convFilterMaxSize) { + while (mvn_data.W / mvn_data.num_parts > limitations::convFilterMaxSize) { mvn_data.num_parts *= 2; } @@ -97,40 +99,71 @@ static bool GetVerifiedMVNData(const std::shared_ptr mvn, MVNData& return true; } -static std::shared_ptr NormalizeVariance(const std::shared_ptr mvn, const MVNData& mvn_data, - const std::shared_ptr& subtract_mean, const std::shared_ptr& avg_broadcast_const) { +static std::shared_ptr NormalizeVariance(const std::shared_ptr mvn, + const MVNData& mvn_data, + const std::shared_ptr& subtract_mean, + const std::shared_ptr& avg_broadcast_const) { // Prepare consts auto combined_C_H = mvn_data.C * mvn_data.H; std::vector avg_weights(8 * mvn_data.W / mvn_data.num_parts, 1.0f / mvn_data.W); - auto avg_weights_const = opset8::Constant::create(mvn_data.element_type, Shape{8, mvn_data.W / mvn_data.num_parts, 1, 1}, avg_weights); + auto avg_weights_const = + opset8::Constant::create(mvn_data.element_type, Shape{8, mvn_data.W / mvn_data.num_parts, 1, 1}, avg_weights); std::vector eps_tensor(combined_C_H * mvn_data.W, mvn_data.eps); - auto eps_tensor_const = opset8::Constant::create(mvn_data.element_type, Shape{1, combined_C_H * mvn_data.W}, eps_tensor); + auto eps_tensor_const = + opset8::Constant::create(mvn_data.element_type, Shape{1, combined_C_H * mvn_data.W}, eps_tensor); std::vector minus_half(combined_C_H * mvn_data.W, -0.5f); - auto minus_half_const = opset8::Constant::create(mvn_data.element_type, Shape{1, combined_C_H * mvn_data.W}, minus_half); + auto minus_half_const = + opset8::Constant::create(mvn_data.element_type, Shape{1, combined_C_H * mvn_data.W}, minus_half); // Calculate square of the difference between input and its mean auto squared_diff = std::make_shared(subtract_mean, subtract_mean); squared_diff->set_friendly_name(mvn_data.name + "_SqrDiff"); // Calculate sum of the squares - auto squared_diff_reshape = std::make_shared(squared_diff, - opset8::Constant::create(element::i64, Shape{4}, Shape{mvn_data.N, combined_C_H * mvn_data.num_parts, 1ull, mvn_data.W / mvn_data.num_parts}), false); - auto transposed_input_3 = std::make_shared(squared_diff_reshape, opset8::Constant::create(element::i64, Shape{4}, {0, 3, 1, 2})); - auto transposed_avg_conv_3 = std::make_shared(transposed_input_3, avg_weights_const, - Strides{1, 1}, CoordinateDiff{0, 0}, CoordinateDiff{0, 0}, Strides{1, 1}, op::PadType::VALID); + auto squared_diff_reshape = std::make_shared( + squared_diff, + opset8::Constant::create( + element::i64, + Shape{4}, + Shape{mvn_data.N, combined_C_H * mvn_data.num_parts, 1ull, mvn_data.W / mvn_data.num_parts}), + false); + auto transposed_input_3 = + std::make_shared(squared_diff_reshape, + opset8::Constant::create(element::i64, Shape{4}, {0, 3, 1, 2})); + auto transposed_avg_conv_3 = std::make_shared(transposed_input_3, + avg_weights_const, + Strides{1, 1}, + CoordinateDiff{0, 0}, + CoordinateDiff{0, 0}, + Strides{1, 1}, + op::PadType::VALID); transposed_avg_conv_3->set_friendly_name(mvn_data.name + "_Avg3"); - auto avg_conv_3 = std::make_shared(transposed_avg_conv_3, opset8::Constant::create(element::i64, Shape{4}, {0, 2, 3, 1})); - auto reshape_avg_conv_3 = std::make_shared(avg_conv_3, - opset8::Constant::create(element::i64, Shape{4}, Shape{mvn_data.N, 1ull, combined_C_H, 8 * mvn_data.num_parts}), false); - auto transposed_input_4 = std::make_shared(reshape_avg_conv_3, opset8::Constant::create(element::i64, Shape{4}, {0, 3, 1, 2})); + auto avg_conv_3 = + std::make_shared(transposed_avg_conv_3, + opset8::Constant::create(element::i64, Shape{4}, {0, 2, 3, 1})); + auto reshape_avg_conv_3 = std::make_shared( + avg_conv_3, + opset8::Constant::create(element::i64, Shape{4}, Shape{mvn_data.N, 1ull, combined_C_H, 8 * mvn_data.num_parts}), + false); + auto transposed_input_4 = + std::make_shared(reshape_avg_conv_3, + opset8::Constant::create(element::i64, Shape{4}, {0, 3, 1, 2})); auto transposed_avg_conv_4 = std::make_shared(transposed_input_4, - avg_broadcast_const, Strides{1, 1}, CoordinateDiff{0, 0}, CoordinateDiff{0, 0}, Strides{1, 1}, op::PadType::VALID); + avg_broadcast_const, + Strides{1, 1}, + CoordinateDiff{0, 0}, + CoordinateDiff{0, 0}, + Strides{1, 1}, + op::PadType::VALID); transposed_avg_conv_4->set_friendly_name(mvn_data.name + "_Avg4"); - auto avg_conv_4 = std::make_shared(transposed_avg_conv_4, - opset8::Constant::create(element::i64, Shape{4}, {0, 2, 3, 1})); - auto reshape_avg_conv_4 = std::make_shared(avg_conv_4, - opset8::Constant::create(element::i64, Shape{2}, Shape{1ull, combined_C_H * mvn_data.W}), false); + auto avg_conv_4 = + std::make_shared(transposed_avg_conv_4, + opset8::Constant::create(element::i64, Shape{4}, {0, 2, 3, 1})); + auto reshape_avg_conv_4 = std::make_shared( + avg_conv_4, + opset8::Constant::create(element::i64, Shape{2}, Shape{1ull, combined_C_H * mvn_data.W}), + false); std::shared_ptr inv_stdev; // Create normalization part of the graph @@ -152,8 +185,17 @@ static std::shared_ptr NormalizeVariance(const std::shared_ptr(subtract_mean, inv_stdev); normalized_output->set_friendly_name(mvn_data.name + "_Output"); - copy_runtime_info(mvn, {squared_diff, squared_diff_reshape, transposed_input_3, transposed_avg_conv_3, avg_conv_3, reshape_avg_conv_3, - transposed_input_4, transposed_avg_conv_4, avg_conv_4, reshape_avg_conv_4}); + copy_runtime_info(mvn, + {squared_diff, + squared_diff_reshape, + transposed_input_3, + transposed_avg_conv_3, + avg_conv_3, + reshape_avg_conv_3, + transposed_input_4, + transposed_avg_conv_4, + avg_conv_4, + reshape_avg_conv_4}); return normalized_output; } @@ -163,38 +205,70 @@ static void Decompose(const std::shared_ptr mvn, const MVNData& mvn auto combined_C_H = mvn_data.C * mvn_data.H; std::vector neg_avg_weights(8 * mvn_data.W / mvn_data.num_parts, -1.0f / mvn_data.W); - auto neg_avg_weights_const = opset8::Constant::create(mvn_data.element_type, Shape{8, mvn_data.W / mvn_data.num_parts, 1, 1}, neg_avg_weights); + auto neg_avg_weights_const = opset8::Constant::create(mvn_data.element_type, + Shape{8, mvn_data.W / mvn_data.num_parts, 1, 1}, + neg_avg_weights); std::vector avg_broadcast(8 * mvn_data.W * mvn_data.num_parts, 0.0f); for (size_t i = 0; i < mvn_data.W * mvn_data.num_parts; i++) { avg_broadcast[i * 8] = 1.0f; } - auto avg_broadcast_const = opset8::Constant::create(mvn_data.element_type, Shape{mvn_data.W, 8 * mvn_data.num_parts, 1, 1}, avg_broadcast); + auto avg_broadcast_const = + opset8::Constant::create(mvn_data.element_type, Shape{mvn_data.W, 8 * mvn_data.num_parts, 1, 1}, avg_broadcast); // Create average calculation part of the graph // We assume C = 1 case (combined channels) const auto input = mvn->input_value(0); - auto reshape = std::make_shared(input, - opset8::Constant::create(element::i64, Shape{4}, Shape{mvn_data.N, 1ull, combined_C_H, mvn_data.W}), false); - auto input_4d = std::make_shared(reshape, - opset8::Constant::create(element::i64, Shape{4}, Shape{mvn_data.N, combined_C_H * mvn_data.num_parts, 1ull, mvn_data.W / mvn_data.num_parts}), false); - auto input_2d = std::make_shared(reshape, - opset8::Constant::create(element::i64, Shape{2}, Shape{1ull, combined_C_H * mvn_data.W}), false); - auto transposed_input_1 = std::make_shared(input_4d, opset8::Constant::create(element::i64, Shape{4}, {0, 3, 1, 2})); - auto transposed_avg_conv_1 = std::make_shared(transposed_input_1, neg_avg_weights_const, - Strides{1, 1}, CoordinateDiff{0, 0}, CoordinateDiff{0, 0}, Strides{1, 1}, op::PadType::VALID); + auto reshape = std::make_shared( + input, + opset8::Constant::create(element::i64, Shape{4}, Shape{mvn_data.N, 1ull, combined_C_H, mvn_data.W}), + false); + auto input_4d = std::make_shared( + reshape, + opset8::Constant::create( + element::i64, + Shape{4}, + Shape{mvn_data.N, combined_C_H * mvn_data.num_parts, 1ull, mvn_data.W / mvn_data.num_parts}), + false); + auto input_2d = std::make_shared( + reshape, + opset8::Constant::create(element::i64, Shape{2}, Shape{1ull, combined_C_H * mvn_data.W}), + false); + auto transposed_input_1 = + std::make_shared(input_4d, opset8::Constant::create(element::i64, Shape{4}, {0, 3, 1, 2})); + auto transposed_avg_conv_1 = std::make_shared(transposed_input_1, + neg_avg_weights_const, + Strides{1, 1}, + CoordinateDiff{0, 0}, + CoordinateDiff{0, 0}, + Strides{1, 1}, + op::PadType::VALID); transposed_avg_conv_1->set_friendly_name(mvn_data.name + "_Avg1"); - auto avg_conv_1 = std::make_shared(transposed_avg_conv_1, opset8::Constant::create(element::i64, Shape{4}, {0, 2, 3, 1})); - auto reshape_avg_conv_1 = std::make_shared(avg_conv_1, - opset8::Constant::create(element::i64, Shape{4}, Shape{mvn_data.N, 1ull, combined_C_H, 8 * mvn_data.num_parts}), false); - auto transposed_input_2 = std::make_shared(reshape_avg_conv_1, opset8::Constant::create(element::i64, Shape{4}, {0, 3, 1, 2})); + auto avg_conv_1 = + std::make_shared(transposed_avg_conv_1, + opset8::Constant::create(element::i64, Shape{4}, {0, 2, 3, 1})); + auto reshape_avg_conv_1 = std::make_shared( + avg_conv_1, + opset8::Constant::create(element::i64, Shape{4}, Shape{mvn_data.N, 1ull, combined_C_H, 8 * mvn_data.num_parts}), + false); + auto transposed_input_2 = + std::make_shared(reshape_avg_conv_1, + opset8::Constant::create(element::i64, Shape{4}, {0, 3, 1, 2})); auto transposed_avg_conv_2 = std::make_shared(transposed_input_2, - avg_broadcast_const, Strides{1, 1}, CoordinateDiff{0, 0}, CoordinateDiff{0, 0}, Strides{1, 1}, op::PadType::VALID); + avg_broadcast_const, + Strides{1, 1}, + CoordinateDiff{0, 0}, + CoordinateDiff{0, 0}, + Strides{1, 1}, + op::PadType::VALID); transposed_avg_conv_2->set_friendly_name(mvn_data.name + "_Avg2"); - auto avg_conv_2 = std::make_shared(transposed_avg_conv_2, - opset8::Constant::create(element::i64, Shape{4}, {0, 2, 3, 1})); - auto avg_conv_2_2d = std::make_shared(avg_conv_2, - opset8::Constant::create(element::i64, Shape{2}, Shape{1ull, combined_C_H * mvn_data.W}), false); + auto avg_conv_2 = + std::make_shared(transposed_avg_conv_2, + opset8::Constant::create(element::i64, Shape{4}, {0, 2, 3, 1})); + auto avg_conv_2_2d = std::make_shared( + avg_conv_2, + opset8::Constant::create(element::i64, Shape{2}, Shape{1ull, combined_C_H * mvn_data.W}), + false); auto subtract_mean = std::make_shared(input_2d, avg_conv_2_2d); subtract_mean->set_friendly_name(mvn_data.name + "_SubMean"); @@ -207,15 +281,31 @@ static void Decompose(const std::shared_ptr mvn, const MVNData& mvn // Reshape (combined channels) back to get the final output if (mvn->get_output_shape(0).size() == 3) { - mvn_output = std::make_shared(pre_output, - opset8::Constant::create(element::i64, Shape{3}, {mvn_data.C, mvn_data.H, mvn_data.W}), false); + mvn_output = std::make_shared( + pre_output, + opset8::Constant::create(element::i64, Shape{3}, {mvn_data.C, mvn_data.H, mvn_data.W}), + false); } else { - mvn_output = std::make_shared(pre_output, - opset8::Constant::create(element::i64, Shape{4}, {mvn_data.N, mvn_data.C, mvn_data.H, mvn_data.W}), false); + mvn_output = std::make_shared( + pre_output, + opset8::Constant::create(element::i64, Shape{4}, {mvn_data.N, mvn_data.C, mvn_data.H, mvn_data.W}), + false); } - copy_runtime_info(mvn, {reshape, input_4d, input_2d, transposed_input_1, transposed_avg_conv_1, avg_conv_1, reshape_avg_conv_1, - transposed_input_2, transposed_avg_conv_2, avg_conv_2, avg_conv_2_2d, subtract_mean, mvn_output}); + copy_runtime_info(mvn, + {reshape, + input_4d, + input_2d, + transposed_input_1, + transposed_avg_conv_1, + avg_conv_1, + reshape_avg_conv_1, + transposed_input_2, + transposed_avg_conv_2, + avg_conv_2, + avg_conv_2_2d, + subtract_mean, + mvn_output}); // We need retain the MVN layer name, so its output can be used as a network result replace_node(mvn, mvn_output); @@ -263,3 +353,7 @@ DecomposeMVN::DecomposeMVN() { auto m = std::make_shared(mvn, matcher_name); this->register_matcher(m, callback); } + +} // namespace pass +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/transformations/handle_transposes_around_matmul.cpp b/src/plugins/intel_gna/src/transformations/handle_transposes_around_matmul.cpp index c1721b23068..51e94c6ff01 100644 --- a/src/plugins/intel_gna/src/transformations/handle_transposes_around_matmul.cpp +++ b/src/plugins/intel_gna/src/transformations/handle_transposes_around_matmul.cpp @@ -151,7 +151,7 @@ HandleTransposeBeforeMatMul::HandleTransposeBeforeMatMul() { } if (prev_node) { - if (GNAPluginNS::GNALimitations::IsTransposeSupported(prev_node->get_output_shape(0))) { + if (limitations::IsTransposeSupported(prev_node->get_output_shape(0))) { InsertTranspose(prev_node, matmul_node->get_friendly_name(), true); } } @@ -162,7 +162,7 @@ HandleTransposeBeforeMatMul::HandleTransposeBeforeMatMul() { if (iter != pattern_map.end() || (iter = pattern_map.find(constant)) != pattern_map.end()) { auto prev_node = iter->second.get_node_shared_ptr(); - if (GNAPluginNS::GNALimitations::IsTranspose2d(prev_node->get_output_shape(0))) { + if (limitations::IsTranspose2d(prev_node->get_output_shape(0))) { InsertTranspose(prev_node, prev_node->get_friendly_name(), true); } } @@ -179,7 +179,7 @@ HandleTransposeBeforeMatMul::HandleTransposeBeforeMatMul() { } if (prev_node) { - if (GNAPluginNS::GNALimitations::IsTransposeSupported(prev_node->get_output_shape(0))) { + if (limitations::IsTransposeSupported(prev_node->get_output_shape(0))) { InsertTranspose(prev_node, matmul_node->get_friendly_name(), true); } } @@ -220,7 +220,7 @@ HandleTransposeAfterMatMul::HandleTransposeAfterMatMul() { ReplaceTransposeWithReshape(transpose_it->second.get_node_shared_ptr()); } else { auto reshape_node = pattern_map.at(reshape).get_node_shared_ptr(); - if (!GNAPluginNS::GNALimitations::IsTransposeSupported(reshape_node->get_input_shape(0))) return false; + if (!limitations::IsTransposeSupported(reshape_node->get_input_shape(0))) return false; auto iter = pattern_map.find(act); if (iter == pattern_map.end() && (iter = pattern_map.find(fq2)) == pattern_map.end() && diff --git a/src/plugins/intel_gna/src/transformations/split_convolution_with_large_buffer_size.cpp b/src/plugins/intel_gna/src/transformations/split_convolution_with_large_buffer_size.cpp index 3524f960995..e2b56b43a95 100644 --- a/src/plugins/intel_gna/src/transformations/split_convolution_with_large_buffer_size.cpp +++ b/src/plugins/intel_gna/src/transformations/split_convolution_with_large_buffer_size.cpp @@ -15,7 +15,9 @@ #include "layers/gna_split_layer.hpp" #include "layers/gna_convolution_layer.hpp" -using namespace ov::intel_gna::pass; +namespace ov { +namespace intel_gna { +namespace pass { // Don't split when convolution is 2D and is not mappable to 1D static bool shouldSplitCnn(const ngraph::Output& node) { @@ -31,8 +33,8 @@ static bool shouldSplitCnn(const ngraph::Output& node) { auto kW = filters.at(3); auto sH = convolution->get_strides().at(0); auto sW = convolution->get_strides().at(1); - if (GNAPluginNS::GNAConvolutionLayer::is3DInputOr2DKernel(height, width, in_channels, kH, kW) && - !GNAPluginNS::GNAConvolutionLayer::isMappableFrom2DTo1D(height, width, in_channels, kH, kW, sH, sW)) { + if (gna_convolution_layer::is3DInputOr2DKernel(height, width, in_channels, kH, kW) && + !gna_convolution_layer::isMappableFrom2DTo1D(height, width, in_channels, kH, kW, sH, sW)) { return false; } } @@ -40,8 +42,9 @@ static bool shouldSplitCnn(const ngraph::Output& node) { } static std::shared_ptr getConvForMatcher() { - return ngraph::pattern::wrap_type({ ngraph::pattern::any_input(), - ngraph::pattern::any_input() }, [](const ngraph::Output& convolution) { + return ngraph::pattern::wrap_type( + {ngraph::pattern::any_input(), ngraph::pattern::any_input()}, + [](const ngraph::Output& convolution) { return shouldSplitCnn(convolution); }); } @@ -51,14 +54,16 @@ static bool Convert(std::shared_ptr conv, std::shared_ptr bias, std::shared_ptr fq) { auto input_size = std::accumulate(std::begin(conv->get_input_shape(0)), - std::end(conv->get_input_shape(0)), size_t(1), std::multiplies()); - if (input_size <= GNAPluginNS::GNALimitations::bufferMaxSize) { + std::end(conv->get_input_shape(0)), + size_t(1), + std::multiplies()); + if (input_size <= limitations::bufferMaxSize) { return false; } auto& input = conv->get_input_shape(0); uint32_t width = input.back(); uint32_t in_channels = input.at(1); - auto split_sizes = GNAPluginNS::GetAlignedSplitSizes(width, GNAPluginNS::GNALimitations::bufferMaxSize / in_channels); + auto split_sizes = GetAlignedSplitSizes(width, limitations::bufferMaxSize / in_channels); IE_ASSERT(split_sizes.size() > 1); std::vector split_sizes_casted(split_sizes.size()); std::transform(std::begin(split_sizes), std::end(split_sizes), std::begin(split_sizes_casted), [](uint32_t size) { @@ -68,15 +73,19 @@ static bool Convert(std::shared_ptr conv, /* TODO check if it's NHWC convolution wrapped with transposes or all input dimensions except of width == 1, otherwise this split axis isn't supported */ const int64_t width_axis = input.size() - 1; - auto split_node = std::make_shared(conv->input_value(0), + auto split_node = std::make_shared( + conv->input_value(0), ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape({1}), std::vector{width_axis}), - ngraph::opset7::Constant::create(ngraph::element::i64, ngraph::Shape({split_sizes_casted.size()}), split_sizes_casted)); + ngraph::opset7::Constant::create(ngraph::element::i64, + ngraph::Shape({split_sizes_casted.size()}), + split_sizes_casted)); ngraph::copy_runtime_info(conv, split_node); split_node->set_friendly_name(conv->get_friendly_name() + "/split"); ngraph::OutputVector convOutputs; std::shared_ptr root_node = fq ? fq : (add ? add : conv); for (int i = 0; i < split_sizes.size(); ++i) { - std::shared_ptr output = conv->clone_with_new_inputs({split_node->output(i), conv->input_value(1)}); + std::shared_ptr output = + conv->clone_with_new_inputs({split_node->output(i), conv->input_value(1)}); ngraph::copy_runtime_info(split_node, output); output->set_friendly_name(conv->get_friendly_name() + "_" + std::to_string(i)); if (bias) { @@ -85,8 +94,8 @@ static bool Convert(std::shared_ptr conv, } if (fq) { - output = fq->clone_with_new_inputs({output, fq->input_value(1), fq->input_value(2), - fq->input_value(3), fq->input_value(4)}); + output = fq->clone_with_new_inputs( + {output, fq->input_value(1), fq->input_value(2), fq->input_value(3), fq->input_value(4)}); ngraph::copy_runtime_info(fq, output); } convOutputs.push_back(output); @@ -102,7 +111,7 @@ static bool Convert(std::shared_ptr conv, SplitConvolution::SplitConvolution() { MATCHER_SCOPE(SplitConvolution); auto conv = getConvForMatcher(); - ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher &m) { + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher& m) { const auto& pattern_map = m.get_pattern_value_map(); return Convert(pattern_map.at(conv).get_node_shared_ptr(), nullptr, nullptr, nullptr); }; @@ -117,10 +126,12 @@ SplitConvolutionWithBias::SplitConvolutionWithBias() { auto bias = ngraph::pattern::wrap_type(); auto add = ngraph::pattern::wrap_type({conv, bias}); - ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher &m) { + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher& m) { const auto& pattern_map = m.get_pattern_value_map(); - return Convert(pattern_map.at(conv).get_node_shared_ptr(), pattern_map.at(add).get_node_shared_ptr(), - pattern_map.at(bias).get_node_shared_ptr(), nullptr); + return Convert(pattern_map.at(conv).get_node_shared_ptr(), + pattern_map.at(add).get_node_shared_ptr(), + pattern_map.at(bias).get_node_shared_ptr(), + nullptr); }; auto m = std::make_shared(add, matcher_name); @@ -133,21 +144,29 @@ SplitConvolutionWithFq::SplitConvolutionWithFq() { auto bias = ngraph::pattern::wrap_type(); auto add = ngraph::pattern::wrap_type({conv, bias}); auto conv_output = std::make_shared(ngraph::OutputVector{conv, add}); - auto out_fq = ngraph::pattern::wrap_type({conv_output, - ngraph::pattern::wrap_type(), - ngraph::pattern::wrap_type(), - ngraph::pattern::wrap_type(), - ngraph::pattern::wrap_type()}); + auto out_fq = ngraph::pattern::wrap_type( + {conv_output, + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type(), + ngraph::pattern::wrap_type()}); - ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher &m) { + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher& m) { const auto& pattern_map = m.get_pattern_value_map(); auto add_it = pattern_map.find(add); auto add_node = (add_it == std::end(pattern_map) ? nullptr : add_it->second.get_node_shared_ptr()); auto bias_it = pattern_map.find(bias); auto bias_node = (bias_it == std::end(pattern_map) ? nullptr : bias_it->second.get_node_shared_ptr()); - return Convert(pattern_map.at(conv).get_node_shared_ptr(), add_node, bias_node, pattern_map.at(out_fq).get_node_shared_ptr()); + return Convert(pattern_map.at(conv).get_node_shared_ptr(), + add_node, + bias_node, + pattern_map.at(out_fq).get_node_shared_ptr()); }; auto m = std::make_shared(out_fq, matcher_name); this->register_matcher(m, callback); } + +} // namespace pass +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/transformations/split_convolution_with_large_buffer_size.hpp b/src/plugins/intel_gna/src/transformations/split_convolution_with_large_buffer_size.hpp index 78d8f737e6e..82d7fcb065b 100644 --- a/src/plugins/intel_gna/src/transformations/split_convolution_with_large_buffer_size.hpp +++ b/src/plugins/intel_gna/src/transformations/split_convolution_with_large_buffer_size.hpp @@ -9,6 +9,7 @@ namespace ov { namespace intel_gna { namespace pass { + // @brief Splits convolution with large input buffer class SplitConvolution : public ngraph::pass::MatcherPass { public: diff --git a/src/plugins/intel_gna/src/transformations/split_eltwise.cpp b/src/plugins/intel_gna/src/transformations/split_eltwise.cpp index 4a35a622856..bc889ee6f22 100644 --- a/src/plugins/intel_gna/src/transformations/split_eltwise.cpp +++ b/src/plugins/intel_gna/src/transformations/split_eltwise.cpp @@ -16,54 +16,65 @@ #include "layers/gna_split_layer.hpp" #include "log/log.hpp" -using namespace ov::intel_gna::pass; -using namespace ov::intel_gna::ngraph_util; +namespace ov { +namespace intel_gna { +namespace pass { -namespace { inline bool is_eltwise_has_to_be_splitted(const ngraph::Output& node) { auto eltwise = std::dynamic_pointer_cast(node.get_node_shared_ptr()); - if (!eltwise) return false; + if (!eltwise) + return false; auto o_dims = eltwise->get_output_shape(0); auto total_elem_size = std::accumulate(std::begin(o_dims), std::end(o_dims), 1, std::multiplies()); - return (total_elem_size > GNAPluginNS::GNALimitations::bufferMaxSize); + return (total_elem_size > limitations::bufferMaxSize); } -std::shared_ptr split_input(const std::shared_ptr& node, +static std::shared_ptr split_input( + const std::shared_ptr& node, const std::pair>& split_sizes_per_axis) { - auto split = std::make_shared(node, - ngraph::opset9::Constant::create(ngraph::element::i64, ngraph::Shape({1}), std::vector{split_sizes_per_axis.first}), - ngraph::opset9::Constant::create(ngraph::element::i64, ngraph::Shape({split_sizes_per_axis.second.size()}), split_sizes_per_axis.second)); + auto split = std::make_shared( + node, + ngraph::opset9::Constant::create(ngraph::element::i64, + ngraph::Shape({1}), + std::vector{split_sizes_per_axis.first}), + ngraph::opset9::Constant::create(ngraph::element::i64, + ngraph::Shape({split_sizes_per_axis.second.size()}), + split_sizes_per_axis.second)); split->set_friendly_name(node->get_friendly_name() + "/split"); ngraph::copy_runtime_info(node, split); return split; } -std::shared_ptr create_eltwise(const std::shared_ptr& node, const std::shared_ptr& split0, - const std::shared_ptr& split1, size_t index) { +static std::shared_ptr create_eltwise(const std::shared_ptr& node, + const std::shared_ptr& split0, + const std::shared_ptr& split1, + size_t index) { auto root_eltwise = std::dynamic_pointer_cast(node); - auto eltwise = std::make_shared(split0->output(index), split1->output(index), - root_eltwise->eltwise_type, root_eltwise->get_output_element_type(0)); + auto eltwise = std::make_shared(split0->output(index), + split1->output(index), + root_eltwise->eltwise_type, + root_eltwise->get_output_element_type(0)); eltwise->set_friendly_name(root_eltwise->get_friendly_name() + "/partition" + std::to_string(index)); ngraph::copy_runtime_info(root_eltwise, eltwise); return eltwise; } -} // namespace SplitEltwise::SplitEltwise() { MATCHER_SCOPE(SplitEltwise); - auto eltwise = ngraph::pattern::wrap_type({ngraph::pattern::any_input(), ngraph::pattern::any_input()}, - is_eltwise_has_to_be_splitted); + auto eltwise = + ngraph::pattern::wrap_type({ngraph::pattern::any_input(), ngraph::pattern::any_input()}, + is_eltwise_has_to_be_splitted); - ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher &m) { + ngraph::matcher_pass_callback callback = [=](ngraph::pattern::Matcher& m) { const auto& pattern_map = m.get_pattern_value_map(); auto eltwise_node = pattern_map.at(eltwise).get_node_shared_ptr(); auto consumers = eltwise_node->output(0).get_target_inputs(); auto o_dims = eltwise_node->get_output_shape(0); - auto split_sizes_per_axis = GNAPluginNS::AlignedSplitSizesPerAxis(o_dims); + auto split_sizes_per_axis = AlignedSplitSizesPerAxis(o_dims); if (0 == split_sizes_per_axis.second.size()) { - log::debug() << "Splitting didn't succeed for layer " << eltwise_node->get_friendly_name() - << " on axis " << split_sizes_per_axis.first << std::endl; + log::debug() << "Splitting didn't succeed for layer " << eltwise_node->get_friendly_name() << " on axis " + << split_sizes_per_axis.first << std::endl; return false; } @@ -87,3 +98,7 @@ SplitEltwise::SplitEltwise() { auto m = std::make_shared(eltwise, matcher_name); this->register_matcher(m, callback); } + +} // namespace pass +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/src/transformations/split_eltwise.hpp b/src/plugins/intel_gna/src/transformations/split_eltwise.hpp index 154ae55ed5b..bcc933390ee 100644 --- a/src/plugins/intel_gna/src/transformations/split_eltwise.hpp +++ b/src/plugins/intel_gna/src/transformations/split_eltwise.hpp @@ -9,6 +9,7 @@ namespace ov { namespace intel_gna { namespace pass { + /** * @brief Split over channels for Eltwise to avoid GNA-HW bufferMaxSize limitation per eltwise */ diff --git a/src/plugins/intel_gna/tests/functional/shared_tests_instances/single_layer_tests/convolution.cpp b/src/plugins/intel_gna/tests/functional/shared_tests_instances/single_layer_tests/convolution.cpp index 0e18dd8f01b..ab8b8546441 100644 --- a/src/plugins/intel_gna/tests/functional/shared_tests_instances/single_layer_tests/convolution.cpp +++ b/src/plugins/intel_gna/tests/functional/shared_tests_instances/single_layer_tests/convolution.cpp @@ -12,7 +12,7 @@ using namespace LayerTestsDefinitions; namespace { -class GnaConvolutionLayerTest : public ConvolutionLayerTest { +class gna_convolution_layerTest : public ConvolutionLayerTest { protected: void Run() override { ConvolutionLayerTest::Run(); @@ -23,7 +23,7 @@ protected: } }; -TEST_P(GnaConvolutionLayerTest, CompareWithRefs) { +TEST_P(gna_convolution_layerTest, CompareWithRefs) { Run(); } @@ -276,7 +276,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_AutoPadValid_MapTo1d, ConvolutionLa ::testing::Values(CommonTestUtils::DEVICE_GNA)), ConvolutionLayerTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_Kernels2D, GnaConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_Kernels2D, gna_convolution_layerTest, ::testing::Combine( conv2DParams_Kernels2D, ::testing::ValuesIn(netPrecisions), @@ -286,9 +286,9 @@ INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_Kernels2D, GnaConvolutionLayerTest, ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(input2DNCHW), ::testing::Values(CommonTestUtils::DEVICE_GNA)), - GnaConvolutionLayerTest::getTestCaseName); + gna_convolution_layerTest::getTestCaseName); -INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_Kernels2D_big, GnaConvolutionLayerTest, +INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_Kernels2D_big, gna_convolution_layerTest, ::testing::Combine( conv2DParams_Kernels2D_big, ::testing::ValuesIn(netPrecisions), @@ -298,7 +298,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_Kernels2D_big, GnaConvolutionLayerT ::testing::Values(InferenceEngine::Layout::ANY), ::testing::Values(input2DNCHW), ::testing::Values(CommonTestUtils::DEVICE_GNA)), - GnaConvolutionLayerTest::getTestCaseName); + gna_convolution_layerTest::getTestCaseName); INSTANTIATE_TEST_SUITE_P(smoke_Convolution2D_Map2D_Not_Transpose_h_w_3_3, ConvolutionLayerTest, ::testing::Combine( diff --git a/src/plugins/intel_gna/tests/unit/backend/gna_limitations_test.cpp b/src/plugins/intel_gna/tests/unit/backend/gna_limitations_test.cpp index c2e068b7f8e..280d44b416f 100644 --- a/src/plugins/intel_gna/tests/unit/backend/gna_limitations_test.cpp +++ b/src/plugins/intel_gna/tests/unit/backend/gna_limitations_test.cpp @@ -9,11 +9,11 @@ #include -using namespace GNAPluginNS::GNALimitations; -using GNAPluginNS::common::kGnaTarget3_0; -using GNAPluginNS::common::kGnaTarget3_5; +using namespace ov::intel_gna::limitations; +using ov::intel_gna::common::kGnaTarget3_0; +using ov::intel_gna::common::kGnaTarget3_5; -struct GNACnn2DValidatorTestParam { +struct GNAcnn2dValidatorTestParam { std::string target; std::string whatInvalid; std::vector invalid; @@ -49,180 +49,180 @@ const std::vector kInvaliddH_35 = {0, 2, 2049}; const std::vector kInvaliddW_30 = {0, 2, 400}; const std::vector kInvaliddW_35 = {0, 2, 2049}; -const GNACnn2DValidatorTestParam target_30 { +const GNAcnn2dValidatorTestParam target_30 { kGnaTarget3_0, "inH", kInvalidH_30, }; -const GNACnn2DValidatorTestParam target_35 { +const GNAcnn2dValidatorTestParam target_35 { kGnaTarget3_5, "inH", kInvalidH_35, }; -const GNACnn2DValidatorTestParam target_30_inW{ +const GNAcnn2dValidatorTestParam target_30_inW{ kGnaTarget3_0, "inW", kInvalidW_30, }; -const GNACnn2DValidatorTestParam target_35_inW{ +const GNAcnn2dValidatorTestParam target_35_inW{ kGnaTarget3_5, "inW", kInvalidW_35, }; -const GNACnn2DValidatorTestParam target_30_inC{ +const GNAcnn2dValidatorTestParam target_30_inC{ kGnaTarget3_0, "inC", kInvalidC_30, }; -const GNACnn2DValidatorTestParam target_35_inC{ +const GNAcnn2dValidatorTestParam target_35_inC{ kGnaTarget3_5, "inC", kInvalidC_35, }; -const GNACnn2DValidatorTestParam target_30_kH{ +const GNAcnn2dValidatorTestParam target_30_kH{ kGnaTarget3_0, "kH", kInvalidkH_30, }; -const GNACnn2DValidatorTestParam target_35_kH{ +const GNAcnn2dValidatorTestParam target_35_kH{ kGnaTarget3_5, "kH", kInvalidkH_35, }; -const GNACnn2DValidatorTestParam target_30_kW{ +const GNAcnn2dValidatorTestParam target_30_kW{ kGnaTarget3_0, "kW", kInvalidkW_30, }; -const GNACnn2DValidatorTestParam target_35_kW{ +const GNAcnn2dValidatorTestParam target_35_kW{ kGnaTarget3_5, "kW", kInvalidkW_35, }; -const GNACnn2DValidatorTestParam target_30_kN{ +const GNAcnn2dValidatorTestParam target_30_kN{ kGnaTarget3_0, "inC", kInvalidkN_30, }; -const GNACnn2DValidatorTestParam target_35_kN{ +const GNAcnn2dValidatorTestParam target_35_kN{ kGnaTarget3_5, "inC", kInvalidkN_35, }; -const GNACnn2DValidatorTestParam target_30_sH{ +const GNAcnn2dValidatorTestParam target_30_sH{ kGnaTarget3_0, "sH", kInvalidsH_30, }; -const GNACnn2DValidatorTestParam target_35_sH{ +const GNAcnn2dValidatorTestParam target_35_sH{ kGnaTarget3_5, "sH", kInvalidsH_35, }; -const GNACnn2DValidatorTestParam target_30_sW{ +const GNAcnn2dValidatorTestParam target_30_sW{ kGnaTarget3_0, "sW", kInvalidsW_30, }; -const GNACnn2DValidatorTestParam target_35_sW{ +const GNAcnn2dValidatorTestParam target_35_sW{ kGnaTarget3_5, "sW", kInvalidsW_35, }; -const GNACnn2DValidatorTestParam target_30_dH{ +const GNAcnn2dValidatorTestParam target_30_dH{ kGnaTarget3_0, "dH", kInvaliddH_30, }; -const GNACnn2DValidatorTestParam target_35_dH{ +const GNAcnn2dValidatorTestParam target_35_dH{ kGnaTarget3_5, "dH", kInvaliddH_35, }; -const GNACnn2DValidatorTestParam target_30_dW{ +const GNAcnn2dValidatorTestParam target_30_dW{ kGnaTarget3_0, "dW", kInvaliddW_30, }; -const GNACnn2DValidatorTestParam target_35_dW{ +const GNAcnn2dValidatorTestParam target_35_dW{ kGnaTarget3_5, "dW", kInvaliddW_35, }; const std::vector kInvalidpw_30 = {0, 2, 10}; -const GNACnn2DValidatorTestParam target_30_pwH{ +const GNAcnn2dValidatorTestParam target_30_pwH{ kGnaTarget3_0, "windowH", kInvalidpw_30, }; -const GNACnn2DValidatorTestParam target_30_pwW{ +const GNAcnn2dValidatorTestParam target_30_pwW{ kGnaTarget3_0, "windowW", kInvalidpw_30, }; const std::vector kInvalidps_30 = {0, 4, 10}; -const GNACnn2DValidatorTestParam target_30_psH{ +const GNAcnn2dValidatorTestParam target_30_psH{ kGnaTarget3_0, "strideH", kInvalidps_30, }; -const GNACnn2DValidatorTestParam target_30_psW{ +const GNAcnn2dValidatorTestParam target_30_psW{ kGnaTarget3_0, "strideW", kInvalidps_30, }; const std::vector kInvalidPoolingRange35 = {0, 256}; -const GNACnn2DValidatorTestParam target_35_pwH{ +const GNAcnn2dValidatorTestParam target_35_pwH{ kGnaTarget3_5, "windowH", kInvalidPoolingRange35, }; -const GNACnn2DValidatorTestParam target_35_pwW{ +const GNAcnn2dValidatorTestParam target_35_pwW{ kGnaTarget3_5, "windowW", kInvalidPoolingRange35, }; -const GNACnn2DValidatorTestParam target_35_psH{ +const GNAcnn2dValidatorTestParam target_35_psH{ kGnaTarget3_5, "strideH", kInvalidPoolingRange35, }; -const GNACnn2DValidatorTestParam target_35_psW{ +const GNAcnn2dValidatorTestParam target_35_psW{ kGnaTarget3_5, "strideW", kInvalidPoolingRange35, }; -struct ValidateCnn2DParams { +struct Validatecnn2dParams { std::map parameters; OvGnaType precission; static const bool exceptionMode = false; - static ValidateCnn2DParams GetValid() { - ValidateCnn2DParams v; + static Validatecnn2dParams GetValid() { + Validatecnn2dParams v; v.parameters["inH"] = 16; v.parameters["inW"] = 16; v.parameters["inC"] = 16; @@ -237,8 +237,8 @@ struct ValidateCnn2DParams { return v; } - static ValidateCnn2DParams GetValidPooling() { - ValidateCnn2DParams v; + static Validatecnn2dParams GetValidPooling() { + Validatecnn2dParams v; v.parameters["windowH"] = 3; v.parameters["windowW"] = 3; v.parameters["strideH"] = 3; @@ -246,7 +246,7 @@ struct ValidateCnn2DParams { return v; } - bool ValidateCnn2D(const Cnn2D::AbstractValidator& validator) { + bool Validatecnn2d(const cnn2d::AbstractValidator& validator) { return validator.ValidateCnn2D({}, parameters["inH"], parameters["inW"], @@ -261,7 +261,7 @@ struct ValidateCnn2DParams { precission, exceptionMode); } - bool ValidatePooling2D(const Cnn2D::AbstractValidator& validator) { + bool ValidatePooling2D(const cnn2d::AbstractValidator& validator) { return validator.ValidatePooling2D({}, parameters["windowH"], parameters["windowW"], @@ -279,16 +279,16 @@ struct ValidateCnn2DParams { } }; -class GNACnn2DValidatorTest : public ::testing::TestWithParam { +class GNAcnn2dValidatorTest : public ::testing::TestWithParam { protected: void SetUp() override { - validator = Cnn2D::AbstractValidator::Create(GetParam().target); + validator = cnn2d::AbstractValidator::Create(GetParam().target); ASSERT_TRUE(validator != nullptr); } - std::unique_ptr validator; + std::unique_ptr validator; }; -class GNACnn2DValidatorTestPadding : public GNACnn2DValidatorTest { +class GNAcnn2dValidatorTestPadding : public GNAcnn2dValidatorTest { protected: bool isPaddingSupported() { static const std::set supported{kGnaTarget3_5}; @@ -296,35 +296,35 @@ protected: } }; -class GNACnn2DValidatorTestPooling2D : public GNACnn2DValidatorTest {}; +class GNAcnn2dValidatorTestPooling2D : public GNAcnn2dValidatorTest {}; namespace { -TEST_P(GNACnn2DValidatorTestPadding, testPaddingSupported) { +TEST_P(GNAcnn2dValidatorTestPadding, testPaddingSupported) { ASSERT_TRUE(validator->ValidateInputPadding("", 1, 1, 1, 1, 2, 2, false) == isPaddingSupported()); } -TEST_P(GNACnn2DValidatorTest, testValidateCnn2DInvalid) { - auto valid = ValidateCnn2DParams::GetValid(); +TEST_P(GNAcnn2dValidatorTest, testValidatecnn2dInvalid) { + auto valid = Validatecnn2dParams::GetValid(); for (const auto invalid : GetParam().invalid) { valid.set(GetParam().whatInvalid, invalid); - ASSERT_FALSE(valid.ValidateCnn2D(*validator)); + ASSERT_FALSE(valid.Validatecnn2d(*validator)); } } -TEST_P(GNACnn2DValidatorTestPooling2D, testValidateCnn2DInvalid) { - auto valid = ValidateCnn2DParams::GetValidPooling(); +TEST_P(GNAcnn2dValidatorTestPooling2D, testValidatecnn2dInvalid) { + auto valid = Validatecnn2dParams::GetValidPooling(); for (const auto invalid : GetParam().invalid) { valid.set(GetParam().whatInvalid, invalid); ASSERT_FALSE(valid.ValidatePooling2D(*validator)); } } -INSTANTIATE_TEST_SUITE_P(smoke_GNACnn2DValidatorTestPadding, - GNACnn2DValidatorTestPadding, +INSTANTIATE_TEST_SUITE_P(smoke_GNAcnn2dValidatorTestPadding, + GNAcnn2dValidatorTestPadding, testing::Values(target_30, target_35)); -INSTANTIATE_TEST_SUITE_P(smoke_GNACnn2DValidatorTest, - GNACnn2DValidatorTest, +INSTANTIATE_TEST_SUITE_P(smoke_GNAcnn2dValidatorTest, + GNAcnn2dValidatorTest, testing::Values(target_30, target_35, target_30_inW, @@ -347,8 +347,8 @@ INSTANTIATE_TEST_SUITE_P(smoke_GNACnn2DValidatorTest, target_35_dW) ); -INSTANTIATE_TEST_SUITE_P(smoke_GNACnn2DValidatorTestPooling2D, - GNACnn2DValidatorTestPooling2D, +INSTANTIATE_TEST_SUITE_P(smoke_GNAcnn2dValidatorTestPooling2D, + GNAcnn2dValidatorTestPooling2D, testing::Values(target_30_pwH, target_30_pwW, target_30_psH, diff --git a/src/plugins/intel_gna/tests/unit/backend/gna_make_pwl_identity.cpp b/src/plugins/intel_gna/tests/unit/backend/gna_make_pwl_identity.cpp index 6006439f9dd..f5d425b729c 100644 --- a/src/plugins/intel_gna/tests/unit/backend/gna_make_pwl_identity.cpp +++ b/src/plugins/intel_gna/tests/unit/backend/gna_make_pwl_identity.cpp @@ -9,7 +9,7 @@ #include -#include "backend/dnn_types.h" +#include "backend/dnn_types.hpp" #include "backend/make_pwl.hpp" #include "backend/pwl_input_params.hpp" #include "backend/pwl_segments_creator_factory.hpp" diff --git a/src/plugins/intel_gna/tests/unit/gna_allocator_test.cpp b/src/plugins/intel_gna/tests/unit/gna_allocator_test.cpp index 44d4ff04a45..9cb8f80ed7a 100644 --- a/src/plugins/intel_gna/tests/unit/gna_allocator_test.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_allocator_test.cpp @@ -48,7 +48,7 @@ protected: }; TEST_F(GNAAllocatorTest, canAllocateStdMemory) { - auto sp = GNAPluginNS::memory::GNAFloatAllocator{}; + auto sp = memory::GNAFloatAllocator{}; uint8_t *x = nullptr; ASSERT_NO_THROW(x = sp.allocate(100)); ASSERT_NE(x, nullptr); @@ -58,7 +58,7 @@ TEST_F(GNAAllocatorTest, canAllocateStdMemory) { TEST_F(GNAAllocatorTest, canAllocateGNAMemory) { // GNA device can be opened one per process for now gnadevice.reset(new GNADeviceHelper()); - GNAPluginNS::memory::GNAAllocator sp{ gnadevice }; + memory::GNAAllocator sp{ gnadevice }; uint8_t *x = nullptr; ASSERT_NO_THROW(x = sp.allocate(100)); ASSERT_NE(x, nullptr); diff --git a/src/plugins/intel_gna/tests/unit/gna_am_intel_dnn.cpp b/src/plugins/intel_gna/tests/unit/gna_am_intel_dnn.cpp index 3d92c76835f..12f3b5b0087 100644 --- a/src/plugins/intel_gna/tests/unit/gna_am_intel_dnn.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_am_intel_dnn.cpp @@ -10,7 +10,7 @@ using namespace testing; class GNA_AmIntelDnn_test : public ::testing::Test { protected: - GNAPluginNS::backend::AMIntelDNN amIntelDnn; + backend::AMIntelDNN amIntelDnn; Gna2Model desc = {}; }; diff --git a/src/plugins/intel_gna/tests/unit/gna_export_import_test.cpp b/src/plugins/intel_gna/tests/unit/gna_export_import_test.cpp index 6543d48a2d6..7b6b10d3033 100644 --- a/src/plugins/intel_gna/tests/unit/gna_export_import_test.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_export_import_test.cpp @@ -15,7 +15,7 @@ #include "any_copy.hpp" using namespace ::testing; -using GNAPluginNS::GNAPlugin; +using ov::intel_gna::GNAPlugin; using ::testing::InSequence; using namespace InferenceEngine; diff --git a/src/plugins/intel_gna/tests/unit/gna_extra_pwl_segments_tests.cpp b/src/plugins/intel_gna/tests/unit/gna_extra_pwl_segments_tests.cpp index fc97309b3dd..144144a598f 100644 --- a/src/plugins/intel_gna/tests/unit/gna_extra_pwl_segments_tests.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_extra_pwl_segments_tests.cpp @@ -9,7 +9,8 @@ #include "gna_plugin.hpp" #include "ngraph_functions/builders.hpp" -using GNAPluginNS::GNAPlugin; +using ov::intel_gna::GNAPlugin; + namespace { struct ConvolutionParameters { @@ -73,7 +74,7 @@ std::ostream& operator<<(std::ostream& os, const intel_dnn_operation_t& value) { class GNAPluginForPWLExtraSegmentsTest : public GNAPlugin { public: GNAPluginForPWLExtraSegmentsTest(const std::map& config) : GNAPlugin(config) { - gnamem.reset(new GNAPluginNS::gna_memory_float(GNAPluginNS::memory::GNAFloatAllocator{})); + gnamem.reset(new gna_memory_float(memory::GNAFloatAllocator{})); graphCompiler.setGNAMemoryPtr(gnamem); gnadevice.reset(); } diff --git a/src/plugins/intel_gna/tests/unit/gna_get_2d_reshaped_data.cpp b/src/plugins/intel_gna/tests/unit/gna_get_2d_reshaped_data.cpp index ebf4436469f..b2397dfdf76 100644 --- a/src/plugins/intel_gna/tests/unit/gna_get_2d_reshaped_data.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_get_2d_reshaped_data.cpp @@ -65,7 +65,7 @@ class Get2DReshapedDataTest : public ::testing::Test { InferenceEngine::Layout layout) const { auto data = std::make_shared(input_name, InferenceEngine::TensorDesc(precision, input_shape.first, layout)); - auto new_data = GNAPluginNS::Get2DReshapedData(data, 1, max_batch_size); + auto new_data = Get2DReshapedData(data, 1, max_batch_size); ASSERT_EQ(new_data->getDims(), input_shape.second); ASSERT_EQ(new_data->getPrecision(), precision); ASSERT_EQ(new_data->getLayout(), layout); diff --git a/src/plugins/intel_gna/tests/unit/gna_get_aligned_split_sizes.cpp b/src/plugins/intel_gna/tests/unit/gna_get_aligned_split_sizes.cpp index 6bc57f1f66a..9c948b2f1c2 100644 --- a/src/plugins/intel_gna/tests/unit/gna_get_aligned_split_sizes.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_get_aligned_split_sizes.cpp @@ -11,6 +11,8 @@ namespace { +using namespace ov::intel_gna; + using GetAlignedSplitSizesData = std::tuple< uint32_t, // total size uint32_t, // maximum split size @@ -27,7 +29,7 @@ const std::vector data = { TEST(GetAlignedSplitSizesTest, testAlignedSplitSizes) { for (const auto &dataItem : data) { - auto sizes = GNAPluginNS::GetAlignedSplitSizes(std::get<0>(dataItem), std::get<1>(dataItem), + auto sizes = GetAlignedSplitSizes(std::get<0>(dataItem), std::get<1>(dataItem), std::get<2>(dataItem)); ASSERT_EQ(sizes, std::get<3>(dataItem)); } diff --git a/src/plugins/intel_gna/tests/unit/gna_get_crop_params.cpp b/src/plugins/intel_gna/tests/unit/gna_get_crop_params.cpp index 66d836e26eb..dd187b28521 100644 --- a/src/plugins/intel_gna/tests/unit/gna_get_crop_params.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_get_crop_params.cpp @@ -12,6 +12,8 @@ namespace { +using namespace ov::intel_gna; + typedef std::tuple< std::vector, // Input shape std::vector, // Output shape @@ -46,7 +48,7 @@ TEST(GetCropParamsTest, testGetCropParams) { crop_layer->dim = orig_out_shape; crop_layer->axis = orig_axes; crop_layer->offset = orig_offset; - const auto results = GNAPluginNS::GetCropParams(crop_layer.get()); + const auto results = GetCropParams(crop_layer.get()); ASSERT_EQ(results.start_offset, result_offset); ASSERT_EQ(results.crop_size, result_out_size); } diff --git a/src/plugins/intel_gna/tests/unit/gna_hw_precision_test.cpp b/src/plugins/intel_gna/tests/unit/gna_hw_precision_test.cpp index 1d41fe37571..b302a82a841 100644 --- a/src/plugins/intel_gna/tests/unit/gna_hw_precision_test.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_hw_precision_test.cpp @@ -13,11 +13,11 @@ using namespace InferenceEngine; namespace testing { -class GNAPluginForPrecisionTest : public GNAPluginNS::GNAPlugin { +class GNAPluginForPrecisionTest : public GNAPlugin { public: GNAPluginForPrecisionTest(const std::map& configMap) : - GNAPluginNS::GNAPlugin(configMap) { - gnamem.reset(new GNAPluginNS::gna_memory_float(GNAPluginNS::memory::GNAFloatAllocator{})); + GNAPlugin(configMap) { + gnamem.reset(new gna_memory_float(memory::GNAFloatAllocator{})); graphCompiler.setGNAMemoryPtr(gnamem); gnadevice.reset(); } diff --git a/src/plugins/intel_gna/tests/unit/gna_infer_request_test.cpp b/src/plugins/intel_gna/tests/unit/gna_infer_request_test.cpp index baec0b29445..d29442ca351 100644 --- a/src/plugins/intel_gna/tests/unit/gna_infer_request_test.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_infer_request_test.cpp @@ -19,8 +19,8 @@ using namespace ::testing; using namespace InferenceEngine; -using GNAPluginNS::GNAInferRequest; -using GNAPluginNS::GNAPlugin; +using ov::intel_gna::GNAInferRequest; +using ov::intel_gna::GNAPlugin; using ::testing::InSequence; class GNAInferRequestTest : public ::testing::Test { diff --git a/src/plugins/intel_gna/tests/unit/gna_input_preproc_test.cpp b/src/plugins/intel_gna/tests/unit/gna_input_preproc_test.cpp index 341e57c099b..8f34a81df4d 100644 --- a/src/plugins/intel_gna/tests/unit/gna_input_preproc_test.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_input_preproc_test.cpp @@ -15,7 +15,7 @@ using namespace InferenceEngine; namespace testing { -class GNAPluginForInPrecisionTest : public GNAPluginNS::GNAPlugin { +class GNAPluginForInPrecisionTest : public GNAPlugin { public: using GNAPlugin::GNAPlugin; using GNAPlugin::ImportFrames; diff --git a/src/plugins/intel_gna/tests/unit/gna_memory_compact_test.cpp b/src/plugins/intel_gna/tests/unit/gna_memory_compact_test.cpp index addb6c4f7b2..f01d8da512d 100644 --- a/src/plugins/intel_gna/tests/unit/gna_memory_compact_test.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_memory_compact_test.cpp @@ -17,11 +17,11 @@ using namespace InferenceEngine; -using namespace GNAPluginNS::memory; +using namespace memory; class GNAMemoryCompactTest : public ::testing::Test { protected: - GNAMemory mem; + GNAMemory mem; bool isCompact = true; void SetUp() override { @@ -258,7 +258,7 @@ TEST_F(GNAMemoryCompactTest, canOptimizeReservePtrWithOffset) { ASSERT_EQ(mem.getRegionBytes(rRegion::REGION_SCRATCH), 4 * sizeof(float)); } -class GNAMemoryTested : public GNAPluginNS::memory::GNAMemory { +class GNAMemoryTested : public memory::GNAMemory { using GNAMemory::GNAMemory; public: @@ -289,10 +289,10 @@ public: } }; -class GNAPluginTested : public GNAPluginNS::GNAPlugin { +class GNAPluginTested : public GNAPlugin { public: std::shared_ptr gnamem_t; - GNAPluginTested() : GNAPluginNS::GNAPlugin() { + GNAPluginTested() : GNAPlugin() { gnamem_t = std::make_shared(); gnamem = gnamem_t; graphCompiler.setGNAMemoryPtr(gnamem); diff --git a/src/plugins/intel_gna/tests/unit/gna_memory_test.cpp b/src/plugins/intel_gna/tests/unit/gna_memory_test.cpp index 0fee1a0eb6c..db01f6df349 100644 --- a/src/plugins/intel_gna/tests/unit/gna_memory_test.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_memory_test.cpp @@ -6,7 +6,7 @@ #include #include "memory/gna_memory.hpp" -using namespace GNAPluginNS::memory; +using namespace memory; class GNAMemoryTest : public ::testing::Test { protected: @@ -317,7 +317,7 @@ TEST_F(GNAMemoryTest, canCalculateReadWriteSectionSize) { } TEST_F(GNAMemoryTest, canCalculateReadWriteSectionSizeWithAlignment) { - GNAMemory memAligned(64); + GNAMemory memAligned(64); float* pFuture1 = reinterpret_cast(&pFuture1); float* pFuture2 = reinterpret_cast(&pFuture2); diff --git a/src/plugins/intel_gna/tests/unit/gna_permute_sequence_test.cpp b/src/plugins/intel_gna/tests/unit/gna_permute_sequence_test.cpp index 7a41a6e2133..bc66b0a63fd 100644 --- a/src/plugins/intel_gna/tests/unit/gna_permute_sequence_test.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_permute_sequence_test.cpp @@ -6,7 +6,7 @@ #include #include -using namespace GNAPluginNS; +using namespace ov::intel_gna::permute; class PermuteSequenceTest : public ::testing::Test { }; diff --git a/src/plugins/intel_gna/tests/unit/gna_plugin_config_test.cpp b/src/plugins/intel_gna/tests/unit/gna_plugin_config_test.cpp index 1691942c0d3..19045177a96 100644 --- a/src/plugins/intel_gna/tests/unit/gna_plugin_config_test.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_plugin_config_test.cpp @@ -9,7 +9,7 @@ #include using namespace InferenceEngine; -using namespace GNAPluginNS; +using namespace ov::intel_gna; IE_SUPPRESS_DEPRECATED_START const std::map supportedConfigKeysWithDefaults = { diff --git a/src/plugins/intel_gna/tests/unit/gna_plugin_load_network_test.cpp b/src/plugins/intel_gna/tests/unit/gna_plugin_load_network_test.cpp index b7fd7bf2baf..97f3602cfec 100644 --- a/src/plugins/intel_gna/tests/unit/gna_plugin_load_network_test.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_plugin_load_network_test.cpp @@ -45,7 +45,7 @@ protected: mock.set_create_model(test_parameter.load_succesfull); mock.init(); - GNAPluginNS::GNAPlugin gna_plugin{}; + GNAPlugin gna_plugin{}; InferenceEngine::CNNNetwork cnn_network{function}; bool load_succesfull = true; try { diff --git a/src/plugins/intel_gna/tests/unit/gna_wait_test.cpp b/src/plugins/intel_gna/tests/unit/gna_wait_test.cpp index 97ca62d8800..4a78237459f 100644 --- a/src/plugins/intel_gna/tests/unit/gna_wait_test.cpp +++ b/src/plugins/intel_gna/tests/unit/gna_wait_test.cpp @@ -17,8 +17,7 @@ #include "request/worker_impl.hpp" #include "request/worker_pool.hpp" -using namespace GNAPluginNS; -using namespace GNAPluginNS::request; +using namespace ov::intel_gna::request; using ::testing::_; using ::testing::Return; diff --git a/src/plugins/intel_gna/tests/unit/request/gna_request_worker_factory_test.cpp b/src/plugins/intel_gna/tests/unit/request/gna_request_worker_factory_test.cpp index 3e0fa032e78..5a2a531f690 100644 --- a/src/plugins/intel_gna/tests/unit/request/gna_request_worker_factory_test.cpp +++ b/src/plugins/intel_gna/tests/unit/request/gna_request_worker_factory_test.cpp @@ -9,7 +9,7 @@ #include "request/model_wrapper_factory.hpp" #include "request/worker_factory.hpp" -using namespace GNAPluginNS; +using namespace ov::intel_gna; using namespace request; using namespace testing; diff --git a/src/plugins/intel_gna/tests/unit/request/gna_request_worker_impl_test.cpp b/src/plugins/intel_gna/tests/unit/request/gna_request_worker_impl_test.cpp index 3bc18d15471..6e02ee74898 100644 --- a/src/plugins/intel_gna/tests/unit/request/gna_request_worker_impl_test.cpp +++ b/src/plugins/intel_gna/tests/unit/request/gna_request_worker_impl_test.cpp @@ -8,7 +8,7 @@ #include "request/model_wrapper_factory.hpp" #include "request/worker_impl.hpp" -using namespace GNAPluginNS; +using namespace ov::intel_gna; using namespace request; using namespace testing; @@ -18,7 +18,7 @@ TEST_F(GNA_Request_WorkerImplTest, initDeinit) { ASSERT_THROW(WorkerImpl(nullptr, {}), std::exception); std::vector> subrequests; - ASSERT_THROW(GNAPluginNS::request::WorkerImpl(nullptr, subrequests), std::exception); + ASSERT_THROW(WorkerImpl(nullptr, subrequests), std::exception); auto wrapper = ModelWrapperFactory::createTrivial(); ASSERT_THROW(WorkerImpl(wrapper, {}), std::exception); diff --git a/src/plugins/intel_gna/tests/unit/request/gna_request_worker_pool_impl_test.cpp b/src/plugins/intel_gna/tests/unit/request/gna_request_worker_pool_impl_test.cpp index 88697db12e7..0571151a486 100644 --- a/src/plugins/intel_gna/tests/unit/request/gna_request_worker_pool_impl_test.cpp +++ b/src/plugins/intel_gna/tests/unit/request/gna_request_worker_pool_impl_test.cpp @@ -7,8 +7,7 @@ #include "mock_worker.hpp" #include "request/worker_pool_impl.hpp" -using namespace GNAPluginNS; -using namespace request; +using namespace ov::intel_gna::request; using namespace testing; class GNA_Request_WorkerPoolImplTest : public ::testing::Test { @@ -18,7 +17,7 @@ public: const constexpr uint32_t GNA_Request_WorkerPoolImplTest::kExpectedIndex; TEST_F(GNA_Request_WorkerPoolImplTest, initDeinit) { - ASSERT_NO_THROW(GNAPluginNS::request::WorkerPoolImpl()); + ASSERT_NO_THROW(WorkerPoolImpl()); } TEST_F(GNA_Request_WorkerPoolImplTest, addModelWorker_nullptr) { diff --git a/src/plugins/intel_gna/tests/unit/request/mock_gna_device.hpp b/src/plugins/intel_gna/tests/unit/request/mock_gna_device.hpp index 0f57b6e5559..178a93c8763 100644 --- a/src/plugins/intel_gna/tests/unit/request/mock_gna_device.hpp +++ b/src/plugins/intel_gna/tests/unit/request/mock_gna_device.hpp @@ -7,15 +7,17 @@ #include "gmock/gmock.h" #include "gna_device_interface.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { class MockGNADevice : public GNADevice { public: MOCK_METHOD(uint32_t, createModel, (Gna2Model&), (const, override)); MOCK_METHOD(uint32_t, createRequestConfig, (const uint32_t), (const, override)); MOCK_METHOD(uint32_t, enqueueRequest, (const uint32_t, Gna2AccelerationMode), (override)); - MOCK_METHOD(GNAPluginNS::RequestStatus, waitForRequest, (uint32_t, int64_t), (override)); + MOCK_METHOD(RequestStatus, waitForRequest, (uint32_t, int64_t), (override)); MOCK_METHOD(uint32_t, maxLayersCount, (), (const, override)); }; -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/tests/unit/request/mock_subrequest.hpp b/src/plugins/intel_gna/tests/unit/request/mock_subrequest.hpp index 0f1d0b88ac3..06e85f54704 100644 --- a/src/plugins/intel_gna/tests/unit/request/mock_subrequest.hpp +++ b/src/plugins/intel_gna/tests/unit/request/mock_subrequest.hpp @@ -7,7 +7,8 @@ #include "gmock/gmock.h" #include "request/subrequest.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { class MockSubrequest : public Subrequest { @@ -21,4 +22,5 @@ public: }; } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/tests/unit/request/mock_worker.hpp b/src/plugins/intel_gna/tests/unit/request/mock_worker.hpp index 635ffd94b0a..2a347cf97cf 100644 --- a/src/plugins/intel_gna/tests/unit/request/mock_worker.hpp +++ b/src/plugins/intel_gna/tests/unit/request/mock_worker.hpp @@ -7,7 +7,8 @@ #include "gmock/gmock.h" #include "request/worker.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { class MockWorker : public Worker { @@ -25,4 +26,5 @@ public: }; } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/tests/unit/request/mock_worker_pool.hpp b/src/plugins/intel_gna/tests/unit/request/mock_worker_pool.hpp index a77a6d1f0c1..e2582e5df1a 100644 --- a/src/plugins/intel_gna/tests/unit/request/mock_worker_pool.hpp +++ b/src/plugins/intel_gna/tests/unit/request/mock_worker_pool.hpp @@ -7,7 +7,8 @@ #include "gmock/gmock.h" #include "request/worker_pool.hpp" -namespace GNAPluginNS { +namespace ov { +namespace intel_gna { namespace request { class MockWorkerPool : public WorkerPool { @@ -25,4 +26,5 @@ public: }; } // namespace request -} // namespace GNAPluginNS +} // namespace intel_gna +} // namespace ov diff --git a/src/plugins/intel_gna/tests/unit/scale_factor_helper_test.cpp b/src/plugins/intel_gna/tests/unit/scale_factor_helper_test.cpp index 21b641a09f5..b7cd7533266 100644 --- a/src/plugins/intel_gna/tests/unit/scale_factor_helper_test.cpp +++ b/src/plugins/intel_gna/tests/unit/scale_factor_helper_test.cpp @@ -76,22 +76,22 @@ public: } } - GNAPluginNS::Config _config; - GNAPluginNS::HeaderLatest::ModelHeader _header; - GNAPluginNS::GnaInputs _gna_inputs; + Config _config; + header_latest::ModelHeader _header; + GnaInputs _gna_inputs; std::vector> _test_inputs; bool _applicable; bool _legacy_scale_factor; }; TEST_P(GNAApplyInputScaleFactorsTest, test_scale_factor_set_properly) { - EXPECT_NO_THROW(ov::intela_gna::helpers::ApplyInputScaleFactors(_config, _header, _gna_inputs)); + EXPECT_NO_THROW(ov::intel_gna::helpers::ApplyInputScaleFactors(_config, _header, _gna_inputs)); for (const auto& input : _test_inputs) { auto& input_ref = _gna_inputs[input.first]; if (_applicable) { EXPECT_FLOAT_EQ(input_ref.scale_factor, input.second); } else { - EXPECT_FLOAT_EQ(input_ref.scale_factor, GNAPluginNS::kScaleFactorDefault); + EXPECT_FLOAT_EQ(input_ref.scale_factor, kScaleFactorDefault); } } } @@ -104,13 +104,13 @@ TEST_P(GNAApplyInputScaleFactorsTest, inputs_count_not_match_to_scale_factors) { } if (_applicable) { - EXPECT_THROW(ov::intela_gna::helpers::ApplyInputScaleFactors(_config, _header, _gna_inputs), std::exception); + EXPECT_THROW(ov::intel_gna::helpers::ApplyInputScaleFactors(_config, _header, _gna_inputs), std::exception); } else { // check if no exception and data are not changed - EXPECT_NO_THROW(ov::intela_gna::helpers::ApplyInputScaleFactors(_config, _header, _gna_inputs)); + EXPECT_NO_THROW(ov::intel_gna::helpers::ApplyInputScaleFactors(_config, _header, _gna_inputs)); for (const auto& input : _test_inputs) { auto& input_ref = _gna_inputs[input.first]; - EXPECT_FLOAT_EQ(input_ref.scale_factor, GNAPluginNS::kScaleFactorDefault); + EXPECT_FLOAT_EQ(input_ref.scale_factor, kScaleFactorDefault); } } } @@ -130,27 +130,27 @@ INSTANTIATE_TEST_CASE_P(smoke_, // Tests if nothing was changed if there is no custom scale factor in configuration TEST(smoke_GNAApplyInputScaleFactorsTest, test_default_scale_factor) { - GNAPluginNS::Config config; - GNAPluginNS::HeaderLatest::ModelHeader header; - GNAPluginNS::GnaInputs inputs; + Config config; + header_latest::ModelHeader header; + GnaInputs inputs; std::string input_name = "input"; auto& input_ref = inputs[input_name]; config.inputScaleFactors.clear(); config.inputScaleFactorsPerInput.clear(); - EXPECT_NO_THROW(ov::intela_gna::helpers::ApplyInputScaleFactors(config, header, inputs)); + EXPECT_NO_THROW(ov::intel_gna::helpers::ApplyInputScaleFactors(config, header, inputs)); - EXPECT_FLOAT_EQ(input_ref.scale_factor, GNAPluginNS::kScaleFactorDefault); + EXPECT_FLOAT_EQ(input_ref.scale_factor, kScaleFactorDefault); } // Tests if exception is thron if input scale factor name does not match to input name TEST(smoke_GNAApplyInputScaleFactorsTest, test_wrong_scale_factor_config_input_name) { - GNAPluginNS::Config config; - GNAPluginNS::HeaderLatest::ModelHeader header; + Config config; + header_latest::ModelHeader header; header.version.major = 2; header.version.minor = 7; - GNAPluginNS::GnaInputs gna_inputs; + GnaInputs gna_inputs; const std::string name_1{"input_1"}; const std::string name_2{"input_2"}; @@ -161,5 +161,5 @@ TEST(smoke_GNAApplyInputScaleFactorsTest, test_wrong_scale_factor_config_input_n config.inputScaleFactorsPerInput[name_1] = 2.0; config.inputScaleFactorsPerInput[name_2 + "__"] = 2.0; - EXPECT_THROW(ov::intela_gna::helpers::ApplyInputScaleFactors(config, header, gna_inputs), std::exception); + EXPECT_THROW(ov::intel_gna::helpers::ApplyInputScaleFactors(config, header, gna_inputs), std::exception); } \ No newline at end of file diff --git a/src/plugins/intel_gna/tests/unit/transformations/gna_decompose_2d_convolution.cpp b/src/plugins/intel_gna/tests/unit/transformations/gna_decompose_2d_convolution.cpp index 1d38d7a7543..ce2329e81db 100644 --- a/src/plugins/intel_gna/tests/unit/transformations/gna_decompose_2d_convolution.cpp +++ b/src/plugins/intel_gna/tests/unit/transformations/gna_decompose_2d_convolution.cpp @@ -635,7 +635,7 @@ static size_t CalculateConvCount(const ConvParams& conv_params) { // Check if split of plane due to GNA HW limitations of 768 filter elements is possible size_t conv_count = 1; size_t total_factorized_conv_channel_count = (conv_params.input_channel_count * conv_params.filter_height * conv_params.filter_width); - while (total_factorized_conv_channel_count / conv_count > GNAPluginNS::GNALimitations::convFilterMaxSize || + while (total_factorized_conv_channel_count / conv_count > ov::intel_gna::limitations::convFilterMaxSize || total_factorized_conv_channel_count % conv_count != 0 || conv_params.filter_channel_count % conv_count != 0) conv_count++; @@ -648,7 +648,7 @@ static bool ShouldDecompose(GraphData& graph_data, const ConvParams& conv_params // Concat (copy) layer limitation allows to split up to a certain limit // Currently we are able to split only convolutions without pooling in horizontal dimension - if (graph_data.conv_count > GNAPluginNS::GNALimitations::copyMaxGrouping || + if (graph_data.conv_count > ov::intel_gna::limitations::copyMaxGrouping || ((graph_data.pool_size_width > 1 || graph_data.pool_stride_width > 1) && graph_data.conv_count > 1)) return false; diff --git a/src/plugins/intel_gna/tests/unit/transformations/gna_decompose_mvn.cpp b/src/plugins/intel_gna/tests/unit/transformations/gna_decompose_mvn.cpp index cc1f004318c..fb2fb07e37f 100644 --- a/src/plugins/intel_gna/tests/unit/transformations/gna_decompose_mvn.cpp +++ b/src/plugins/intel_gna/tests/unit/transformations/gna_decompose_mvn.cpp @@ -188,7 +188,7 @@ std::shared_ptr getReferenceFunction(const ngraph::Shape& inpu mvn_data.normalize_variance = normalize_variance; mvn_data.num_parts = 1; - while (mvn_data.W / mvn_data.num_parts > GNAPluginNS::GNALimitations::convFilterMaxSize) { + while (mvn_data.W / mvn_data.num_parts > ov::intel_gna::limitations::convFilterMaxSize) { mvn_data.num_parts *= 2; } diff --git a/src/plugins/intel_gna/tests/unit/transformations/gna_split_eltwise.cpp b/src/plugins/intel_gna/tests/unit/transformations/gna_split_eltwise.cpp index ae6a5c95742..07d987e6d28 100644 --- a/src/plugins/intel_gna/tests/unit/transformations/gna_split_eltwise.cpp +++ b/src/plugins/intel_gna/tests/unit/transformations/gna_split_eltwise.cpp @@ -55,7 +55,7 @@ static std::shared_ptr createFunction(const ngraph::Shape& inp } if (split) { - auto split_sizes_per_axis = GNAPluginNS::AlignedSplitSizesPerAxis(input_shape); + auto split_sizes_per_axis = ov::intel_gna::AlignedSplitSizesPerAxis(input_shape); auto split0 = std::make_shared(last_node0, ngraph::opset9::Constant::create(ngraph::element::i64, ngraph::Shape({1}), std::vector{split_sizes_per_axis.first}), ngraph::opset9::Constant::create(ngraph::element::i64, ngraph::Shape({split_sizes_per_axis.second.size()}), split_sizes_per_axis.second)); diff --git a/src/tests_deprecated/unit/engines/gna/I8_quantisation_test.cpp b/src/tests_deprecated/unit/engines/gna/I8_quantisation_test.cpp index 11583a85439..5318952b286 100644 --- a/src/tests_deprecated/unit/engines/gna/I8_quantisation_test.cpp +++ b/src/tests_deprecated/unit/engines/gna/I8_quantisation_test.cpp @@ -18,7 +18,7 @@ class I8QuantisationTest : public GNATest<> { protected: InferenceEngine::CNNLayerPtr quantize(InferenceEngine::CNNLayerPtr lp) { auto newLayer = InferenceEngine::injectData(lp); - GNAPluginNS::Config gna_config; + Config gna_config; gna_config.gnaPrecision = InferenceEngine::Precision::I16; gna_config.gnaFlags.input_low_precision = false; LayerQuantizer lq(gna_config); @@ -29,13 +29,13 @@ class I8QuantisationTest : public GNATest<> { InferenceEngine::CNNNetwork quantize_single_input_model(const InferenceEngine::CNNNetwork& model, float scale_factor) const { auto scale_factors = std::vector({scale_factor}); - GNAPluginNS::GnaInputs inputs; + GnaInputs inputs; InferenceEngine::InputsDataMap inputs_map = model.getInputsInfo(); auto input_layer = getCreatorLayer(inputs_map.begin()->second->getInputData()).lock(); inputs[input_layer->name].scale_factor = scale_factor; - GNAPluginNS::Config gna_config; + Config gna_config; gna_config.gnaPrecision = InferenceEngine::Precision::I16; gna_config.gnaFlags.input_low_precision = false; diff --git a/src/tests_deprecated/unit/engines/gna/fp32_non_quantized_tests.cpp b/src/tests_deprecated/unit/engines/gna/fp32_non_quantized_tests.cpp index 16134cd787a..7f0768738a1 100644 --- a/src/tests_deprecated/unit/engines/gna/fp32_non_quantized_tests.cpp +++ b/src/tests_deprecated/unit/engines/gna/fp32_non_quantized_tests.cpp @@ -9,7 +9,6 @@ #include "gna_matcher.hpp" using namespace InferenceEngine; -using namespace GNAPluginNS; using namespace GNATestIRs; class FP32NonQuantizedTest : public GNATest<>{ diff --git a/src/tests_deprecated/unit/engines/gna/gna_matcher.cpp b/src/tests_deprecated/unit/engines/gna/gna_matcher.cpp index 13e3eb1a895..8b4342875c6 100644 --- a/src/tests_deprecated/unit/engines/gna/gna_matcher.cpp +++ b/src/tests_deprecated/unit/engines/gna/gna_matcher.cpp @@ -4,7 +4,7 @@ #include "gna_matcher.hpp" #include -#include "backend/gna_types.h" +#include "backend/gna_types.hpp" #include #include "gna_plugin.hpp" #include "gna_mock_api.hpp" @@ -34,7 +34,6 @@ using namespace std; using namespace InferenceEngine; -using namespace GNAPluginNS; using namespace ::testing; #if USE_RANDOM_SEED @@ -636,7 +635,7 @@ void GNADumpXNNMatcher::match() { try { // matching gna DumpXNN forward call. - auto plugin = std::make_shared(); + auto plugin = std::make_shared(); load(plugin); } catch(std::exception &ex) { diff --git a/src/tests_deprecated/unit/engines/gna/gna_matcher.hpp b/src/tests_deprecated/unit/engines/gna/gna_matcher.hpp index e37c592d1a7..e5366a1c690 100644 --- a/src/tests_deprecated/unit/engines/gna/gna_matcher.hpp +++ b/src/tests_deprecated/unit/engines/gna/gna_matcher.hpp @@ -22,8 +22,8 @@ #include #include -#include -#include +#include +#include #include #include #include @@ -471,7 +471,7 @@ class GNADumpXNNMatcher : public GNATestConfigurability { protected: bool match_in_dctor = true; - void load(std::shared_ptr & plugin); + void load(std::shared_ptr & plugin); void match(); }; diff --git a/src/tests_deprecated/unit/engines/gna/gna_proc_type_test.cpp b/src/tests_deprecated/unit/engines/gna/gna_proc_type_test.cpp index c722e99735f..bfee58ed8eb 100644 --- a/src/tests_deprecated/unit/engines/gna/gna_proc_type_test.cpp +++ b/src/tests_deprecated/unit/engines/gna/gna_proc_type_test.cpp @@ -15,7 +15,6 @@ using namespace std; using namespace InferenceEngine; -using namespace GNAPluginNS; using namespace ::testing; class GNAProcTypeTest : public GNATest<> { diff --git a/src/tests_deprecated/unit/engines/gna/graph_tools/graph_copy_tests.cpp b/src/tests_deprecated/unit/engines/gna/graph_tools/graph_copy_tests.cpp index f6d4cb2e5c1..b70e454f751 100644 --- a/src/tests_deprecated/unit/engines/gna/graph_tools/graph_copy_tests.cpp +++ b/src/tests_deprecated/unit/engines/gna/graph_tools/graph_copy_tests.cpp @@ -26,7 +26,7 @@ protected: MockCopier mc; InferenceEngine::CNNNetwork quantize(const InferenceEngine::CNNNetwork& model, std::vector scale_factors) const { - GNAPluginNS::GnaInputs inputs; + GnaInputs inputs; InferenceEngine::InputsDataMap inputs_map = model.getInputsInfo(); size_t sf_id = 0; for (auto&& input_data : inputs_map) { @@ -37,7 +37,7 @@ protected: inputs[input_layer->name].scale_factor = scale_factors[sf_id++]; } - GNAPluginNS::Config gna_config; + Config gna_config; gna_config.gnaPrecision = InferenceEngine::Precision::I16; gna_config.gnaFlags.input_low_precision = false; @@ -115,8 +115,6 @@ TEST_F(GraphCopyTests, canPreserveAttributes) { ASSERT_STREQ(idMemInput.c_str(), "r-1-2-3"); } -using namespace GNAPluginNS; - TEST_F(GraphCopyTests, canQuantizeTopology) { auto clone = quantize(CNNNetwork(mockNet), std::vector({1.0f, 1.0f})); diff --git a/src/tests_deprecated/unit/engines/gna/i16_quantisation_test.cpp b/src/tests_deprecated/unit/engines/gna/i16_quantisation_test.cpp index 4ae783f93e3..0d47463ec87 100644 --- a/src/tests_deprecated/unit/engines/gna/i16_quantisation_test.cpp +++ b/src/tests_deprecated/unit/engines/gna/i16_quantisation_test.cpp @@ -5,7 +5,7 @@ #include #include #include -#include "backend/gna_types.h" +#include "backend/gna_types.hpp" #include "frontend/model_quantizer.hpp" #include "frontend/layer_quantizer.hpp" #include "gna_matcher.hpp" @@ -20,7 +20,7 @@ class I16QuantisationTest : public GNATest<> { protected: InferenceEngine::CNNLayerPtr quantize (InferenceEngine::CNNLayerPtr lp) { auto newLayer = InferenceEngine::injectData(lp); - GNAPluginNS::Config gna_config; + Config gna_config; gna_config.gnaPrecision = InferenceEngine::Precision::I16; gna_config.gnaFlags.input_low_precision = false; LayerQuantizer lq(gna_config); @@ -31,13 +31,13 @@ class I16QuantisationTest : public GNATest<> { InferenceEngine::CNNNetwork quantize_single_input_model(const InferenceEngine::CNNNetwork& model, float scale_factor) const { auto scale_factors = std::vector({scale_factor}); - GNAPluginNS::GnaInputs inputs; + GnaInputs inputs; InferenceEngine::InputsDataMap inputs_map = model.getInputsInfo(); auto input_layer = getCreatorLayer(inputs_map.begin()->second->getInputData()).lock(); inputs[input_layer->name].scale_factor = scale_factor; - GNAPluginNS::Config gna_config; + Config gna_config; gna_config.gnaPrecision = InferenceEngine::Precision::I16; gna_config.gnaFlags.input_low_precision = false; diff --git a/src/tests_deprecated/unit/engines/gna/layers/gna_align_filter2_tests.cpp b/src/tests_deprecated/unit/engines/gna/layers/gna_align_filter2_tests.cpp index fa467205fcc..47e42d8fff3 100644 --- a/src/tests_deprecated/unit/engines/gna/layers/gna_align_filter2_tests.cpp +++ b/src/tests_deprecated/unit/engines/gna/layers/gna_align_filter2_tests.cpp @@ -12,7 +12,6 @@ #include "../gna_matcher.hpp" using GNAAlignFilterTestParams = std::tuple; -using namespace GNAPluginNS; class GNAAlignFilterTest : public GNATest<>, public testing::WithParamInterface { diff --git a/src/tests_deprecated/unit/engines/gna/matchers/copy_matcher.hpp b/src/tests_deprecated/unit/engines/gna/matchers/copy_matcher.hpp index 3762638c3a6..d6395a92000 100644 --- a/src/tests_deprecated/unit/engines/gna/matchers/copy_matcher.hpp +++ b/src/tests_deprecated/unit/engines/gna/matchers/copy_matcher.hpp @@ -5,7 +5,7 @@ #pragma once #include "nnet_base_matcher.hpp" -#include "backend/gna_types.h" +#include "backend/gna_types.hpp" class CopyLayerMatcher : public ::testing::MatcherInterface { bool matchInserted; diff --git a/src/tests_deprecated/unit/engines/gna/matchers/fill_with_data.hpp b/src/tests_deprecated/unit/engines/gna/matchers/fill_with_data.hpp index e6f57f1b101..8c547c947f2 100644 --- a/src/tests_deprecated/unit/engines/gna/matchers/fill_with_data.hpp +++ b/src/tests_deprecated/unit/engines/gna/matchers/fill_with_data.hpp @@ -4,7 +4,7 @@ #pragma once -#include "backend/gna_types.h" +#include "backend/gna_types.hpp" class OutputFiller : public ::testing::MatcherInterface { mutable std::stringstream reason; diff --git a/src/tests_deprecated/unit/engines/gna/matchers/input_data_matcher.hpp b/src/tests_deprecated/unit/engines/gna/matchers/input_data_matcher.hpp index 90926673e4a..1acd15c7f48 100644 --- a/src/tests_deprecated/unit/engines/gna/matchers/input_data_matcher.hpp +++ b/src/tests_deprecated/unit/engines/gna/matchers/input_data_matcher.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include "backend/gna_types.h" +#include "backend/gna_types.hpp" #include "nnet_base_matcher.hpp" class InputDataMatcher : public ::testing::MatcherInterface { diff --git a/src/tests_deprecated/unit/engines/gna/matchers/nnet_base_matcher.hpp b/src/tests_deprecated/unit/engines/gna/matchers/nnet_base_matcher.hpp index 72849b7d5ff..c5375df5958 100644 --- a/src/tests_deprecated/unit/engines/gna/matchers/nnet_base_matcher.hpp +++ b/src/tests_deprecated/unit/engines/gna/matchers/nnet_base_matcher.hpp @@ -4,7 +4,7 @@ #pragma once -#include "backend/gna_types.h" +#include "backend/gna_types.hpp" #include "gna_lib_ver_selector.hpp" class NNetComponentMatcher : public ::testing::MatcherInterface { diff --git a/src/tests_deprecated/unit/engines/gna/matchers/precision_matcher.hpp b/src/tests_deprecated/unit/engines/gna/matchers/precision_matcher.hpp index 873eb039521..05ed0167534 100644 --- a/src/tests_deprecated/unit/engines/gna/matchers/precision_matcher.hpp +++ b/src/tests_deprecated/unit/engines/gna/matchers/precision_matcher.hpp @@ -4,7 +4,7 @@ #pragma once #include "nnet_base_matcher.hpp" -#include "backend/gna_types.h" +#include "backend/gna_types.hpp" #include "gna_lib_ver_selector.hpp" class NNetPrecisionMatcher : public ::testing::MatcherInterface { diff --git a/src/tests_deprecated/unit/engines/gna/matchers/pwl_quantization_metrics_matcher.hpp b/src/tests_deprecated/unit/engines/gna/matchers/pwl_quantization_metrics_matcher.hpp index e907de22dc9..03ef7fe4613 100644 --- a/src/tests_deprecated/unit/engines/gna/matchers/pwl_quantization_metrics_matcher.hpp +++ b/src/tests_deprecated/unit/engines/gna/matchers/pwl_quantization_metrics_matcher.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include "nnet_base_matcher.hpp"