From e79636bfbbcde2a8806b1f064216d617b2c04930 Mon Sep 17 00:00:00 2001 From: Szymon Irzabek Date: Tue, 7 Mar 2023 17:14:59 +0100 Subject: [PATCH] [GNA] Add 3.6 and 4.0 targets (#15735) --- samples/cpp/speech_sample/main.cpp | 20 +++++++----- src/inference/include/ie/gna/gna_config.hpp | 7 ---- .../openvino/runtime/intel_gna/properties.hpp | 25 +++++++++++++++ .../intel_gna/src/backend/gna_limitations.cpp | 27 +++++++++------- .../intel_gna/src/backend/gna_limitations.hpp | 12 +++---- .../intel_gna/src/common/gna_target.cpp | 32 +++++++++++++------ .../intel_gna/src/common/gna_target.hpp | 10 +++--- .../src/gna2_model_export_helper.cpp | 11 +++---- .../src/gna2_model_export_helper.hpp | 2 +- src/plugins/intel_gna/src/gna_device.cpp | 7 +++- src/plugins/intel_gna/src/gna_device.hpp | 14 ++++---- .../intel_gna/src/gna_graph_compiler.cpp | 2 +- .../intel_gna/src/gna_graph_compiler.hpp | 2 +- src/plugins/intel_gna/src/gna_plugin.cpp | 6 ++-- .../intel_gna/src/gna_plugin_config.cpp | 9 ++---- .../intel_gna/src/gna_plugin_config.hpp | 6 ++-- .../src/gna_transformations_pipeline.hpp | 10 +++--- .../decompose_2d_convolution.cpp | 2 +- .../decompose_2d_convolution.hpp | 6 ++-- .../unit/backend/gna_limitations_test.cpp | 2 +- .../tests/unit/gna_plugin_config_test.cpp | 13 ++++++-- .../gna_decompose_2d_convolution.cpp | 6 ++-- 22 files changed, 138 insertions(+), 93 deletions(-) diff --git a/samples/cpp/speech_sample/main.cpp b/samples/cpp/speech_sample/main.cpp index 3cf0459fb95..e913d71411a 100644 --- a/samples/cpp/speech_sample/main.cpp +++ b/samples/cpp/speech_sample/main.cpp @@ -221,19 +221,23 @@ int main(int argc, char* argv[]) { } } gnaPluginConfig[ov::inference_precision.name()] = (FLAGS_qb == 8) ? ov::element::i8 : ov::element::i16; + const std::unordered_map StringHWGenerationMap{ + {"GNA_TARGET_1_0", ov::intel_gna::HWGeneration::GNA_1_0}, + {"GNA_TARGET_2_0", ov::intel_gna::HWGeneration::GNA_2_0}, + {"GNA_TARGET_3_0", ov::intel_gna::HWGeneration::GNA_3_0}, + {"GNA_TARGET_3_1", ov::intel_gna::HWGeneration::GNA_3_1}, + {"GNA_TARGET_3_5", ov::intel_gna::HWGeneration::GNA_3_5}, + {"GNA_TARGET_3_5_E", ov::intel_gna::HWGeneration::GNA_3_5_E}, + {"GNA_TARGET_3_6", ov::intel_gna::HWGeneration::GNA_3_6}, + {"GNA_TARGET_4_0", ov::intel_gna::HWGeneration::GNA_4_0}}; auto parse_target = [&](const std::string& target) -> ov::intel_gna::HWGeneration { auto hw_target = ov::intel_gna::HWGeneration::UNDEFINED; - - if (target == "GNA_TARGET_2_0") { - hw_target = ov::intel_gna::HWGeneration::GNA_2_0; - } else if (target == "GNA_TARGET_3_0") { - hw_target = ov::intel_gna::HWGeneration::GNA_3_0; - } else if (target == "GNA_TARGET_3_5") { - hw_target = ov::intel_gna::HWGeneration::GNA_3_5; + const auto key_iter = StringHWGenerationMap.find(target); + if (key_iter != StringHWGenerationMap.end()) { + hw_target = key_iter->second; } else if (!target.empty()) { slog::warn << "Unsupported target: " << target << slog::endl; } - return hw_target; }; diff --git a/src/inference/include/ie/gna/gna_config.hpp b/src/inference/include/ie/gna/gna_config.hpp index 453e5d5db41..5efd720d75b 100644 --- a/src/inference/include/ie/gna/gna_config.hpp +++ b/src/inference/include/ie/gna/gna_config.hpp @@ -53,13 +53,6 @@ DECLARE_GNA_CONFIG_KEY(PRECISION); */ DECLARE_GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE); -/** - * @brief Generation of GNA embedded device to export the model. - * @deprecated Key is deprecated and will be removed in a future release. - */ -INFERENCE_ENGINE_DEPRECATED("The config key will be removed") -DECLARE_GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE_GENERATION); - /** * @brief GNA proc_type setting that should be one of GNA_AUTO, GNA_HW, GNA_HW_WITH_SW_FBACK, GNA_SW_EXACT */ diff --git a/src/inference/include/openvino/runtime/intel_gna/properties.hpp b/src/inference/include/openvino/runtime/intel_gna/properties.hpp index 2c384c6af90..7d4f381f715 100644 --- a/src/inference/include/openvino/runtime/intel_gna/properties.hpp +++ b/src/inference/include/openvino/runtime/intel_gna/properties.hpp @@ -117,9 +117,14 @@ inline std::istream& operator>>(std::istream& is, ExecutionMode& execution_mode) */ enum class HWGeneration { UNDEFINED = 0, //!< GNA HW generation is undefined + GNA_1_0 = 4, //!< GNA HW generation 1.0 GNA_2_0 = 1, //!< GNA HW generation 2.0 GNA_3_0 = 2, //!< GNA HW generation 3.0 + GNA_3_1 = 5, //!< GNA HW generation 3.1 GNA_3_5 = 3, //!< GNA HW generation 3.5 + GNA_3_5_E = 6, //!< GNA HW generation 3.5 embedded + GNA_3_6 = 7, //!< GNA HW generation 3.6 + GNA_4_0 = 8, //!< GNA HW generation 4.0 }; /** @cond INTERNAL */ @@ -127,12 +132,22 @@ inline std::ostream& operator<<(std::ostream& os, const HWGeneration& hw_generat switch (hw_generation) { case HWGeneration::UNDEFINED: return os << "UNDEFINED"; + case HWGeneration::GNA_1_0: + return os << "GNA_1_0"; case HWGeneration::GNA_2_0: return os << "GNA_2_0"; case HWGeneration::GNA_3_0: return os << "GNA_3_0"; + case HWGeneration::GNA_3_1: + return os << "GNA_3_1"; case HWGeneration::GNA_3_5: return os << "GNA_3_5"; + case HWGeneration::GNA_3_5_E: + return os << "GNA_3_5_E"; + case HWGeneration::GNA_3_6: + return os << "GNA_3_6"; + case HWGeneration::GNA_4_0: + return os << "GNA_4_0"; default: throw ov::Exception{"Unsupported HW generation!"}; } @@ -143,12 +158,22 @@ inline std::istream& operator>>(std::istream& is, HWGeneration& hw_generation) { is >> str; if (str == "UNDEFINED") { hw_generation = HWGeneration::UNDEFINED; + } else if (str == "GNA_1_0") { + hw_generation = HWGeneration::GNA_1_0; } else if (str == "GNA_2_0") { hw_generation = HWGeneration::GNA_2_0; } else if (str == "GNA_3_0") { hw_generation = HWGeneration::GNA_3_0; + } else if (str == "GNA_3_1") { + hw_generation = HWGeneration::GNA_3_1; } else if (str == "GNA_3_5") { hw_generation = HWGeneration::GNA_3_5; + } else if (str == "GNA_3_5_E") { + hw_generation = HWGeneration::GNA_3_5_E; + } else if (str == "GNA_3_6") { + hw_generation = HWGeneration::GNA_3_6; + } else if (str == "GNA_4_0") { + hw_generation = HWGeneration::GNA_4_0; } else { throw ov::Exception{"Unsupported HW generation: " + str}; } diff --git a/src/plugins/intel_gna/src/backend/gna_limitations.cpp b/src/plugins/intel_gna/src/backend/gna_limitations.cpp index a497d5a3bdd..594f751dcbe 100644 --- a/src/plugins/intel_gna/src/backend/gna_limitations.cpp +++ b/src/plugins/intel_gna/src/backend/gna_limitations.cpp @@ -34,6 +34,7 @@ inline std::ostream& operator<<(std::ostream& os, const std::set SupportedElementTypes::supported_parameter_types = {ov::element::u8, @@ -71,7 +72,7 @@ bool SupportedElementTypes::is_constant_type_supported(ov::element::Type elem_ty } bool is_conv_supported(const std::shared_ptr& conv_ie, - const ov::intel_gna::common::DeviceVersion& effective_compile_target, + const DeviceVersion& effective_compile_target, const InferenceEngine::Precision gna_precision, bool is_exception_allowed) { OPENVINO_ASSERT(conv_ie, "ConvolutionIE node is empty!"); @@ -129,7 +130,7 @@ bool is_conv_supported(const std::shared_ptr& conv_ie } bool is_pooling_supported(const std::shared_ptr max_pool, - const ov::intel_gna::common::DeviceVersion& effective_compile_target, + const DeviceVersion& effective_compile_target, bool is_exception_allowed) { OPENVINO_ASSERT(max_pool, "MaxPool node is empty!"); auto kernels = max_pool->get_kernel(); @@ -172,7 +173,7 @@ bool is_split_supported(const std::shared_ptr& node, bool is_exception } bool is_op_supported(const std::shared_ptr& node, - const ov::intel_gna::common::DeviceVersion& effective_compile_target, + const DeviceVersion& effective_compile_target, const InferenceEngine::Precision gna_precision, bool is_exception_allowed) { if (ov::op::util::is_parameter(node)) { @@ -210,7 +211,7 @@ bool is_op_supported(const std::shared_ptr& node, } void check_all_ops_supported(const std::shared_ptr& model, - const ov::intel_gna::common::DeviceVersion& effective_compile_target, + const DeviceVersion& effective_compile_target, const InferenceEngine::Precision gna_precision) { std::stringstream error; // Walk through the transformed model @@ -627,13 +628,15 @@ bool Validator_35::ShouldUseOnlyConv2DGnaIface() const { return true; } -std::unique_ptr AbstractValidator::Create(const common::DeviceVersion& target) { +std::unique_ptr AbstractValidator::Create(const DeviceVersion& target) { switch (target) { - case common::DeviceVersion::GNA3_0: - case common::DeviceVersion::GNAEmbedded3_1: + case DeviceVersion::GNA3_0: + case DeviceVersion::GNA3_1: return tools::make_unique(); - case common::DeviceVersion::GNA3_5: - case common::DeviceVersion::GNAEmbedded3_5: + case DeviceVersion::GNA3_5: + case DeviceVersion::GNAEmbedded3_5: + case DeviceVersion::GNA3_6: + case DeviceVersion::GNA4_0: return tools::make_unique(); default: return nullptr; @@ -658,9 +661,9 @@ bool AbstractValidator::ValidationSuccesful(const bool throwOnError, return error.empty(); } -bool UseOnly16BitConvolutionWeights(const common::DeviceVersion& compile_target) { - return (compile_target == common::DeviceVersion::GNA2_0 || compile_target == common::DeviceVersion::GNA3_0) || - compile_target == common::DeviceVersion::GNAEmbedded3_1; +bool UseOnly16BitConvolutionWeights(const DeviceVersion& compile_target) { + return compile_target == DeviceVersion::GNA1_0 || compile_target == DeviceVersion::GNA2_0 || + compile_target == DeviceVersion::GNA3_0 || compile_target == DeviceVersion::GNA3_1; } } // namespace cnn2d diff --git a/src/plugins/intel_gna/src/backend/gna_limitations.hpp b/src/plugins/intel_gna/src/backend/gna_limitations.hpp index 5db7a456f00..70c28e222be 100644 --- a/src/plugins/intel_gna/src/backend/gna_limitations.hpp +++ b/src/plugins/intel_gna/src/backend/gna_limitations.hpp @@ -95,7 +95,7 @@ private: * @return true if supported */ bool is_conv_supported(const std::shared_ptr& conv_ie, - const ov::intel_gna::common::DeviceVersion& effective_compile_target, + const target::DeviceVersion& effective_compile_target, const InferenceEngine::Precision gna_precision, bool is_exception_allowed = false); /** @@ -107,7 +107,7 @@ bool is_conv_supported(const std::shared_ptr& conv_ie * @return true if precision is found in supported */ bool is_pooling_supported(const std::shared_ptr max_pool, - const ov::intel_gna::common::DeviceVersion& effective_compile_target, + const target::DeviceVersion& effective_compile_target, bool is_exception_allowed = false); /** @@ -136,7 +136,7 @@ bool is_split_supported(const std::shared_ptr& node, bool is_exception * @return true if supported */ bool is_op_supported(const std::shared_ptr& node, - const ov::intel_gna::common::DeviceVersion& effective_compile_target, + const target::DeviceVersion& effective_compile_target, const InferenceEngine::Precision gna_precision, bool is_exception_allowed = false); @@ -147,7 +147,7 @@ bool is_op_supported(const std::shared_ptr& node, * @param gna_precision GNA inference precision */ void check_all_ops_supported(const std::shared_ptr& model, - const ov::intel_gna::common::DeviceVersion& effective_compile_target, + const target::DeviceVersion& effective_compile_target, const InferenceEngine::Precision gna_precision); namespace cnn2d { @@ -279,7 +279,7 @@ public: OvGnaType inPrecision, bool exception = true) const = 0; - static std::unique_ptr Create(const common::DeviceVersion& target); + static std::unique_ptr Create(const target::DeviceVersion& target); }; class Validator_30 : public AbstractValidator { @@ -431,7 +431,7 @@ public: bool exception = true) const override; }; -bool UseOnly16BitConvolutionWeights(const common::DeviceVersion& compile_target); +bool UseOnly16BitConvolutionWeights(const target::DeviceVersion& compile_target); } // namespace cnn2d diff --git a/src/plugins/intel_gna/src/common/gna_target.cpp b/src/plugins/intel_gna/src/common/gna_target.cpp index df2f117b8d2..ff6b2e28140 100644 --- a/src/plugins/intel_gna/src/common/gna_target.cpp +++ b/src/plugins/intel_gna/src/common/gna_target.cpp @@ -12,7 +12,8 @@ namespace ov { namespace intel_gna { -namespace common { +using namespace common; +namespace target { static constexpr const char* kGnaTargetUnspecified = ""; static constexpr const char* kGnaTargetSoftwareEmulation = "GNA_SW_EMULATION"; @@ -22,35 +23,48 @@ 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* kGnaTarget3_5_e = "GNA_TARGET_3_5_E"; +static constexpr const char* kGnaTarget3_6 = "GNA_TARGET_3_6"; +static constexpr const char* kGnaTarget4_0 = "GNA_TARGET_4_0"; static const std::unordered_map HWGenerationDeviceMap{ + {HWGeneration::GNA_1_0, DeviceVersion::GNA1_0}, {HWGeneration::GNA_2_0, DeviceVersion::GNA2_0}, {HWGeneration::GNA_3_0, DeviceVersion::GNA3_0}, + {HWGeneration::GNA_3_1, DeviceVersion::GNA3_1}, {HWGeneration::GNA_3_5, DeviceVersion::GNA3_5}, + {HWGeneration::GNA_3_5_E, DeviceVersion::GNAEmbedded3_5}, + {HWGeneration::GNA_3_6, DeviceVersion::GNA3_6}, + {HWGeneration::GNA_4_0, DeviceVersion::GNA4_0}, {HWGeneration::UNDEFINED, DeviceVersion::NotSet}}; static const std::unordered_map GnaDeviceMap{ - {Gna2DeviceVersionEmbedded1_0, DeviceVersion::GNAEmbedded1_0}, + {Gna2DeviceVersionEmbedded1_0, DeviceVersion::GNA1_0}, {Gna2DeviceVersion2_0, DeviceVersion::GNA2_0}, {Gna2DeviceVersion3_0, DeviceVersion::GNA3_0}, - {Gna2DeviceVersionEmbedded3_1, DeviceVersion::GNAEmbedded3_1}, + {Gna2DeviceVersionEmbedded3_1, DeviceVersion::GNA3_1}, {Gna2DeviceVersion3_5, DeviceVersion::GNA3_5}, {Gna2DeviceVersionEmbedded3_5, DeviceVersion::GNAEmbedded3_5}, + {Gna2DeviceVersionEmbedded3_5, DeviceVersion::GNA3_6}, + {Gna2DeviceVersionEmbedded3_5, DeviceVersion::GNA4_0}, {Gna2DeviceVersionSoftwareEmulation, DeviceVersion::SoftwareEmulation}}; static const std::unordered_map StringDeviceMap{ - {kGnaTarget1_0, DeviceVersion::GNAEmbedded1_0}, + {kGnaTarget1_0, DeviceVersion::GNA1_0}, {kGnaTarget2_0, DeviceVersion::GNA2_0}, {kGnaTarget3_0, DeviceVersion::GNA3_0}, - {kGnaTarget3_1, DeviceVersion::GNAEmbedded3_1}, + {kGnaTarget3_1, DeviceVersion::GNA3_1}, {kGnaTarget3_5, DeviceVersion::GNA3_5}, {kGnaTarget3_5_e, DeviceVersion::GNAEmbedded3_5}, + {kGnaTarget3_6, DeviceVersion::GNA3_6}, + {kGnaTarget4_0, DeviceVersion::GNA4_0}, {kGnaTargetSoftwareEmulation, DeviceVersion::SoftwareEmulation}, {kGnaTargetUnspecified, DeviceVersion::NotSet}}; -static const std::vector EmbeddedDevices{DeviceVersion::GNAEmbedded1_0, - DeviceVersion::GNAEmbedded3_1, - DeviceVersion::GNAEmbedded3_5}; +static const std::vector EmbeddedDevices{DeviceVersion::GNA1_0, + DeviceVersion::GNA3_1, + DeviceVersion::GNAEmbedded3_5, + DeviceVersion::GNA3_6, + DeviceVersion::GNA4_0}; DeviceVersion HwGenerationToDevice(const HWGeneration& target) { return GetValueForKey(target, HWGenerationDeviceMap); @@ -124,6 +138,6 @@ DeviceVersion Target::get_effective_compile_target() const { } } -} // namespace common +} // namespace target } // namespace intel_gna } // namespace ov diff --git a/src/plugins/intel_gna/src/common/gna_target.hpp b/src/plugins/intel_gna/src/common/gna_target.hpp index c8fa0153f5f..81c59e68016 100644 --- a/src/plugins/intel_gna/src/common/gna_target.hpp +++ b/src/plugins/intel_gna/src/common/gna_target.hpp @@ -11,17 +11,19 @@ namespace ov { namespace intel_gna { -namespace common { +namespace target { enum class DeviceVersion { NotSet = -1, SoftwareEmulation = 0, - GNAEmbedded1_0 = 0x10e, + GNA1_0 = 0x10e, GNA2_0 = 0x20, GNA3_0 = 0x30, - GNAEmbedded3_1 = 0x31e, + GNA3_1 = 0x31e, GNA3_5 = 0x35, GNAEmbedded3_5 = 0x35e, + GNA3_6 = 0x36e, + GNA4_0 = 0x40e, Default = GNA3_0 }; @@ -50,6 +52,6 @@ DeviceVersion StringToDevice(const std::string& target); std::string DeviceToString(const DeviceVersion& target); bool IsEmbeddedDevice(const DeviceVersion& target); -} // namespace common +} // namespace target } // namespace intel_gna } // namespace ov 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 7f0c59919bb..31233e20533 100644 --- a/src/plugins/intel_gna/src/gna2_model_export_helper.cpp +++ b/src/plugins/intel_gna/src/gna2_model_export_helper.cpp @@ -20,7 +20,6 @@ namespace ov { namespace intel_gna { -using namespace common; #define Gna2TlvTypeOVInputScaleFactor GNA2_TLV_IMPL_CHAR_TO_TYPE("OVIS") #define Gna2TlvTypeOVOutputScaleFactor GNA2_TLV_IMPL_CHAR_TO_TYPE("OVOS") @@ -31,7 +30,7 @@ static_assert(std::numeric_limits::is_iec559, "Float is not IEC 559 compa typedef std::array TlvFloatRecord; static TlvFloatRecord GetFloatInTLV(Gna2TlvType type, float value) { - TlvFloatRecord r; + TlvFloatRecord r{}; reinterpret_cast(r.data())->type = type; reinterpret_cast(r.data())->length = sizeof(float); *reinterpret_cast(r.data() + sizeof(Gna2TlvRecord)) = value; @@ -95,11 +94,11 @@ static void WriteStringToTlv(std::ostream& outStream, const Gna2TlvType tlvType, void ExportTlvModel(uint32_t modelId, uint32_t deviceIndex, std::ostream& outStream, - const DeviceVersion& compile_target, + const target::DeviceVersion& compile_target, const std::vector& allInputs, const std::vector& allOutputs, const GnaAllocations& allAllocations) { - if (compile_target == DeviceVersion::GNAEmbedded1_0) { + if (compile_target == target::DeviceVersion::GNA1_0) { THROW_GNA_EXCEPTION << "Unsupported compile target for TLV export: GNA Embedded 1.0" << std::endl; } @@ -195,7 +194,7 @@ void ExportTlvModel(uint32_t modelId, Gna2TlvTypeOVOutputScaleFactor, allAllocations.Get(Gna2MemoryTagOutput)); WriteStringToTlv(outStream, Gna2TlvTypeOVString, metadata); - const auto& ovVersionString = ov::intel_gna::get_openvino_version_string(); + const auto& ovVersionString = common::get_openvino_version_string(); WriteStringToTlv(outStream, Gna2TlvTypeOVVersion, ovVersionString); } @@ -223,7 +222,7 @@ void* ExportSueLegacyUsingGnaApi2(uint32_t modelId, uint32_t deviceIndex, Gna2Mo status = Gna2ModelExportConfigSetSource(exportConfig, deviceIndex, modelId); GNADeviceHelper::checkGna2Status(status, "Gna2ModelExportConfigSetSource"); - status = Gna2ModelExportConfigSetTarget(exportConfig, DeviceToGna(DeviceVersion::GNAEmbedded1_0)); + status = Gna2ModelExportConfigSetTarget(exportConfig, DeviceToGna(target::DeviceVersion::GNA1_0)); GNADeviceHelper::checkGna2Status(status, "Gna2ModelExportConfigSetTarget"); void* bufferSueCreekHeader = nullptr; diff --git a/src/plugins/intel_gna/src/gna2_model_export_helper.hpp b/src/plugins/intel_gna/src/gna2_model_export_helper.hpp index 902dda8b5ec..40b19d847ec 100644 --- a/src/plugins/intel_gna/src/gna2_model_export_helper.hpp +++ b/src/plugins/intel_gna/src/gna2_model_export_helper.hpp @@ -73,7 +73,7 @@ void* ExportSueLegacyUsingGnaApi2(uint32_t modelId, uint32_t deviceIndex, Gna2Mo void ExportTlvModel(uint32_t modelId, uint32_t deviceIndex, std::ostream& outStream, - const common::DeviceVersion& compileTarget, + const target::DeviceVersion& compileTarget, const std::vector& inputs, const std::vector& outputs, const GnaAllocations& allAllocation); diff --git a/src/plugins/intel_gna/src/gna_device.cpp b/src/plugins/intel_gna/src/gna_device.cpp index 03d38edda36..0c3d140df5b 100644 --- a/src/plugins/intel_gna/src/gna_device.cpp +++ b/src/plugins/intel_gna/src/gna_device.cpp @@ -30,7 +30,7 @@ namespace ov { namespace intel_gna { -using namespace common; +using namespace target; std::mutex GNADeviceHelper::acrossPluginsSync{}; @@ -570,10 +570,15 @@ uint32_t GNADeviceHelper::retrieveMaxLayersCount() { using namespace limitations; switch (target->get_effective_execution_target()) { + case DeviceVersion::GNA1_0: case DeviceVersion::GNA2_0: return kMaxLayersCountGNA2_0; case DeviceVersion::GNA3_0: + case DeviceVersion::GNA3_1: case DeviceVersion::GNA3_5: + case DeviceVersion::GNAEmbedded3_5: + case DeviceVersion::GNA3_6: + case DeviceVersion::GNA4_0: default: return kMaxLayersCountGNA3_X; } diff --git a/src/plugins/intel_gna/src/gna_device.hpp b/src/plugins/intel_gna/src/gna_device.hpp index c99dc733208..7deb3c945b1 100644 --- a/src/plugins/intel_gna/src/gna_device.hpp +++ b/src/plugins/intel_gna/src/gna_device.hpp @@ -41,7 +41,7 @@ class GNADeviceHelper : public GNADevice { static std::string gnaLibraryVersion{", GNA library version: " + GNADeviceHelper::GetGnaLibraryVersion()}; return gnaLibraryVersion; } - std::shared_ptr target; + std::shared_ptr target; std::string modeOfOperation = "default"; GnaAllocations allAllocations; uint32_t nGnaDeviceIndex = 0; @@ -69,7 +69,7 @@ class GNADeviceHelper : public GNADevice { static constexpr const char* kDumpDelimiter = "."; public: - explicit GNADeviceHelper(std::shared_ptr target = std::make_shared(), + explicit GNADeviceHelper(std::shared_ptr target = std::make_shared(), bool isPerformanceMeasuring = false, bool deviceEmbedded = false); @@ -92,8 +92,8 @@ public: void releaseModel(const uint32_t model_id); static uint32_t getNumberOfGnaDevices(); static uint32_t selectGnaDevice(); - static bool is_hw_target(const common::DeviceVersion device_version) { - return common::DeviceVersion::SoftwareEmulation != device_version; + static bool is_hw_target(const target::DeviceVersion device_version) { + return target::DeviceVersion::SoftwareEmulation != device_version; } bool is_hw_detected() const { return is_hw_target(target->get_detected_device_version()); @@ -170,10 +170,10 @@ private: static void enforceLegacyCnns(Gna2Model& gnaModel); static void enforceLegacyCnnsWhenNeeded(Gna2Model& gnaModel); - static bool is_up_to_20_hw(const common::DeviceVersion device_version) { - return device_version <= common::DeviceVersion::GNA2_0 && is_hw_target(device_version); + static bool is_up_to_20_hw(const target::DeviceVersion device_version) { + return device_version <= target::DeviceVersion::GNA2_0 && is_hw_target(device_version); } - void createVirtualDevice(const common::DeviceVersion& devVersion); + void createVirtualDevice(const target::DeviceVersion& devVersion); void updateGnaDeviceVersion(); void initGnaPerfCounters() { diff --git a/src/plugins/intel_gna/src/gna_graph_compiler.cpp b/src/plugins/intel_gna/src/gna_graph_compiler.cpp index 32b2e6be8be..293d1988b2b 100644 --- a/src/plugins/intel_gna/src/gna_graph_compiler.cpp +++ b/src/plugins/intel_gna/src/gna_graph_compiler.cpp @@ -221,7 +221,7 @@ void GNAGraphCompiler::fillSplitConnections(InferenceEngine::CNNLayerPtr layer) split_connection.emplace(id, layerInfoItem); } -void GNAGraphCompiler::SetValidatorTarget(const DeviceVersion& target) { +void GNAGraphCompiler::SetValidatorTarget(const target::DeviceVersion& target) { auto temp = limitations::cnn2d::AbstractValidator::Create(target); cnn2dValidator.reset(temp.release()); } diff --git a/src/plugins/intel_gna/src/gna_graph_compiler.hpp b/src/plugins/intel_gna/src/gna_graph_compiler.hpp index f58c4ff8031..6f6f78962bf 100644 --- a/src/plugins/intel_gna/src/gna_graph_compiler.hpp +++ b/src/plugins/intel_gna/src/gna_graph_compiler.hpp @@ -93,7 +93,7 @@ public: const uint32_t strideH, const uint32_t strideW) const; - void SetValidatorTarget(const common::DeviceVersion& target); + void SetValidatorTarget(const target::DeviceVersion& target); /** * Connects either memory output, or generic output to a layer diff --git a/src/plugins/intel_gna/src/gna_plugin.cpp b/src/plugins/intel_gna/src/gna_plugin.cpp index 4141f677109..f1d2dc3013a 100644 --- a/src/plugins/intel_gna/src/gna_plugin.cpp +++ b/src/plugins/intel_gna/src/gna_plugin.cpp @@ -661,7 +661,7 @@ void GNAPlugin::LoadNetwork(const CNNNetwork& _network) { const auto effectiveCompileTarget = config.target->get_effective_compile_target(); graphCompiler.SetValidatorTarget(effectiveCompileTarget); - auto transformer = TransformationsPipeline(config, effectiveCompileTarget); + auto transformer = TransformationsPipeline(config); if (_network.getFunction()) { CNNNetwork clonedNetwork = InferenceEngine::cloneNetwork(_network); @@ -1039,7 +1039,7 @@ void GNAPlugin::DumpXNNToFile() const { const auto& inputsDesc = inputs_ptr_->Get(); const auto& outputsDesc = outputs_.Get(); - if (config.target->get_effective_compile_target() == common::DeviceVersion::GNAEmbedded1_0) { + if (config.target->get_effective_compile_target() == target::DeviceVersion::GNA1_0) { auto dump = gnadevice->dumpXnn(modelId); dump.header.RwRegionSize = gnamem->getRegionBytes(REGION_SCRATCH); dump.header.InputScalingFactor = inputsDesc.begin()->scale_factor; @@ -1631,7 +1631,7 @@ InferenceEngine::QueryNetworkResult GNAPlugin::QueryNetwork( auto supported = GetSupportedNodes( model, [&](std::shared_ptr& model) { - TransformationsPipeline(qn_config, effectiveCompileTarget).apply(model); + TransformationsPipeline(qn_config).apply(model); }, [&](const std::shared_ptr& op) { return limitations::is_op_supported(op, effectiveCompileTarget, qn_config.gnaPrecision); diff --git a/src/plugins/intel_gna/src/gna_plugin_config.cpp b/src/plugins/intel_gna/src/gna_plugin_config.cpp index 223947ac08f..0d48a7c313f 100644 --- a/src/plugins/intel_gna/src/gna_plugin_config.cpp +++ b/src/plugins/intel_gna/src/gna_plugin_config.cpp @@ -24,7 +24,7 @@ using namespace InferenceEngine::details; namespace ov { namespace intel_gna { -using namespace common; +using namespace target; const uint8_t Config::max_num_requests; @@ -52,7 +52,7 @@ void Config::UpdateFromMap(const std::map& config) { auto value = item.second; auto check_scale_factor = [&](float scale_factor) { - if (AreFpEq(scale_factor, 0.0f) || std::isinf(scale_factor)) { + if (common::AreFpEq(scale_factor, 0.0f) || std::isinf(scale_factor)) { THROW_GNA_EXCEPTION << "input scale factor of 0.0f or +-inf not supported"; } }; @@ -127,8 +127,6 @@ void Config::UpdateFromMap(const std::map& config) { } else if (key == GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE) || key == ov::intel_gna::firmware_model_image_path) { embedded_export_path = value; OPENVINO_SUPPRESS_DEPRECATED_START - } else if (key == GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE_GENERATION)) { - dumpXNNGeneration = value; } else if (key == GNA_CONFIG_KEY(DEVICE_MODE) || key == ov::intel_gna::execution_mode) { auto procType = supported_values.find(value); if (procType == supported_values.end()) { @@ -290,9 +288,6 @@ void Config::AdjustKeyMapValues() { } } keyConfigMap[ov::intel_gna::firmware_model_image_path.name()] = embedded_export_path; - IE_SUPPRESS_DEPRECATED_START - keyConfigMap[GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE_GENERATION)] = dumpXNNGeneration; - IE_SUPPRESS_DEPRECATED_END std::string device_mode; if (gnaFlags.sw_fp32) { device_mode = ov::util::to_string(ov::intel_gna::ExecutionMode::SW_FP32); diff --git a/src/plugins/intel_gna/src/gna_plugin_config.hpp b/src/plugins/intel_gna/src/gna_plugin_config.hpp index e3afb02be8f..e1e538b6eb5 100644 --- a/src/plugins/intel_gna/src/gna_plugin_config.hpp +++ b/src/plugins/intel_gna/src/gna_plugin_config.hpp @@ -36,8 +36,7 @@ struct Config { inference_precision = r.inference_precision; gnaPrecision = r.gnaPrecision; embedded_export_path = r.embedded_export_path; - dumpXNNGeneration = r.dumpXNNGeneration; - target = std::make_shared(); + target = std::make_shared(); if (r.target) { *target = *r.target; } @@ -63,9 +62,8 @@ struct Config { InferenceEngine::Precision gnaPrecision = InferenceEngine::Precision::I16; std::string embedded_export_path; - std::string dumpXNNGeneration; - std::shared_ptr target = std::make_shared(); + std::shared_ptr target = std::make_shared(); Gna2AccelerationMode pluginGna2AccMode = Gna2AccelerationModeSoftware; bool swExactMode = true; diff --git a/src/plugins/intel_gna/src/gna_transformations_pipeline.hpp b/src/plugins/intel_gna/src/gna_transformations_pipeline.hpp index 14c937b27b1..ecf6462397d 100644 --- a/src/plugins/intel_gna/src/gna_transformations_pipeline.hpp +++ b/src/plugins/intel_gna/src/gna_transformations_pipeline.hpp @@ -15,11 +15,9 @@ namespace intel_gna { class TransformationsPipeline { public: - explicit TransformationsPipeline(const Config& config, - const ov::intel_gna::common::DeviceVersion& effective_compile_target = - ov::intel_gna::common::DeviceVersion::NotSet) - : config(config), - effective_compile_target(effective_compile_target) {} + explicit TransformationsPipeline(const Config& config) : config(config) { + effective_compile_target = config.target->get_effective_compile_target(); + } void apply(const std::shared_ptr& model); IE_SUPPRESS_DEPRECATED_START void apply_legacy(const InferenceEngine::CNNNetwork& network, bool runBeforeCopy); @@ -34,7 +32,7 @@ private: bool is_ngraph_passes_used = false; bool fake_quantized = false; int legacy_pass_index = 0; - ov::intel_gna::common::DeviceVersion effective_compile_target; + ov::intel_gna::target::DeviceVersion effective_compile_target; }; } // namespace intel_gna 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 c8322586d10..a4be3baa726 100644 --- a/src/plugins/intel_gna/src/transformations/decompose_2d_convolution.cpp +++ b/src/plugins/intel_gna/src/transformations/decompose_2d_convolution.cpp @@ -19,7 +19,7 @@ namespace ov { namespace intel_gna { -using namespace common; +using namespace target; namespace pass { using namespace helper; diff --git a/src/plugins/intel_gna/src/transformations/decompose_2d_convolution.hpp b/src/plugins/intel_gna/src/transformations/decompose_2d_convolution.hpp index 1c9ab4cc949..78d14f73630 100644 --- a/src/plugins/intel_gna/src/transformations/decompose_2d_convolution.hpp +++ b/src/plugins/intel_gna/src/transformations/decompose_2d_convolution.hpp @@ -35,7 +35,7 @@ namespace pass { class Decompose2DConv : public ngraph::pass::MatcherPass { public: OPENVINO_RTTI("Decompose2DConv", "0"); - Decompose2DConv(const common::DeviceVersion& compile_target, const InferenceEngine::Precision& gnaPrecision); + Decompose2DConv(const target::DeviceVersion& compile_target, const InferenceEngine::Precision& gnaPrecision); }; /** @@ -56,7 +56,7 @@ public: class Decompose2DConvTransposedWithBias : public ngraph::pass::MatcherPass { public: OPENVINO_RTTI("Decompose2DConvTransposedWithBias", "0"); - Decompose2DConvTransposedWithBias(const common::DeviceVersion& compile_target, + Decompose2DConvTransposedWithBias(const target::DeviceVersion& compile_target, const InferenceEngine::Precision& gnaPrecision); }; @@ -80,7 +80,7 @@ public: class Decompose2DConvTransposedWithBiasAF : public ngraph::pass::MatcherPass { public: OPENVINO_RTTI("Decompose2DConvTransposedWithBiasAF", "0"); - Decompose2DConvTransposedWithBiasAF(const common::DeviceVersion& compile_target, + Decompose2DConvTransposedWithBiasAF(const target::DeviceVersion& compile_target, const InferenceEngine::Precision& gnaPrecision); }; 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 0e9c672a8fc..37a3d7e1e70 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 @@ -11,7 +11,7 @@ #include "common/gna_target.hpp" using namespace ov::intel_gna::limitations; -using namespace ov::intel_gna::common; +using namespace ov::intel_gna::target; struct GNACnn2DValidatorTestParam { DeviceVersion target; 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 5a3648c1801..06ef1278ef2 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 @@ -12,14 +12,13 @@ using namespace InferenceEngine; using namespace ov::intel_gna; -using namespace ov::intel_gna::common; +using namespace ov::intel_gna::target; IE_SUPPRESS_DEPRECATED_START const std::map supportedConfigKeysWithDefaults = { {GNA_CONFIG_KEY(SCALE_FACTOR), "1.000000"}, {GNA_CONFIG_KEY(SCALE_FACTOR) + std::string("_0"), "1.000000"}, {GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE), ""}, - {GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE_GENERATION), ""}, {GNA_CONFIG_KEY(EXEC_TARGET), ""}, {GNA_CONFIG_KEY(COMPILE_TARGET), ""}, {GNA_CONFIG_KEY(DEVICE_MODE), GNAConfigParams::GNA_SW_EXACT}, @@ -182,15 +181,25 @@ TEST_F(GNAPluginConfigTest, GnaConfigSingleThreadTest) { IE_SUPPRESS_DEPRECATED_END TEST_F(GNAPluginConfigTest, GnaConfigGnaExecTargetTest) { + SetAndCompare(GNA_CONFIG_KEY(EXEC_TARGET), "GNA_TARGET_1_0"); + EXPECT_EQ(config.target->get_user_set_execution_target(), DeviceVersion::GNA1_0); SetAndCompare(GNA_CONFIG_KEY(EXEC_TARGET), "GNA_TARGET_2_0"); EXPECT_EQ(config.target->get_user_set_execution_target(), DeviceVersion::GNA2_0); SetAndCompare(GNA_CONFIG_KEY(EXEC_TARGET), "GNA_TARGET_3_0"); EXPECT_EQ(config.target->get_user_set_execution_target(), DeviceVersion::GNA3_0); + SetAndCompare(GNA_CONFIG_KEY(EXEC_TARGET), "GNA_TARGET_3_1"); + EXPECT_EQ(config.target->get_user_set_execution_target(), DeviceVersion::GNA3_1); ExpectThrow(GNA_CONFIG_KEY(EXEC_TARGET), "GNA_TARGET_3_7"); SetAndCompare(GNA_CONFIG_KEY(EXEC_TARGET), "GNA_TARGET_3_5"); EXPECT_EQ(config.target->get_user_set_execution_target(), DeviceVersion::GNA3_5); + SetAndCompare(GNA_CONFIG_KEY(EXEC_TARGET), "GNA_TARGET_3_5_E"); + EXPECT_EQ(config.target->get_user_set_execution_target(), DeviceVersion::GNAEmbedded3_5); + SetAndCompare(GNA_CONFIG_KEY(EXEC_TARGET), "GNA_TARGET_3_6"); + EXPECT_EQ(config.target->get_user_set_execution_target(), DeviceVersion::GNA3_6); + SetAndCompare(GNA_CONFIG_KEY(EXEC_TARGET), "GNA_TARGET_4_0"); + EXPECT_EQ(config.target->get_user_set_execution_target(), DeviceVersion::GNA4_0); ExpectThrow(GNA_CONFIG_KEY(EXEC_TARGET), "0"); ExpectThrow(GNA_CONFIG_KEY(EXEC_TARGET), "GNA_TARGET_1_5"); 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 616c44d2031..26d9ec4f575 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 @@ -884,17 +884,17 @@ void execute_test(modelType model, case modelType::TranspConvBcastAddMaxPoolTransp: case modelType::TranspConvBcastAddActTransp: case modelType::TranspConvBcastAddMaxPoolActTransp: - manager.register_pass(ov::intel_gna::common::DeviceVersion::Default, + manager.register_pass(ov::intel_gna::target::DeviceVersion::Default, gnaPrecision); break; case modelType::TranspConvTranspBcastAdd: manager.register_pass( - ov::intel_gna::common::DeviceVersion::Default, + ov::intel_gna::target::DeviceVersion::Default, gnaPrecision); break; case modelType::TranspConvTranspBcastAddAct: manager.register_pass( - ov::intel_gna::common::DeviceVersion::Default, + ov::intel_gna::target::DeviceVersion::Default, gnaPrecision); break; }