diff options
author | Cathal Corbett <cathal.corbett@arm.com> | 2022-11-15 12:56:16 +0000 |
---|---|---|
committer | Cathal Corbett <cathal.corbett@arm.com> | 2022-11-16 11:12:24 +0000 |
commit | bd18eab07a8f30492de1e462b1815189014cb8d5 (patch) | |
tree | 7c26e2ecb94ffa1ea67204e02011a8166931eb09 /src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp | |
parent | 194086f01bdd1af52ddd976eb5b4152255565127 (diff) | |
download | armnn-bd18eab07a8f30492de1e462b1815189014cb8d5.tar.gz |
IVGCVSW-7345 Add Pooling2d support to TOSA Reference Backend
Signed-off-by: Cathal Corbett <cathal.corbett@arm.com>
Change-Id: I73a47e513fe2d064ef233b121a68ef2edf0396dc
Diffstat (limited to 'src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp')
-rw-r--r-- | src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp | 128 |
1 files changed, 125 insertions, 3 deletions
diff --git a/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp b/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp index 47f31380a5..48eca344bc 100644 --- a/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp +++ b/src/backends/tosaReference/test/TosaRefLayerSupportTests.cpp @@ -57,9 +57,131 @@ TEST_CASE("IsLayerSupportedTosaReferenceAdditionUnsupported") reasonIfNotSupported); CHECK(!supported); - REQUIRE(reasonIfNotSupported.find("TOSA Reference Operator: 14 for input: Op_ADD_input0_") != std::string::npos); - REQUIRE(reasonIfNotSupported.find("TOSA Reference Operator: 14 for input: Op_ADD_input1_") != std::string::npos); - REQUIRE(reasonIfNotSupported.find("TOSA Reference Operator: 14 for output: Op_ADD_output0_") != std::string::npos); + REQUIRE(reasonIfNotSupported.find( + "TOSA Reference Operator: Op_ADD for input: Op_ADD_input0_") != std::string::npos); + REQUIRE(reasonIfNotSupported.find( + "TOSA Reference Operator: Op_ADD for input: Op_ADD_input1_") != std::string::npos); + REQUIRE(reasonIfNotSupported.find( + "TOSA Reference Operator: Op_ADD for output: Op_ADD_output0_") != std::string::npos); +} + +TEST_CASE("IsLayerSupportedTosaReferenceMaxPooling2d") +{ + armnn::TensorShape inShape = {1,1,3,4}; + armnn::TensorShape outShape = {1,1,3,4}; + armnn::TensorInfo in(inShape, armnn::DataType::Float32); + armnn::TensorInfo out(outShape, armnn::DataType::Float32); + + armnn::Pooling2dDescriptor desc; + armnn::TosaRefLayerSupport supportChecker; + std::string reasonIfNotSupported; + auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Pooling2d, + {in, out}, + desc, + armnn::EmptyOptional(), + armnn::EmptyOptional(), + reasonIfNotSupported); + + CHECK(supported); +} + +TEST_CASE("IsLayerSupportedTosaReferenceAvgPooling2d_IgnoreValue") +{ + armnn::TensorShape inShape = {1,1,3,4}; + armnn::TensorShape outShape = {1,1,3,4}; + armnn::TensorInfo in(inShape, armnn::DataType::Float32); + armnn::TensorInfo out(outShape, armnn::DataType::Float32); + + armnn::Pooling2dDescriptor desc; + desc.m_PaddingMethod = armnn::PaddingMethod::IgnoreValue; + desc.m_PoolType = armnn::PoolingAlgorithm::Average; + + armnn::TosaRefLayerSupport supportChecker; + std::string reasonIfNotSupported; + auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Pooling2d, + {in, out}, + desc, + armnn::EmptyOptional(), + armnn::EmptyOptional(), + reasonIfNotSupported); + + CHECK(supported); +} + +TEST_CASE("IsLayerSupportedTosaReferenceAvgPooling2d_InputOutputDatatypeDifferent") +{ + armnn::TensorShape inShape = {1,1,3,4}; + armnn::TensorShape outShape = {1,1,3,4}; + armnn::TensorInfo in(inShape, armnn::DataType::QAsymmS8); + armnn::TensorInfo out(outShape, armnn::DataType::Signed32); + + armnn::Pooling2dDescriptor desc; + desc.m_PaddingMethod = armnn::PaddingMethod::IgnoreValue; + desc.m_PoolType = armnn::PoolingAlgorithm::Average; + + armnn::TosaRefLayerSupport supportChecker; + std::string reasonIfNotSupported; + auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Pooling2d, + {in, out}, + desc, + armnn::EmptyOptional(), + armnn::EmptyOptional(), + reasonIfNotSupported); + + CHECK(supported); +} + +TEST_CASE("IsLayerSupportedTosaReferenceMaxPooling2dUnsupported") +{ + armnn::TensorShape inShape = {1,1,3,4}; + armnn::TensorShape outShape = {1,1,3,4}; + armnn::TensorInfo in(inShape, armnn::DataType::Signed64); + armnn::TensorInfo out(outShape, armnn::DataType::Signed64); + + armnn::Pooling2dDescriptor desc; + armnn::TosaRefLayerSupport supportChecker; + std::string reasonIfNotSupported; + auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Pooling2d, + {in, out}, + desc, + armnn::EmptyOptional(), + armnn::EmptyOptional(), + reasonIfNotSupported); + + CHECK(!supported); + REQUIRE(reasonIfNotSupported.find( + "TOSA Reference Operator: Op_MAX_POOL2D for input: Op_MAX_POOL2D_input0_") != std::string::npos); + REQUIRE(reasonIfNotSupported.find( + "TOSA Reference Operator: Op_MAX_POOL2D for output: Op_MAX_POOL2D_output0_") != std::string::npos); +} + +TEST_CASE("IsLayerSupportedTosaReferenceAvgPooling2dUnsupported_InputOutputDatatypeDifferent") +{ + armnn::TensorShape inShape = {1,1,3,4}; + armnn::TensorShape outShape = {1,1,3,4}; + armnn::TensorInfo in(inShape, armnn::DataType::Float32); + armnn::TensorInfo out(outShape, armnn::DataType::Float16); + + armnn::Pooling2dDescriptor desc; + desc.m_PaddingMethod = armnn::PaddingMethod::IgnoreValue; + desc.m_PoolType = armnn::PoolingAlgorithm::Average; + + armnn::TosaRefLayerSupport supportChecker; + std::string reasonIfNotSupported; + auto supported = supportChecker.IsLayerSupported(armnn::LayerType::Pooling2d, + {in, out}, + desc, + armnn::EmptyOptional(), + armnn::EmptyOptional(), + reasonIfNotSupported); + + CHECK(!supported); + REQUIRE(reasonIfNotSupported.find( + "TOSA Reference Operator: Op_AVG_POOL2D for input: Op_PAD_intermediate0_") != std::string::npos); + REQUIRE(reasonIfNotSupported.find( + " and output: Op_AVG_POOL2D_output0_") != std::string::npos); + REQUIRE(reasonIfNotSupported.find( + " has an unsupported input data type: 8 to output data type: 10") != std::string::npos); } } |