aboutsummaryrefslogtreecommitdiff
path: root/src/backends/reference/workloads/Conv3dImpl.cpp
diff options
context:
space:
mode:
authorMatthew Sloyan <matthew.sloyan@arm.com>2021-10-18 13:07:49 +0100
committerMatthew Sloyan <matthew.sloyan@arm.com>2021-10-20 16:03:04 +0100
commit5d7b0a314b3e354a6cbcf15f5dd78b50f1e02774 (patch)
tree3d844c4575193ffddfe3a17c51cb808c9f16ddb0 /src/backends/reference/workloads/Conv3dImpl.cpp
parent73010788725f8f07efb6df20711ece712ee213ea (diff)
downloadarmnn-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/backends/reference/workloads/Conv3dImpl.cpp')
-rw-r--r--src/backends/reference/workloads/Conv3dImpl.cpp47
1 files changed, 37 insertions, 10 deletions
diff --git a/src/backends/reference/workloads/Conv3dImpl.cpp b/src/backends/reference/workloads/Conv3dImpl.cpp
index 484d887cfc..1c06d624a8 100644
--- a/src/backends/reference/workloads/Conv3dImpl.cpp
+++ b/src/backends/reference/workloads/Conv3dImpl.cpp
@@ -113,11 +113,25 @@ void Convolve3d(const TensorShape& rInputShape,
// Keep this implementation, as using DataLayoutIndexed::GetIndex
// causes large performance regression.
- inputIndex = batchIdx * inputDepth * inputHeight * inputWidth * inChannels +
- (zInput-paddingFront) * inputHeight * inputWidth * inChannels +
- (yInput-paddingTop) * inputWidth * inChannels +
- (xInput-paddingLeft) * inChannels +
- cInput;
+ if (dataLayoutIndexed.GetDataLayout() == DataLayout::NDHWC)
+ {
+ inputIndex =
+ batchIdx * inputDepth * inputHeight * inputWidth * inChannels +
+ (zInput-paddingFront) * inputHeight * inputWidth * inChannels +
+ (yInput-paddingTop) * inputWidth * inChannels +
+ (xInput-paddingLeft) * inChannels +
+ cInput;
+ }
+ else
+ {
+ // NCDHW DataLayout
+ inputIndex =
+ batchIdx * inputDepth * inputHeight * inputWidth * inChannels +
+ inputDepth * inputHeight * inputWidth * cInput +
+ (zInput-paddingFront) * inputHeight * inputWidth +
+ (yInput-paddingTop) * inputWidth +
+ xInput-paddingLeft;
+ }
inputValue = inputVec[inputIndex];
}
@@ -133,11 +147,24 @@ void Convolve3d(const TensorShape& rInputShape,
sum += biasVec[cOutput];
}
- unsigned int outIdx = batchIdx * outputDepth * outputHeight * outputWidth * outChannels +
- zOutput * outputHeight * outputWidth * outChannels +
- yOutput * outputWidth * outChannels +
- xOutput * outChannels +
- cOutput;
+ unsigned int outIdx;
+ if (dataLayoutIndexed.GetDataLayout() == DataLayout::NDHWC)
+ {
+ outIdx = batchIdx * outputDepth * outputHeight * outputWidth * outChannels +
+ zOutput * outputHeight * outputWidth * outChannels +
+ yOutput * outputWidth * outChannels +
+ xOutput * outChannels +
+ cOutput;
+ }
+ else
+ {
+ // NCDHW DataLayout
+ outIdx = batchIdx * outputDepth * outputHeight * outputWidth * outChannels +
+ cOutput * outputDepth * outputHeight * outputWidth +
+ zOutput * outputHeight * outputWidth +
+ yOutput * outputWidth +
+ xOutput;
+ }
rOutputEncoder[outIdx];
rOutputEncoder.Set(sum);