aboutsummaryrefslogtreecommitdiff
path: root/src/armnn/QuantizerVisitor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/armnn/QuantizerVisitor.cpp')
-rw-r--r--src/armnn/QuantizerVisitor.cpp55
1 files changed, 25 insertions, 30 deletions
diff --git a/src/armnn/QuantizerVisitor.cpp b/src/armnn/QuantizerVisitor.cpp
index 38e33cf2a3..4a87ca16ce 100644
--- a/src/armnn/QuantizerVisitor.cpp
+++ b/src/armnn/QuantizerVisitor.cpp
@@ -90,19 +90,20 @@ void QuantizerVisitor::VisitFullyConnectedLayer(const IConnectableLayer *layer,
{
std::vector<uint8_t> weightsBacking;
ConstTensor qWeights = CreateQuantizedConst(weights, weightsBacking);
+ Optional<ConstTensor> optionalQBiases;
+ std::vector<uint8_t> biasesBacking;
- IConnectableLayer* newLayer;
if (biases.has_value())
{
- std::vector<uint8_t> biasBacking;
- ConstTensor qBias = CreateQuantizedConst(biases.value(), biasBacking);
- newLayer = m_QuantizedNetwork->AddFullyConnectedLayer(desc, qWeights, qBias, name);
- }
- else
- {
- newLayer = m_QuantizedNetwork->AddFullyConnectedLayer(desc, qWeights, name);
+ ConstTensor qBiases = CreateQuantizedConst(biases.value(), biasesBacking);
+ optionalQBiases = Optional<ConstTensor>(qBiases);
}
+ IConnectableLayer* newLayer = m_QuantizedNetwork->AddFullyConnectedLayer(desc,
+ qWeights,
+ optionalQBiases,
+ name);
+
RecordLayer(layer, newLayer);
SetQuantizedInputConnections(layer, newLayer);
}
@@ -185,23 +186,20 @@ void QuantizerVisitor::VisitConvolution2dLayer(const IConnectableLayer* layer,
{
std::vector<uint8_t> weightsBacking;
ConstTensor qWeights = CreateQuantizedConst(weights, weightsBacking);
+ Optional<ConstTensor> optionalQBiases;
+ std::vector<uint8_t> biasesBacking;
- IConnectableLayer* newLayer;
if (biases.has_value())
{
- std::vector<uint8_t> biasesBacking;
ConstTensor qBiases = CreateQuantizedConst(biases.value(), biasesBacking);
-
- newLayer = m_QuantizedNetwork->AddConvolution2dLayer(convolution2dDescriptor,
- qWeights,
- qBiases,
- name);
- }
- else
- {
- newLayer = m_QuantizedNetwork->AddConvolution2dLayer(convolution2dDescriptor, qWeights, name);
+ optionalQBiases = Optional<ConstTensor>(qBiases);
}
+ IConnectableLayer* newLayer = m_QuantizedNetwork->AddConvolution2dLayer(convolution2dDescriptor,
+ qWeights,
+ optionalQBiases,
+ name);
+
RecordLayer(layer, newLayer);
SetQuantizedInputConnections(layer, newLayer);
}
@@ -214,23 +212,20 @@ void QuantizerVisitor::VisitDepthwiseConvolution2dLayer(const IConnectableLayer*
{
std::vector<uint8_t> weightsBacking;
ConstTensor qWeights = CreateQuantizedConst(weights, weightsBacking);
+ Optional<ConstTensor> optionalQBiases;
+ std::vector<uint8_t> biasesBacking;
- IConnectableLayer* newLayer;
if (biases.has_value())
{
- std::vector<uint8_t> biasesBacking;
ConstTensor qBiases = CreateQuantizedConst(biases.value(), biasesBacking);
-
- newLayer = m_QuantizedNetwork->AddDepthwiseConvolution2dLayer(desc,
- qWeights,
- qBiases,
- name);
- }
- else
- {
- newLayer = m_QuantizedNetwork->AddDepthwiseConvolution2dLayer(desc, qWeights, name);
+ optionalQBiases = Optional<ConstTensor>(qBiases);
}
+ IConnectableLayer* newLayer = m_QuantizedNetwork->AddDepthwiseConvolution2dLayer(desc,
+ qWeights,
+ optionalQBiases,
+ name);
+
RecordLayer(layer, newLayer);
SetQuantizedInputConnections(layer, newLayer);
}