// // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // #pragma once #include #include #include #include #include namespace armnn { template void SetValueChecked(Optional optionalRef, V&& val) { if (optionalRef) { optionalRef.value() = val; } } template bool IsSupportedForDataTypeGeneric(Optional reasonIfUnsupported, DataType dataType, Float16Func float16FuncPtr, Float32Func float32FuncPtr, Uint8Func uint8FuncPtr, Int32Func int32FuncPtr, BooleanFunc booleanFuncPtr, Params&&... params) { switch(dataType) { case DataType::Float16: return float16FuncPtr(reasonIfUnsupported, std::forward(params)...); case DataType::Float32: return float32FuncPtr(reasonIfUnsupported, std::forward(params)...); case DataType::QAsymmU8: return uint8FuncPtr(reasonIfUnsupported, std::forward(params)...); case DataType::Signed32: return int32FuncPtr(reasonIfUnsupported, std::forward(params)...); case DataType::Boolean: return booleanFuncPtr(reasonIfUnsupported, std::forward(params)...); default: return false; } } template bool TrueFunc(Optional reasonIfUnsupported, Params&&... params) { IgnoreUnused(reasonIfUnsupported); IgnoreUnused(params...); return true; } template bool FalseFunc(Optional reasonIfUnsupported, Params&&... params) { IgnoreUnused(reasonIfUnsupported); IgnoreUnused(params...); return false; } template bool FalseFuncF16(Optional reasonIfUnsupported, Params&&... params) { IgnoreUnused(params...); SetValueChecked(reasonIfUnsupported, "Layer is not supported with float16 data type"); return false; } template bool FalseFuncF32(Optional reasonIfUnsupported, Params&&... params) { IgnoreUnused(params...); SetValueChecked(reasonIfUnsupported, "Layer is not supported with float32 data type"); return false; } template bool FalseFuncU8(Optional reasonIfUnsupported, Params&&... params) { IgnoreUnused(params...); SetValueChecked(reasonIfUnsupported, "Layer is not supported with 8-bit data type"); return false; } template bool FalseFuncI32(Optional reasonIfUnsupported, Params&&... params) { IgnoreUnused(params...); SetValueChecked(reasonIfUnsupported, "Layer is not supported with int32 data type"); return false; } template bool FalseInputFuncF32(Optional reasonIfUnsupported, Params&&... params) { IgnoreUnused(params...); SetValueChecked(reasonIfUnsupported, "Layer is not supported with float32 data type input"); return false; } template bool FalseInputFuncF16(Optional reasonIfUnsupported, Params&&... params) { IgnoreUnused(params...); SetValueChecked(reasonIfUnsupported, "Layer is not supported with float16 data type input"); return false; } template bool FalseOutputFuncF32(Optional reasonIfUnsupported, Params&&... params) { IgnoreUnused(params...); SetValueChecked(reasonIfUnsupported, "Layer is not supported with float32 data type output"); return false; } template bool FalseOutputFuncF16(Optional reasonIfUnsupported, Params&&... params) { IgnoreUnused(params...); SetValueChecked(reasonIfUnsupported, "Layer is not supported with float16 data type output"); return false; } }