From 09742380f1d986e3f7d3a7d130f37f3ab85729fd Mon Sep 17 00:00:00 2001 From: Sadik Armagan Date: Fri, 15 Jul 2022 10:22:49 +0100 Subject: IVGCVSW-7107 'Error while running Arm NN Sl with -d option' * Templated the DumpTensor() function based on tensor type Signed-off-by: Sadik Armagan Change-Id: I08775e480f89010be61daf0a09a2ab0274e05978 --- shim/sl/canonical/CanonicalUtils.cpp | 35 +++++++++++++++++++++++------------ shim/sl/canonical/CanonicalUtils.hpp | 3 ++- 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/shim/sl/canonical/CanonicalUtils.cpp b/shim/sl/canonical/CanonicalUtils.cpp index 713629f554..059b5ca4a3 100644 --- a/shim/sl/canonical/CanonicalUtils.cpp +++ b/shim/sl/canonical/CanonicalUtils.cpp @@ -198,25 +198,26 @@ std::string GetOperandSummary(const Operand& operand) return ss.str(); } -using DumpElementFunction = void (*)(const armnn::ConstTensor& tensor, +template +using DumpElementFunction = void (*)(const TensorType& tensor, unsigned int elementIndex, std::ofstream& fileStream); namespace { -template -void DumpTensorElement(const armnn::ConstTensor& tensor, unsigned int elementIndex, std::ofstream& fileStream) +template +void DumpTensorElement(const TensorType& tensor, unsigned int elementIndex, std::ofstream& fileStream) { const ElementType* elements = reinterpret_cast(tensor.GetMemoryArea()); fileStream << static_cast(elements[elementIndex]) << " "; } } // namespace - +template void DumpTensor(const std::string& dumpDir, const std::string& requestName, const std::string& tensorName, - const armnn::ConstTensor& tensor) + const TensorType& tensor) { // The dump directory must exist in advance. fs::path dumpPath = dumpDir; @@ -231,38 +232,38 @@ void DumpTensor(const std::string& dumpDir, return; } - DumpElementFunction dumpElementFunction = nullptr; + DumpElementFunction dumpElementFunction = nullptr; switch (tensor.GetDataType()) { case armnn::DataType::Float32: { - dumpElementFunction = &DumpTensorElement; + dumpElementFunction = &DumpTensorElement; break; } case armnn::DataType::QAsymmU8: { - dumpElementFunction = &DumpTensorElement; + dumpElementFunction = &DumpTensorElement; break; } case armnn::DataType::Signed32: { - dumpElementFunction = &DumpTensorElement; + dumpElementFunction = &DumpTensorElement; break; } case armnn::DataType::Float16: { - dumpElementFunction = &DumpTensorElement; + dumpElementFunction = &DumpTensorElement; break; } case armnn::DataType::QAsymmS8: { - dumpElementFunction = &DumpTensorElement; + dumpElementFunction = &DumpTensorElement; break; } case armnn::DataType::Boolean: { - dumpElementFunction = &DumpTensorElement; + dumpElementFunction = &DumpTensorElement; break; } default: @@ -336,6 +337,16 @@ void DumpTensor(const std::string& dumpDir, } } +template void DumpTensor(const std::string& dumpDir, + const std::string& requestName, + const std::string& tensorName, + const armnn::ConstTensor& tensor); + +template void DumpTensor(const std::string& dumpDir, + const std::string& requestName, + const std::string& tensorName, + const armnn::Tensor& tensor); + void DumpJsonProfilingIfRequired(bool gpuProfilingEnabled, const std::string& dumpDir, armnn::NetworkId networkId, diff --git a/shim/sl/canonical/CanonicalUtils.hpp b/shim/sl/canonical/CanonicalUtils.hpp index a509684153..b94fd5e126 100644 --- a/shim/sl/canonical/CanonicalUtils.hpp +++ b/shim/sl/canonical/CanonicalUtils.hpp @@ -55,10 +55,11 @@ bool isQuantizedOperand(const OperandType& operandType); std::string GetModelSummary(const Model& model); +template void DumpTensor(const std::string& dumpDir, const std::string& requestName, const std::string& tensorName, - const armnn::ConstTensor& tensor); + const TensorType& tensor); void DumpJsonProfilingIfRequired(bool gpuProfilingEnabled, const std::string& dumpDir, -- cgit v1.2.1