Skip to content

Commit

Permalink
[GNA] Safety fixes (openvinotoolkit#2158)
Browse files Browse the repository at this point in the history
  • Loading branch information
dorloff authored Sep 15, 2020
1 parent e4f0d80 commit eea5aca
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions inference-engine/src/gna_plugin/gna_graph_compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(INT16_MAX)));
auto quantizedOffset = FLOAT_TO_INT32(std::min(quantized->_dst_quant.scale * power.offset,
Expand Down
2 changes: 1 addition & 1 deletion inference-engine/src/gna_plugin/gna_plugin.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class GNAPlugin : public InferenceEngine::IInferencePlugin {
protected:
std::string _pluginName = "GNA";

Config config;
Config config {};
std::shared_ptr<GNAPluginNS::backend::AMIntelDNN> dnn;
std::shared_ptr<GNAPluginNS::GNAFlags> gnaFlags;
std::shared_ptr<GNAPluginNS::gna_memory_type> gnamem;
Expand Down
4 changes: 2 additions & 2 deletions inference-engine/src/gna_plugin/gna_slope_scale.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
#include <cstdint>

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);
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down Expand Up @@ -1119,6 +1122,7 @@ void EltwiseSplitOverChannelsPass::run() {
for (size_t k = 0; k != totalSplits; k++) {
auto eltwiseRaw = std::make_shared<EltwiseLayer>(
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<QuantizedLayerParams>(eltwiseRaw) : eltwiseRaw;
Expand Down

0 comments on commit eea5aca

Please sign in to comment.