From 571a4f723042215f52a6c0366347c5b23f48c902 Mon Sep 17 00:00:00 2001 From: Teresa Charlin Date: Tue, 26 Mar 2024 11:18:42 +0000 Subject: IVGCVSW-8165: Update TOSA Common and TosaRef to use TOSA v0.80 * Keep the order of the operators in TosaRef, so that const ops go first * Remove IsLayerSupportedTosaReferenceConstantUnsupported and open ticket in MLTOSA Signed-off-by: Teresa Charlin Change-Id: Ifaa6c26dd8ad7d531f1691320d8c731956b910aa --- .../tosaCommon/operatorMappings/Conv2dOperator.cpp | 4 ++-- .../tosaCommon/operatorMappings/TosaOperatorUtils.hpp | 6 ++++++ .../operatorMappings/TosaRescaleOperatorUtils.hpp | 4 +++- .../operatorMappings/TransposeConv2dOperator.cpp | 4 ++-- src/backends/tosaReference/TosaRefBackend.cpp | 18 ++++++++---------- .../tosaReference/test/TosaRefLayerSupportTests.cpp | 16 ---------------- 6 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/backends/tosaCommon/operatorMappings/Conv2dOperator.cpp b/src/backends/tosaCommon/operatorMappings/Conv2dOperator.cpp index fdd6ca4c27..c65f1891da 100644 --- a/src/backends/tosaCommon/operatorMappings/Conv2dOperator.cpp +++ b/src/backends/tosaCommon/operatorMappings/Conv2dOperator.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2022-2024 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -114,7 +114,7 @@ TosaSerializationBasicBlock* ConvertConv2dToTosaOperator(const Layer* layer, static_cast(conv2dDescriptor->m_StrideX)}; std::vector dilation = {static_cast(conv2dDescriptor->m_DilationY), static_cast(conv2dDescriptor->m_DilationX)}; - TosaConvAttribute attribute(pad, stride, dilation, 0, 0); + TosaConvAttribute attribute(pad, stride, dilation, 0, 0, false); // input_zp, weight_zp, local_bound auto* op = new TosaSerializationOperator(Op_CONV2D, Attribute_ConvAttribute, diff --git a/src/backends/tosaCommon/operatorMappings/TosaOperatorUtils.hpp b/src/backends/tosaCommon/operatorMappings/TosaOperatorUtils.hpp index 817aba36b2..047e0a1f42 100644 --- a/src/backends/tosaCommon/operatorMappings/TosaOperatorUtils.hpp +++ b/src/backends/tosaCommon/operatorMappings/TosaOperatorUtils.hpp @@ -131,6 +131,8 @@ inline std::string TosaDTypeToString(DType tosaDType) return "DType_FP16"; case DType_BF16: return "DType_BF16"; + case DType_SHAPE: + return "DType_SHAPE"; } return ""; } @@ -282,6 +284,10 @@ inline std::string TosaOpToString(Op tosaOp) return "Op_FFT2D"; case Op_RFFT2D: return "Op_RFFT2D"; + case Op_ERF: + return "Op_ERF"; + case Op_DIM: // = Op_MAX + return "Op_DIM"; } return ""; } diff --git a/src/backends/tosaCommon/operatorMappings/TosaRescaleOperatorUtils.hpp b/src/backends/tosaCommon/operatorMappings/TosaRescaleOperatorUtils.hpp index a0432846f5..1a4dd7aac3 100644 --- a/src/backends/tosaCommon/operatorMappings/TosaRescaleOperatorUtils.hpp +++ b/src/backends/tosaCommon/operatorMappings/TosaRescaleOperatorUtils.hpp @@ -33,7 +33,9 @@ inline void CreateRescaleTosaOperator(const std::string& inputName, shifts, scale32, double_round, - false); + false, // per_channel + false, // input_unsigned + false); // output_unsigned // op *op = new TosaSerializationOperator(Op_RESCALE, Attribute_RescaleAttribute, &attribute, {inputName}, {outputName}); diff --git a/src/backends/tosaCommon/operatorMappings/TransposeConv2dOperator.cpp b/src/backends/tosaCommon/operatorMappings/TransposeConv2dOperator.cpp index 3041b790ae..8c2ae9f2b5 100644 --- a/src/backends/tosaCommon/operatorMappings/TransposeConv2dOperator.cpp +++ b/src/backends/tosaCommon/operatorMappings/TransposeConv2dOperator.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2022-2024 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -143,7 +143,7 @@ TosaSerializationBasicBlock* ConvertTransposeConv2dToTosaOperator(const Layer* l } } - TosaTransposeConvAttribute attribute(pad, stride, outputShape, 0, 0); + TosaTransposeConvAttribute attribute(pad, stride, outputShape, 0, 0, false); // input_zp, weight_zp, local_bound auto* op = new TosaSerializationOperator(Op_TRANSPOSE_CONV2D, Attribute_TransposeConvAttribute, diff --git a/src/backends/tosaReference/TosaRefBackend.cpp b/src/backends/tosaReference/TosaRefBackend.cpp index aaac07c27b..db653391e2 100644 --- a/src/backends/tosaReference/TosaRefBackend.cpp +++ b/src/backends/tosaReference/TosaRefBackend.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2022-2024 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -92,15 +92,15 @@ OptimizationViews TosaRefBackend::OptimizeSubgraphView(const SubgraphView& subgr std::vector operators; std::vector tensors; - auto it = subgraph.end(); - while (it != subgraph.begin()) + auto it = subgraph.begin(); + while (it != subgraph.end()) { - --it; Layer& base = *(PolymorphicDowncast(*it)); if(base.GetType() == armnn::LayerType::Input || base.GetType() == armnn::LayerType::Output) { + ++it; continue; } @@ -108,10 +108,8 @@ OptimizationViews TosaRefBackend::OptimizeSubgraphView(const SubgraphView& subgr // Loop through inputs to see if there are any graph inputs, if so save them. // If it's an input to the graph "input" can be found in the string. - for (uint32_t i = 0; i < mappings->GetInputs().size(); i++) + for (const std::string& blockInputName : mappings->GetInputs()) { - std::basic_string blockInputName = mappings->GetInputs()[i]; - if (blockInputName.find("input") != std::string::npos) { graphInputs.push_back(blockInputName); @@ -120,10 +118,8 @@ OptimizationViews TosaRefBackend::OptimizeSubgraphView(const SubgraphView& subgr // Loop through outputs to see if there are any graph outputs, if so save them. // If it's an output to the graph "output" can be found in the string. - for (uint32_t i = 0; i < mappings->GetOutputs().size(); i++) + for (const std::string& blockOutputName : mappings->GetOutputs()) { - std::basic_string blockOutputName = mappings->GetOutputs()[i]; - if (blockOutputName.find("output") != std::string::npos) { graphOutputs.push_back(blockOutputName); @@ -135,6 +131,8 @@ OptimizationViews TosaRefBackend::OptimizeSubgraphView(const SubgraphView& subgr auto blockTensors = mappings->GetTensors(); tensors.insert(tensors.end(), blockTensors.begin(), blockTensors.end()); + + ++it; } // Add all mappings to main block. diff --git a/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp b/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp index 2da2875a76..759b37fe93 100644 --- a/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp +++ b/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp @@ -129,22 +129,6 @@ TEST_CASE("IsLayerSupportedTosaReferenceConstant") CHECK(supported); } -TEST_CASE("IsLayerSupportedTosaReferenceConstantUnsupported") -{ - TensorInfo outputInfo({1,1,3,4}, DataType::Signed64); - - TosaRefLayerSupport supportChecker; - std::string reasonIfNotSupported; - auto supported = supportChecker.IsLayerSupported(LayerType::Constant, - {outputInfo}, - BaseDescriptor(), - EmptyOptional(), - EmptyOptional(), - reasonIfNotSupported); - - CHECK(!supported); -} - TEST_CASE("IsLayerSupportedTosaReferenceConv2d") { TensorInfo inputInfo ({ 1, 5, 5, 1 }, DataType::Float32); -- cgit v1.2.1