From eea5acaacc994bfed4efa23426817e6c1c50919b Mon Sep 17 00:00:00 2001 From: Denis Orlov Date: Tue, 15 Sep 2020 11:24:17 +0300 Subject: [PATCH] [GNA] Safety fixes (#2158) --- inference-engine/src/gna_plugin/gna_graph_compiler.cpp | 2 ++ inference-engine/src/gna_plugin/gna_plugin.hpp | 2 +- inference-engine/src/gna_plugin/gna_slope_scale.h | 4 ++-- .../src/gna_plugin/optimizer/gna_pass_manager.cpp | 4 ++++ 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/inference-engine/src/gna_plugin/gna_graph_compiler.cpp b/inference-engine/src/gna_plugin/gna_graph_compiler.cpp index 3c463b51580..84e0c7095e7 100644 --- a/inference-engine/src/gna_plugin/gna_graph_compiler.cpp +++ b/inference-engine/src/gna_plugin/gna_graph_compiler.cpp @@ -542,9 +542,11 @@ void GNAGraphCompiler::PowerPrimitive(InferenceEngine::CNNLayerPtr layer) { connectInput(layer, ptr_inputs, num_data_bytes_in, 0, 0); if (gnaFlags->sw_fp32) { + IE_ASSERT(quantized == nullptr); gnamem->readonly().push_value(ptr_weights, power.scale, num_rows_out, 64); gnamem->readonly().push_value(ptr_biases, power.offset, num_rows_out, 64); } else { + IE_ASSERT(quantized != nullptr); auto quantizedScale = FLOAT_TO_INT16(std::min(quantized->_weights_quant.scale * power.scale, static_cast(INT16_MAX))); auto quantizedOffset = FLOAT_TO_INT32(std::min(quantized->_dst_quant.scale * power.offset, diff --git a/inference-engine/src/gna_plugin/gna_plugin.hpp b/inference-engine/src/gna_plugin/gna_plugin.hpp index 839d9abb388..54bf674d694 100644 --- a/inference-engine/src/gna_plugin/gna_plugin.hpp +++ b/inference-engine/src/gna_plugin/gna_plugin.hpp @@ -33,7 +33,7 @@ class GNAPlugin : public InferenceEngine::IInferencePlugin { protected: std::string _pluginName = "GNA"; - Config config; + Config config {}; std::shared_ptr dnn; std::shared_ptr gnaFlags; std::shared_ptr gnamem; diff --git a/inference-engine/src/gna_plugin/gna_slope_scale.h b/inference-engine/src/gna_plugin/gna_slope_scale.h index a4b9f0eef7d..967bdeb393d 100644 --- a/inference-engine/src/gna_plugin/gna_slope_scale.h +++ b/inference-engine/src/gna_plugin/gna_slope_scale.h @@ -7,9 +7,9 @@ #include typedef struct { - double slope; + double slope {}; uint64_t slope_scale = 0; - uint32_t slope_scale_index; + uint32_t slope_scale_index {}; } pwl_gna_slope_scale_t; pwl_gna_slope_scale_t gna_slope(const double slope, const double in_scale, const double out_scale); diff --git a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp index 4cd259de84f..ff55abc2c29 100644 --- a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp +++ b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp @@ -294,6 +294,9 @@ void SubstituteSoftSignPass::run() { }; auto getNthChild = [](CNNLayerPtr l, int N) { auto first = getInputTo(l->outData.front()).begin(); + auto last = getInputTo(l->outData.front()).end(); + IE_ASSERT(first != last); + IE_ASSERT(N <= std::distance(first, last)); std::advance(first, N); return first->second; }; @@ -1119,6 +1122,7 @@ void EltwiseSplitOverChannelsPass::run() { for (size_t k = 0; k != totalSplits; k++) { auto eltwiseRaw = std::make_shared( LayerParams{l->name + "/eltwise/" + std::to_string(k), "Eltwise", Precision::FP32}); + IE_ASSERT(eltwiseRaw != nullptr); eltwiseRaw->_operation = masterEltwise->_operation; eltwiseRaw->coeff = masterEltwise->coeff; auto eltwise = quantized ? InferenceEngine::injectData(eltwiseRaw) : eltwiseRaw;