From 37c3e508dcd767e8823c913f3f487d6b0bd03fb2 Mon Sep 17 00:00:00 2001 From: Mike Kelly Date: Tue, 9 Nov 2021 15:43:37 +0000 Subject: Fixed Driver Crash in DumpTensor * When handling Tensors DumpTensor was automatically trying to turn them into ConstTensors but then threw an exceptions when IsConstant returned false Signed-off-by: Mike Kelly Change-Id: I8681bb3dd41cfe19c60fbd1cc9394c8b6cca551e --- Utils.cpp | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'Utils.cpp') diff --git a/Utils.cpp b/Utils.cpp index f910cd49..884bed00 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -335,14 +335,15 @@ std::string GetOperandSummary(const V1_3::Operand& operand) #endif -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]) << " "; @@ -350,10 +351,11 @@ void DumpTensorElement(const armnn::ConstTensor& tensor, unsigned int elementInd } // 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; @@ -368,38 +370,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: @@ -473,6 +475,17 @@ 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, -- cgit v1.2.1