Skip to content

Commit

Permalink
[GNA] Added ConcatAlignFilter support for Accuracy Aware mode (openvi…
Browse files Browse the repository at this point in the history
…notoolkit#7834)

* Added ConcatAlignFilter support for Accuracy Aware mode

* fails after reviewing and added tests

* moved the test to gna/scale_factors_tests; added comments to test
  • Loading branch information
dmitriikhurtin authored and dood-apo committed Aug 24, 2023
1 parent bc2f7c5 commit 8c106fd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
15 changes: 11 additions & 4 deletions inference-engine/src/gna_plugin/frontend/layer_quantizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,11 +653,18 @@ class DataQuantizer<Desc, InferenceEngine::WeightableLayer *> : public DataQuant

void operator()(InferenceEngine::WeightableLayer *wl, const FakeQuant&) const {
auto quantData = InferenceEngine::getInjectedData<QuantizedLayerParams>(*wl);
IE_ASSERT(quantData->_weights_quant.IsStatsSet());
if (quantData->_weights_quant.GetLevels() <= std::numeric_limits<uint8_t>::max()) {
quantizeWeightsBiases<FakeQuantI8>(FakeQuantI8(), wl, Quant<FakeQuantI8>());
if (quantData->_weights_quant.IsStatsSet()) {
if (quantData->_weights_quant.GetLevels() <= std::numeric_limits<uint8_t>::max()) {
quantizeWeightsBiases<FakeQuantI8>(FakeQuantI8(), wl, Quant<FakeQuantI8>());
} else {
quantizeWeightsBiases<FakeQuantI16>(FakeQuantI16(), wl, Quant<FakeQuantI16>());
}
} else {
quantizeWeightsBiases<FakeQuantI16>(FakeQuantI16(), wl, Quant<FakeQuantI16>());
if (std::is_same<typename Desc::OptionalType, FakeQuant>()) {
THROW_GNA_EXCEPTION << "Infinite recursion. The type Desc::OptionalType is equal FakeQuant.";
}

(*this)(wl, typename Desc::OptionalType());
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1354,6 +1354,12 @@ class ScaleFactorCalculator {
} else {
return frontend::FakeQuantI16().getWeightsPrecision().size();
}
} else {
if (!info.isSynthetic()) {
gnawarn() << "The layer (" << ptr->name << ") has not quantization statistics\n";
}

return GetOptionalWeightsBytesSize();
}
}

Expand Down
4 changes: 4 additions & 0 deletions inference-engine/src/gna_plugin/layers/gna_layer_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,10 @@ class LayerInfo {
return isConcatAlignFilter() || isSyntheticScaleShift() || isCropAffined();
}

bool isSynthetic() const noexcept {
return isConcatAlignFilter() || isSyntheticScaleShift() || isConvolutionFilter() || isAffineFilter();
}

size_t paddingSize() const {
static InferenceEngine::details::caseless_set<std::string> layersWithPossiblePadding = {"FullyConnected",
"InnerProduct",
Expand Down

0 comments on commit 8c106fd

Please sign in to comment.