diff options
Diffstat (limited to 'src/backends/tosaCommon')
-rw-r--r-- | src/backends/tosaCommon/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/backends/tosaCommon/TosaLayerSupportRules.hpp | 40 |
2 files changed, 41 insertions, 0 deletions
diff --git a/src/backends/tosaCommon/CMakeLists.txt b/src/backends/tosaCommon/CMakeLists.txt index 9653859767..61434edc96 100644 --- a/src/backends/tosaCommon/CMakeLists.txt +++ b/src/backends/tosaCommon/CMakeLists.txt @@ -8,6 +8,7 @@ include_directories(SYSTEM ${TOSA_SERIALIZATION_LIB_INCLUDE}) list(APPEND armnnTosaBackend_sources TosaMappings.hpp + TosaLayerSupportRules.hpp ) add_subdirectory(operatorMappings) diff --git a/src/backends/tosaCommon/TosaLayerSupportRules.hpp b/src/backends/tosaCommon/TosaLayerSupportRules.hpp new file mode 100644 index 0000000000..2a2b08da99 --- /dev/null +++ b/src/backends/tosaCommon/TosaLayerSupportRules.hpp @@ -0,0 +1,40 @@ +// +// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. +// SPDX-License-Identifier: MIT +// + +#pragma once + +// List of Layer Support Rules common to TOSA backends only, for use with CheckSupportRule() + +struct TosaOperatorAttributeOfAny : public Rule +{ + template<typename Container> + explicit TosaOperatorAttributeOfAny(TosaSerializationOperator* op, const Container& c) + { + m_Res = std::any_of(c.begin(), c.end(), [&op](Attribute attribute) + { + return attribute == op->GetAttributeType(); + }); + } +}; + +struct TosaTypeAnyOf : public Rule +{ + template<typename Container> + TosaTypeAnyOf(TosaSerializationTensor* tensor, const Container& c) + { + m_Res = std::any_of(c.begin(), c.end(), [&tensor](DType dt) + { + return dt == tensor->GetDtype(); + }); + } +}; + +struct TosaTensorNumDimensionsWithinBounds : public Rule +{ + explicit TosaTensorNumDimensionsWithinBounds(TosaSerializationTensor* tensor) + { + m_Res = (tensor->GetShape().size() <= MaxNumOfTensorDimensions) || (!tensor->GetShape().empty()); + } +}; |