diff options
author | Matthew Sloyan <matthew.sloyan@arm.com> | 2021-10-18 13:07:49 +0100 |
---|---|---|
committer | Matthew Sloyan <matthew.sloyan@arm.com> | 2021-10-20 16:03:04 +0100 |
commit | 5d7b0a314b3e354a6cbcf15f5dd78b50f1e02774 (patch) | |
tree | 3d844c4575193ffddfe3a17c51cb808c9f16ddb0 /src/armnnTfLiteParser/TfLiteParser.cpp | |
parent | 73010788725f8f07efb6df20711ece712ee213ea (diff) | |
download | armnn-5d7b0a314b3e354a6cbcf15f5dd78b50f1e02774.tar.gz |
Add ConstTensorsAsInput support for Conv3d
* Constant weights and biases are now stored as Constant layers.
* Updated Serializer, Deserializer and unit tests to reflect this.
* Updated TfLiteParser.
* Updated Ref backend to handle constant weights and
bias as inputs rather than reading from member variables.
* Added Conv3d EndToEnd test.
* Added NCDHW DataLayout and unit tests.
Signed-off-by: Matthew Sloyan <matthew.sloyan@arm.com>
Change-Id: I10cdd354ca5f1c748730f92ffdb36bf810f83c8e
Diffstat (limited to 'src/armnnTfLiteParser/TfLiteParser.cpp')
-rw-r--r-- | src/armnnTfLiteParser/TfLiteParser.cpp | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/armnnTfLiteParser/TfLiteParser.cpp b/src/armnnTfLiteParser/TfLiteParser.cpp index 81d491a1a1..7db5d85b13 100644 --- a/src/armnnTfLiteParser/TfLiteParser.cpp +++ b/src/armnnTfLiteParser/TfLiteParser.cpp @@ -1099,36 +1099,29 @@ void TfLiteParserImpl::ParseConv3D(size_t subgraphIndex, size_t operatorIndex) auto filterTensorAndData = CreateConstTensorNonPermuted(inputs[1], filterTensorInfo); - armnn::IConnectableLayer* layer = nullptr; auto layerName = fmt::format("Conv3D:{}:{}", subgraphIndex, operatorIndex); + auto inputTensorIndexes = AsUnsignedVector(GetInputTensorIds(m_Model, subgraphIndex, operatorIndex)); + // Add the first input and weights tensor to the registration list. + // The constant weights will be added by SetupConstantLayers. + std::vector<unsigned int> tensorIndexesToRegister = {inputTensorIndexes[0], inputTensorIndexes[1]}; + if (inputs.size() == 3) { desc.m_BiasEnabled = true; - armnn::TensorInfo biasTensorInfo = ToTensorInfo(inputs[2]); - auto biasTensorAndData = CreateConstTensorNonPermuted(inputs[2], biasTensorInfo); - layer = m_Network->AddConvolution3dLayer(desc, - filterTensorAndData, - Optional<ConstTensor>(biasTensorAndData), - layerName.c_str()); - } - else - { - layer = m_Network->AddConvolution3dLayer(desc, - filterTensorAndData, - EmptyOptional(), - layerName.c_str()); + + // Add the biases input to the registration list, a constant layer will be added by SetupConstantLayers. + tensorIndexesToRegister.emplace_back(inputTensorIndexes[2]); } + armnn::IConnectableLayer* layer = m_Network->AddConvolution3dLayer(desc, layerName.c_str()); ARMNN_ASSERT(layer != nullptr); armnn::TensorInfo outputTensorInfo = ToTensorInfo(outputs[0], true); layer->GetOutputSlot(0).SetTensorInfo(outputTensorInfo); // Register the input connection slots for the layer, connections are made after all layers have been created - // only the tensors for the inputs are relevant, exclude the const tensors - auto inputTensorIndexes = AsUnsignedVector(GetInputTensorIds(m_Model, subgraphIndex, operatorIndex)); - RegisterInputSlots(subgraphIndex, operatorIndex, layer, {inputTensorIndexes[0]}); + RegisterInputSlots(subgraphIndex, operatorIndex, layer, tensorIndexesToRegister); layer = AddFusedActivationLayer(layer, 0, options->fused_activation_function); // Register the output connection slots for the layer, connections are made after all layers have been created |