Francis Murtagh | 9270d9e | 2022-08-12 13:54:17 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2022 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | // List of Layer Support Rules common to TOSA backends only, for use with CheckSupportRule() |
| 9 | |
| 10 | struct TosaOperatorAttributeOfAny : public Rule |
| 11 | { |
| 12 | template<typename Container> |
| 13 | explicit TosaOperatorAttributeOfAny(TosaSerializationOperator* op, const Container& c) |
| 14 | { |
| 15 | m_Res = std::any_of(c.begin(), c.end(), [&op](Attribute attribute) |
| 16 | { |
| 17 | return attribute == op->GetAttributeType(); |
| 18 | }); |
| 19 | } |
| 20 | }; |
| 21 | |
| 22 | struct TosaTypeAnyOf : public Rule |
| 23 | { |
| 24 | template<typename Container> |
| 25 | TosaTypeAnyOf(TosaSerializationTensor* tensor, const Container& c) |
| 26 | { |
| 27 | m_Res = std::any_of(c.begin(), c.end(), [&tensor](DType dt) |
| 28 | { |
| 29 | return dt == tensor->GetDtype(); |
| 30 | }); |
| 31 | } |
| 32 | }; |
| 33 | |
| 34 | struct TosaTensorNumDimensionsWithinBounds : public Rule |
| 35 | { |
| 36 | explicit TosaTensorNumDimensionsWithinBounds(TosaSerializationTensor* tensor) |
| 37 | { |
| 38 | m_Res = (tensor->GetShape().size() <= MaxNumOfTensorDimensions) || (!tensor->GetShape().empty()); |
| 39 | } |
| 40 | }; |