From 6c92ce48c1e5e3c73c5ffb88fcfa7ea11f0c367f Mon Sep 17 00:00:00 2001 From: Krzysztof Bruniecki Date: Tue, 21 Dec 2021 07:44:06 +0100 Subject: [PATCH] Remove non official code (#9315) - feature to export for embedded GNA3 which is not in fact supported. - SW emulation modes like SSE etc, which are not useful and are undocumented. --- samples/cpp/speech_sample/main.cpp | 4 -- samples/cpp/speech_sample/speech_sample.hpp | 45 +++++++++---------- src/inference/include/ie/gna/gna_config.hpp | 13 ------ src/plugins/intel_gna/gna_device.cpp | 22 --------- src/plugins/intel_gna/gna_device.hpp | 3 -- src/plugins/intel_gna/gna_plugin.cpp | 32 ++++--------- src/plugins/intel_gna/gna_plugin_config.cpp | 19 -------- src/tests/unit/gna/gna_plugin_config_test.cpp | 6 --- 8 files changed, 30 insertions(+), 114 deletions(-) diff --git a/samples/cpp/speech_sample/main.cpp b/samples/cpp/speech_sample/main.cpp index 0db982f5676..b035c724d56 100644 --- a/samples/cpp/speech_sample/main.cpp +++ b/samples/cpp/speech_sample/main.cpp @@ -177,7 +177,6 @@ int main(int argc, char* argv[]) { // Embedded GNA model dumping (for Intel(R) Speech Enabling Developer Kit) if (!FLAGS_we.empty()) { gnaPluginConfig[InferenceEngine::GNAConfigParams::KEY_GNA_FIRMWARE_MODEL_IMAGE] = FLAGS_we; - gnaPluginConfig[InferenceEngine::GNAConfigParams::KEY_GNA_FIRMWARE_MODEL_IMAGE_GENERATION] = FLAGS_we_gen; } // ----------------------------------------------------------------------------------------------------- // --------------------------- Step 2. Loading model to the device ------------------------------------------ @@ -232,9 +231,6 @@ int main(int argc, char* argv[]) { } if (!FLAGS_we.empty()) { slog::info << "Exported GNA embedded model to file " << FLAGS_we << slog::endl; - if (!FLAGS_we_gen.empty()) { - slog::info << "GNA embedded model export done for GNA generation: " << FLAGS_we_gen << slog::endl; - } return 0; } // --------------------------------------------------------------------------------------------------------- diff --git a/samples/cpp/speech_sample/speech_sample.hpp b/samples/cpp/speech_sample/speech_sample.hpp index e93d6efd817..7d53fcd07af 100644 --- a/samples/cpp/speech_sample/speech_sample.hpp +++ b/samples/cpp/speech_sample/speech_sample.hpp @@ -162,9 +162,6 @@ DEFINE_string(wg, "", write_gna_model_message); /// @brief Write GNA embedded model to file (model.bin) DEFINE_string(we, "", write_embedded_model_message); -/// @brief Optional GNA embedded device generation (default GNA1 aka Sue Creek) - hide option -DEFINE_string(we_gen, "GNA1", write_embedded_model_generation_message); - /// @brief Input quantization mode (default static) DEFINE_string(q, "static", quantization_message); @@ -203,26 +200,28 @@ static void showUsage() { std::cout << "speech_sample [OPTION]" << std::endl; std::cout << "Options:" << std::endl; std::cout << std::endl; - std::cout << " -h " << help_message << std::endl; - std::cout << " -i \"\" " << input_message << std::endl; - std::cout << " -m \"\" " << model_message << std::endl; - std::cout << " -o \"\" " << output_message << std::endl; - std::cout << " -d \"\" " << target_device_message << std::endl; - std::cout << " -pc " << performance_counter_message << std::endl; - std::cout << " -q \"\" " << quantization_message << std::endl; - std::cout << " -qb \"\" " << quantization_bits_message << std::endl; - std::cout << " -sf \"\" " << scale_factor_message << std::endl; - std::cout << " -bs \"\" " << batch_size_message << std::endl; - std::cout << " -r \"\" " << reference_score_message << std::endl; - std::cout << " -rg \"\" " << read_gna_model_message << std::endl; - std::cout << " -wg \"\" " << write_gna_model_message << std::endl; - std::cout << " -we \"\" " << write_embedded_model_message << std::endl; - std::cout << " -nthreads \"\" " << infer_num_threads_message << std::endl; - std::cout << " -cw_l \"\" " << context_window_message_l << std::endl; - std::cout << " -cw_r \"\" " << context_window_message_r << std::endl; - std::cout << " -oname \"\" " << output_layer_names_message << std::endl; - std::cout << " -iname \"\" " << input_layer_names_message << std::endl; - std::cout << " -pwl_me \"\" " << pwl_max_error_percent_message << std::endl; + std::cout << " -h " << help_message << std::endl; + std::cout << " -i \"\" " << input_message << std::endl; + std::cout << " -m \"\" " << model_message << std::endl; + std::cout << " -o \"\" " << output_message << std::endl; + std::cout << " -d \"\" " << target_device_message << std::endl; + std::cout << " -pc " << performance_counter_message << std::endl; + std::cout << " -q \"\" " << quantization_message << std::endl; + std::cout << " -qb \"\" " << quantization_bits_message << std::endl; + std::cout << " -sf \"\" " << scale_factor_message << std::endl; + std::cout << " -bs \"\" " << batch_size_message << std::endl; + std::cout << " -r \"\" " << reference_score_message << std::endl; + std::cout << " -rg \"\" " << read_gna_model_message << std::endl; + std::cout << " -wg \"\" " << write_gna_model_message << std::endl; + std::cout << " -we \"\" " << write_embedded_model_message << std::endl; + std::cout << " -nthreads \"\" " << infer_num_threads_message << std::endl; + std::cout << " -cw_l \"\" " << context_window_message_l << std::endl; + std::cout << " -cw_r \"\" " << context_window_message_r << std::endl; + std::cout << " -oname \"\" " << output_layer_names_message << std::endl; + std::cout << " -iname \"\" " << input_layer_names_message << std::endl; + std::cout << " -pwl_me \"\" " << pwl_max_error_percent_message << std::endl; + std::cout << " -exec_target \"\" " << execution_target_message << std::endl; + std::cout << " -compile_target \"\" " << compile_target_message << std::endl; } /** diff --git a/src/inference/include/ie/gna/gna_config.hpp b/src/inference/include/ie/gna/gna_config.hpp index ab281b07591..963a0413271 100644 --- a/src/inference/include/ie/gna/gna_config.hpp +++ b/src/inference/include/ie/gna/gna_config.hpp @@ -53,11 +53,6 @@ DECLARE_GNA_CONFIG_KEY(PRECISION); */ DECLARE_GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE); -/** - * @brief information on GNA generation chosen for firmware model dump, can be overridden by GNA3 - */ -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, GNA_SW_EXACT */ @@ -69,14 +64,6 @@ DECLARE_GNA_CONFIG_VALUE(HW_WITH_SW_FBACK); DECLARE_GNA_CONFIG_VALUE(SW); DECLARE_GNA_CONFIG_VALUE(SW_EXACT); DECLARE_GNA_CONFIG_VALUE(SW_FP32); -DECLARE_GNA_CONFIG_VALUE(GEN); -DECLARE_GNA_CONFIG_VALUE(GEN_EXACT); -DECLARE_GNA_CONFIG_VALUE(SSE); -DECLARE_GNA_CONFIG_VALUE(SSE_EXACT); -DECLARE_GNA_CONFIG_VALUE(AVX1); -DECLARE_GNA_CONFIG_VALUE(AVX1_EXACT); -DECLARE_GNA_CONFIG_VALUE(AVX2); -DECLARE_GNA_CONFIG_VALUE(AVX2_EXACT); /** * @brief The option to override the GNA HW execution target. May be one of GNA_TARGET_2_0, GNA_TARGET_3_0. diff --git a/src/plugins/intel_gna/gna_device.cpp b/src/plugins/intel_gna/gna_device.cpp index 023799790da..67a731849c3 100644 --- a/src/plugins/intel_gna/gna_device.cpp +++ b/src/plugins/intel_gna/gna_device.cpp @@ -473,28 +473,6 @@ GNADeviceHelper::DumpResult GNADeviceHelper::dumpXnn(const uint32_t modelId) { #if GNA_LIB_VER == 2 -void GNADeviceHelper::dumpXnnForDeviceVersion( - const uint32_t modelId, - std::ostream & outStream, - const Gna2DeviceVersion targetDeviceVersion) { - - Gna2ModelSueCreekHeader sueHeader; - auto ptr = ExportSueLegacyUsingGnaApi2(modelId, nGnaDeviceIndex, &sueHeader); - gnaUserFree(ptr); - - ExportGnaDescriptorPartiallyFilled(sueHeader.NumberOfLayers, outStream); - - ExportLdForDeviceVersion(modelId, outStream, targetDeviceVersion); - if (dumpXNNROPtr == nullptr) { - THROW_GNA_EXCEPTION << "Bad RO pointer (nullptr)"; - } - outStream.write(static_cast(dumpXNNROPtr), dumpXNNROSize); - - // TODO: GNA2: remove - outStream.write("Gna2ModelSueCreekHeader", 24); - outStream.write(reinterpret_cast(&sueHeader), sizeof(sueHeader)); -} - void GNADeviceHelper::createVirtualDevice(Gna2DeviceVersion devVersion, std::string purpose) { const auto status = Gna2DeviceCreateForExport(devVersion, &nGnaDeviceIndex); GNADeviceHelper::checkGna2Status(status, "Gna2DeviceCreateForExport(" + std::to_string(devVersion) + ")" + purpose); diff --git a/src/plugins/intel_gna/gna_device.hpp b/src/plugins/intel_gna/gna_device.hpp index 4024b3c1807..2955a084eba 100644 --- a/src/plugins/intel_gna/gna_device.hpp +++ b/src/plugins/intel_gna/gna_device.hpp @@ -176,9 +176,6 @@ public: #else DumpResult dumpXnn(const uint32_t modelId); - void dumpXnnForDeviceVersion(const uint32_t modelId, - std::ostream & outStream, - Gna2DeviceVersion targetDeviceVersion); #endif void free(void * ptr); diff --git a/src/plugins/intel_gna/gna_plugin.cpp b/src/plugins/intel_gna/gna_plugin.cpp index f406cdce23a..6fae93ffac7 100644 --- a/src/plugins/intel_gna/gna_plugin.cpp +++ b/src/plugins/intel_gna/gna_plugin.cpp @@ -1164,17 +1164,8 @@ void GNAPlugin::createRequestConfigsForGnaModels() { #endif int GNAPlugin::GetDeviceVersionFromString(const std::string deviceString) { - constexpr uint32_t embeddedSuffix = 0xE; if (deviceString.empty()) - return 0x100 + embeddedSuffix; - if (deviceString.size() == 4 && deviceString.substr(0, 3) == "GNA") { - int version = deviceString[3] - '0'; - if (version > 0) { - version <<= 8; - version += embeddedSuffix; - return version; - } - } + return static_cast(Gna2DeviceVersionEmbedded1_0); THROW_GNA_EXCEPTION << "Wrong GNA generation for embedded model dump: " << deviceString; } @@ -1185,8 +1176,6 @@ void GNAPlugin::DumpXNNToFile() const { return; } - const auto versionInt = GetDeviceVersionFromString(config.dumpXNNGeneration); - if (!gnadevice) { THROW_GNA_EXCEPTION << "Cannot generate XNNDump for float network"; } @@ -1202,18 +1191,13 @@ void GNAPlugin::DumpXNNToFile() const { dumpStream.write(reinterpret_cast(dump.model.get()), dump.header.model_size); #else auto const modelId = gnadevice->createModel(std::get<0>(gnaModels.front())->obj); - if (versionInt == Gna2DeviceVersionEmbedded1_0) { - auto dump = gnadevice->dumpXnn(modelId); - dump.header.RwRegionSize = gnamem->getRWBytes(); - dump.header.InputScalingFactor = inputsDesc->inputScaleFactors.front(); - dump.header.OutputScalingFactor = outputsDesc.front().scale_factor; - dumpStream.write(reinterpret_cast(&dump.header), sizeof(Gna2ModelSueCreekHeader)); - dumpStream.write(reinterpret_cast(dump.model.get()), dump.header.ModelSize); - } else { - static_assert(sizeof(versionInt) >= sizeof(Gna2DeviceVersion), ""); - gnadevice->dumpXnnForDeviceVersion(modelId, dumpStream, - *reinterpret_cast(&versionInt)); - } + auto dump = gnadevice->dumpXnn(modelId); + dump.header.RwRegionSize = gnamem->getRWBytes(); + dump.header.InputScalingFactor = inputsDesc->inputScaleFactors.front(); + dump.header.OutputScalingFactor = outputsDesc.front().scale_factor; + dumpStream.write(reinterpret_cast(&dump.header), sizeof(Gna2ModelSueCreekHeader)); + dumpStream.write(reinterpret_cast(dump.model.get()), dump.header.ModelSize); + gnadevice->releaseModel(modelId); #endif } diff --git a/src/plugins/intel_gna/gna_plugin_config.cpp b/src/plugins/intel_gna/gna_plugin_config.cpp index 3495eb1d935..4f2fca2089a 100644 --- a/src/plugins/intel_gna/gna_plugin_config.cpp +++ b/src/plugins/intel_gna/gna_plugin_config.cpp @@ -24,14 +24,6 @@ static const caseless_unordered_map supported_values = { }; static const std::vector supported_values_on_gna2 = { GNAConfigParams::GNA_HW_WITH_SW_FBACK, - GNAConfigParams::GNA_GEN, - GNAConfigParams::GNA_GEN_EXACT, - GNAConfigParams::GNA_SSE, - GNAConfigParams::GNA_SSE_EXACT, - GNAConfigParams::GNA_AVX1, - GNAConfigParams::GNA_AVX1_EXACT, - GNAConfigParams::GNA_AVX2, - GNAConfigParams::GNA_AVX2_EXACT }; #else static const caseless_unordered_map > supported_values = { @@ -40,14 +32,6 @@ static const caseless_unordered_map & config) { inputScaleFactors[input_index] = InferenceEngine::CNNLayer::ie_parse_float(value); } else if (key == GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE)) { dumpXNNPath = value; - } else if (key == GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE_GENERATION)) { - dumpXNNGeneration = value; } else if (key == GNA_CONFIG_KEY(DEVICE_MODE)) { auto procType = supported_values.find(value); if (procType == supported_values.end()) { @@ -267,7 +249,6 @@ void Config::AdjustKeyMapValues() { std::to_string(inputScaleFactors[n]); } keyConfigMap[GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE)] = dumpXNNPath; - keyConfigMap[GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE_GENERATION)] = dumpXNNGeneration; std::string device_mode; if (gnaFlags.sw_fp32) { diff --git a/src/tests/unit/gna/gna_plugin_config_test.cpp b/src/tests/unit/gna/gna_plugin_config_test.cpp index 1b061c8bf1f..6d0a7c23413 100644 --- a/src/tests/unit/gna/gna_plugin_config_test.cpp +++ b/src/tests/unit/gna/gna_plugin_config_test.cpp @@ -15,7 +15,6 @@ 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}, @@ -96,11 +95,6 @@ TEST_F(GNAPluginConfigTest, GnaConfigFirmwareModelImageTest) { EXPECT_EQ(config.dumpXNNPath, "abc"); } -TEST_F(GNAPluginConfigTest, GnaConfigFirmwareModelImageGeneratorTest) { - SetAndCompare(GNA_CONFIG_KEY(FIRMWARE_MODEL_IMAGE_GENERATION), "def"); - EXPECT_EQ(config.dumpXNNGeneration, "def"); -} - TEST_F(GNAPluginConfigTest, GnaConfigDeviceModeTest) { SetAndCompare(GNA_CONFIG_KEY(DEVICE_MODE), GNAConfigParams::GNA_HW); #if GNA_LIB_VER == 1