diff options
Diffstat (limited to 'src')
16 files changed, 43 insertions, 12 deletions
diff --git a/src/backends/tosaCommon/TosaMappings.cpp b/src/backends/tosaCommon/TosaMappings.cpp index 6ab1b06b30..a998996f19 100644 --- a/src/backends/tosaCommon/TosaMappings.cpp +++ b/src/backends/tosaCommon/TosaMappings.cpp @@ -12,7 +12,7 @@ TosaSerializationBasicBlock* CreateEmptyTosaSerializationBasicBlock() { // Empty basic block when no TOSA mapping implemented/exists auto* op = new TosaSerializationOperator(Op_UNKNOWN, Attribute_NONE, nullptr, {}, {}); - return new TosaSerializationBasicBlock("", {op}, {}, {}, {}); + return new TosaSerializationBasicBlock("", "", {op}, {}, {}, {}); } TosaSerializationBasicBlock* GetTosaMapping(const Layer* layer, diff --git a/src/backends/tosaCommon/operatorMappings/AvgPool2DIgnoreValueOperator.cpp b/src/backends/tosaCommon/operatorMappings/AvgPool2DIgnoreValueOperator.cpp index 61de0ae39a..a7ca873831 100644 --- a/src/backends/tosaCommon/operatorMappings/AvgPool2DIgnoreValueOperator.cpp +++ b/src/backends/tosaCommon/operatorMappings/AvgPool2DIgnoreValueOperator.cpp @@ -111,6 +111,7 @@ TosaSerializationBasicBlock* ConvertAvgPool2DIgnoreValueToTosaOperator(const Lay // operatorInputNames/operatorOutputNames ends up being the same as // blockInputNames/blockOutputNames for one-to-one ArmNN to TOSA mappings return new TosaSerializationBasicBlock(blockName, // name + mainName, // region name {opPad, opPool}, // operators tensors, // tensors {padInputName}, // inputs diff --git a/src/backends/tosaCommon/operatorMappings/ConcatOperator.cpp b/src/backends/tosaCommon/operatorMappings/ConcatOperator.cpp index 8c651be052..d1ff0dfb20 100644 --- a/src/backends/tosaCommon/operatorMappings/ConcatOperator.cpp +++ b/src/backends/tosaCommon/operatorMappings/ConcatOperator.cpp @@ -74,6 +74,7 @@ TosaSerializationBasicBlock* ConvertConcatToTosaOperator(const Layer* layer, // operatorInputNames/operatorOutputNames ends up being the same as // blockInputNames/blockOutputNames for one-to-one ArmNN to TOSA mappings return new TosaSerializationBasicBlock(blockName, // name + mainName, // region name {op}, // operators tensors, // tensors inputNames, // inputs diff --git a/src/backends/tosaCommon/operatorMappings/ConstantOperator.cpp b/src/backends/tosaCommon/operatorMappings/ConstantOperator.cpp index 5e3973f8ec..c7cd7d7969 100644 --- a/src/backends/tosaCommon/operatorMappings/ConstantOperator.cpp +++ b/src/backends/tosaCommon/operatorMappings/ConstantOperator.cpp @@ -37,6 +37,7 @@ TosaSerializationBasicBlock* ConvertConstantToTosaOperator(const Layer* layer, auto* outputTensor0 = new TosaSerializationTensor(outputName, outputShape0, outputDType0, uint8Data); return new TosaSerializationBasicBlock(blockName, // name + mainName, // region name {op}, // operators {outputTensor0}, // tensors {}, // inputs diff --git a/src/backends/tosaCommon/operatorMappings/Conv2dOperator.cpp b/src/backends/tosaCommon/operatorMappings/Conv2dOperator.cpp index a7af08347a..fdd6ca4c27 100644 --- a/src/backends/tosaCommon/operatorMappings/Conv2dOperator.cpp +++ b/src/backends/tosaCommon/operatorMappings/Conv2dOperator.cpp @@ -114,7 +114,7 @@ TosaSerializationBasicBlock* ConvertConv2dToTosaOperator(const Layer* layer, static_cast<int>(conv2dDescriptor->m_StrideX)}; std::vector<int> dilation = {static_cast<int>(conv2dDescriptor->m_DilationY), static_cast<int>(conv2dDescriptor->m_DilationX)}; - TosaConvAttribute attribute(pad, stride, dilation, 0, 0, ArmNNToDType(inputs[0]->GetDataType())); + TosaConvAttribute attribute(pad, stride, dilation, 0, 0); auto* op = new TosaSerializationOperator(Op_CONV2D, Attribute_ConvAttribute, @@ -126,6 +126,7 @@ TosaSerializationBasicBlock* ConvertConv2dToTosaOperator(const Layer* layer, // operatorInputNames/operatorOutputNames ends up being the same as // blockInputNames/blockOutputNames for one-to-one ArmNN to TOSA mappings return new TosaSerializationBasicBlock(blockName, // name + mainName, // region name operators, // operators tensors, // tensors inputNames, // inputs diff --git a/src/backends/tosaCommon/operatorMappings/ElementwiseBinaryOperator.cpp b/src/backends/tosaCommon/operatorMappings/ElementwiseBinaryOperator.cpp index 9909e66a7d..28e7ec8231 100644 --- a/src/backends/tosaCommon/operatorMappings/ElementwiseBinaryOperator.cpp +++ b/src/backends/tosaCommon/operatorMappings/ElementwiseBinaryOperator.cpp @@ -95,6 +95,7 @@ TosaSerializationBasicBlock* ConvertElementwiseBinaryToTosaOperator(const Layer* // operatorInputNames/operatorOutputNames ends up being the same as // blockInputNames/blockOutputNames for one-to-one ArmNN to Tosa mappings return new TosaSerializationBasicBlock(blockName, // name + mainName, // region name {op}, // operators tensors, // tensors {input0Name, input1Name}, // inputs diff --git a/src/backends/tosaCommon/operatorMappings/ElementwiseUnaryOperator.cpp b/src/backends/tosaCommon/operatorMappings/ElementwiseUnaryOperator.cpp index 15fb9d746b..17ea64b984 100644 --- a/src/backends/tosaCommon/operatorMappings/ElementwiseUnaryOperator.cpp +++ b/src/backends/tosaCommon/operatorMappings/ElementwiseUnaryOperator.cpp @@ -65,6 +65,7 @@ TosaSerializationBasicBlock* ConvertElementwiseUnaryOperator(const Layer* layer, // operatorInputNames/operatorOutputNames ends up being the same as // blockInputNames/blockOutputNames for one-to-one ArmNN to Tosa mappings return new TosaSerializationBasicBlock(blockName, // name + mainName, // region name {op}, // operators tensors, // tensors {input0Name}, // inputs diff --git a/src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp b/src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp index 444d99a39e..c33f61296a 100644 --- a/src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp +++ b/src/backends/tosaCommon/operatorMappings/Pooling2DOperator.cpp @@ -66,6 +66,7 @@ TosaSerializationBasicBlock* ConvertPooling2DToTosaOperator(const Layer* layer, // operatorInputNames/operatorOutputNames ends up being the same as // blockInputNames/blockOutputNames for one-to-one ArmNN to TOSA mappings return new TosaSerializationBasicBlock(blockName, // name + mainName, // region name {op}, // operators tensors, // tensors {input0Name}, // inputs diff --git a/src/backends/tosaCommon/operatorMappings/ReshapeOperator.cpp b/src/backends/tosaCommon/operatorMappings/ReshapeOperator.cpp index 10670ecb95..55d66806b7 100644 --- a/src/backends/tosaCommon/operatorMappings/ReshapeOperator.cpp +++ b/src/backends/tosaCommon/operatorMappings/ReshapeOperator.cpp @@ -55,6 +55,7 @@ TosaSerializationBasicBlock* ConvertReshapeToTosaOperator(const Layer* layer, // operatorInputNames/operatorOutputNames ends up being the same as // blockInputNames/blockOutputNames for one-to-one ArmNN to TOSA mappings return new TosaSerializationBasicBlock(blockName, // name + mainName, // region name {op}, // operators tensors, // tensors {inputName}, // inputs diff --git a/src/backends/tosaCommon/operatorMappings/SliceOperator.cpp b/src/backends/tosaCommon/operatorMappings/SliceOperator.cpp index b98576f47d..294d38937f 100644 --- a/src/backends/tosaCommon/operatorMappings/SliceOperator.cpp +++ b/src/backends/tosaCommon/operatorMappings/SliceOperator.cpp @@ -58,6 +58,7 @@ TosaSerializationBasicBlock* ConvertSliceToTosaOperator(const Layer* layer, // operatorInputNames/operatorOutputNames ends up being the same as // blockInputNames/blockOutputNames for one-to-one ArmNN to TOSA mappings return new TosaSerializationBasicBlock(blockName, // name + mainName, // region name {op}, // operators tensors, // tensors {inputName}, // inputs diff --git a/src/backends/tosaCommon/operatorMappings/TosaOperatorUtils.hpp b/src/backends/tosaCommon/operatorMappings/TosaOperatorUtils.hpp index dccb29892c..3e106e1fd5 100644 --- a/src/backends/tosaCommon/operatorMappings/TosaOperatorUtils.hpp +++ b/src/backends/tosaCommon/operatorMappings/TosaOperatorUtils.hpp @@ -16,14 +16,17 @@ using namespace armnn; using namespace tosa; +const std::string mainName = "main"; + // Function to return Tosa datatype from input ArmNN datatype. inline DType ArmNNToDType(const DataType& type) { switch (type) { case DataType::Float16: - case DataType::BFloat16: return DType_FP16; + case DataType::BFloat16: + return DType_BF16; case DataType::Float32: return DType_FP32; case DataType::QAsymmU8: @@ -126,6 +129,8 @@ inline std::string TosaDTypeToString(DType tosaDType) return "DType_UINT16"; case DType_FP16: return "DType_FP16"; + case DType_BF16: + return "DType_BF16"; } return ""; } @@ -273,6 +278,10 @@ inline std::string TosaOpToString(Op tosaOp) return "Op_COND_IF"; case Op_WHILE_LOOP: return "Op_WHILE_LOOP"; + case Op_FFT2D: + return "Op_FFT2D"; + case Op_RFFT2D: + return "Op_RFFT2D"; } return ""; } diff --git a/src/backends/tosaCommon/operatorMappings/TransposeConv2dOperator.cpp b/src/backends/tosaCommon/operatorMappings/TransposeConv2dOperator.cpp index c8af5c2926..3041b790ae 100644 --- a/src/backends/tosaCommon/operatorMappings/TransposeConv2dOperator.cpp +++ b/src/backends/tosaCommon/operatorMappings/TransposeConv2dOperator.cpp @@ -143,7 +143,7 @@ TosaSerializationBasicBlock* ConvertTransposeConv2dToTosaOperator(const Layer* l } } - TosaTransposeConvAttribute attribute(pad, stride, outputShape, 0, 0, ArmNNToDType(inputs[0]->GetDataType())); + TosaTransposeConvAttribute attribute(pad, stride, outputShape, 0, 0); auto* op = new TosaSerializationOperator(Op_TRANSPOSE_CONV2D, Attribute_TransposeConvAttribute, @@ -155,6 +155,7 @@ TosaSerializationBasicBlock* ConvertTransposeConv2dToTosaOperator(const Layer* l // operatorInputNames/operatorOutputNames ends up being the same as // blockInputNames/blockOutputNames for one-to-one ArmNN to TOSA mappings return new TosaSerializationBasicBlock(blockName, // name + mainName, // region name operators, // operators tensors, // tensors {input0Name, input1Name, input2Name}, // inputs diff --git a/src/backends/tosaCommon/operatorMappings/TransposeOperator.cpp b/src/backends/tosaCommon/operatorMappings/TransposeOperator.cpp index 56178e428b..ccc77741c9 100644 --- a/src/backends/tosaCommon/operatorMappings/TransposeOperator.cpp +++ b/src/backends/tosaCommon/operatorMappings/TransposeOperator.cpp @@ -58,6 +58,7 @@ TosaSerializationBasicBlock* ConvertTransposeToTosaOperator(const Layer* layer, // operatorInputNames/operatorOutputNames ends up being the same as // blockInputNames/blockOutputNames for one-to-one ArmNN to TOSA mappings return new TosaSerializationBasicBlock(blockName, // name + mainName, // region name {op}, // operators tensors, // tensors {input0Name}, // inputs diff --git a/src/backends/tosaReference/TosaRefBackend.cpp b/src/backends/tosaReference/TosaRefBackend.cpp index bce3e2c1b8..aaac07c27b 100644 --- a/src/backends/tosaReference/TosaRefBackend.cpp +++ b/src/backends/tosaReference/TosaRefBackend.cpp @@ -137,10 +137,15 @@ OptimizationViews TosaRefBackend::OptimizeSubgraphView(const SubgraphView& subgr tensors.insert(tensors.end(), blockTensors.begin(), blockTensors.end()); } - // Add all mappings to main block, the TOSA Reference Model requires the full graph to be in one block called main. - auto* block = new TosaSerializationBasicBlock("main", operators, tensors, graphInputs, graphOutputs); + // Add all mappings to main block. + auto* block = new TosaSerializationBasicBlock("main", "main", operators, tensors, graphInputs, graphOutputs); - handler.get()->GetBlocks().push_back(block); + std::vector<TosaSerializationBasicBlock*> blocks; + blocks.emplace_back(block); + + // Add blocks to the main region. + auto* region = new TosaSerializationRegion("main", blocks); + handler->GetRegions().emplace_back(region); auto compiledBlob = std::make_unique<PreCompiledObjectPtr>(handler.release(), DeleteAsType<TosaSerializationHandler>); diff --git a/src/backends/tosaReference/TosaRefLayerSupport.cpp b/src/backends/tosaReference/TosaRefLayerSupport.cpp index 238801cb98..e1c349feb4 100644 --- a/src/backends/tosaReference/TosaRefLayerSupport.cpp +++ b/src/backends/tosaReference/TosaRefLayerSupport.cpp @@ -103,13 +103,20 @@ bool TosaRefLayerSupport::IsLayerSupported(const LayerType& type, TosaSerializationHandler handler; - // Add mappings to main block as the TOSA Reference Model requires the graph to be in one block called main. + // Add all mappings to main block. auto* block = new TosaSerializationBasicBlock("main", + "main", mappings->GetOperators(), mappings->GetTensors(), mappings->GetInputs(), mappings->GetOutputs()); - handler.GetBlocks().emplace_back(block); + + std::vector<TosaSerializationBasicBlock*> blocks; + blocks.emplace_back(block); + + // Add blocks to the main region. + auto* region = new TosaSerializationRegion("main", blocks); + handler.GetRegions().emplace_back(region); GraphStatus status; TosaReference::IModelRunner runner; diff --git a/src/backends/tosaReference/workloads/TosaRefPreCompiledWorkload.cpp b/src/backends/tosaReference/workloads/TosaRefPreCompiledWorkload.cpp index ba353a32c7..8b08f01b23 100644 --- a/src/backends/tosaReference/workloads/TosaRefPreCompiledWorkload.cpp +++ b/src/backends/tosaReference/workloads/TosaRefPreCompiledWorkload.cpp @@ -20,13 +20,12 @@ TosaRefPreCompiledWorkload::TosaRefPreCompiledWorkload(const PreCompiledQueueDes "TosaRefPreCompiledWorkload requires a valid pre-compiled object (TosaSerializationHandler)."); } } - void TosaRefPreCompiledWorkload::Execute() const { tosa::TosaSerializationHandler* handler = static_cast<tosa::TosaSerializationHandler*>(m_Data.m_PreCompiledObject); - std::vector<std::string> inputNames = handler->GetInputs(); - std::vector<std::string> outputNames = handler->GetOutputs(); + std::vector<std::string> inputNames = handler->GetMainRegion()->GetBlocks()[0]->GetInputs(); + std::vector<std::string> outputNames = handler->GetMainRegion()->GetBlocks()[0]->GetOutputs(); TosaReference::IModelRunner runner; GraphStatus status; |