diff options
author | kevmay01 <kevin.may@arm.com> | 2019-01-24 14:05:09 +0000 |
---|---|---|
committer | kevmay01 <kevin.may@arm.com> | 2019-01-24 14:05:09 +0000 |
commit | 2b4d88e34ac1f965417fd236fd4786f26bae2042 (patch) | |
tree | 4518b52c6a22e33c4b467588a2843c9d5f1a9ee6 /src/backends/backendsCommon/test/ArithmeticTestImpl.hpp | |
parent | 94412aff782472be54dce4328e2ecee0225b3e97 (diff) | |
download | armnn-2b4d88e34ac1f965417fd236fd4786f26bae2042.tar.gz |
IVGCVSW-2503 Refactor RefElementwiseWorkload around Equal and Greater
* Remove Equal and Greater from RefElementwiseWorkload
* Create RefComparisonWorkload and add Equal and Greater
* Update ElementwiseFunction for different input/output types
* Update TfParser to create Equal/Greater with Boolean output
* Update relevant tests to check for Boolean comparison
Change-Id: I299b7f2121769c960ac0c6139764a5f3c89c9c32
Diffstat (limited to 'src/backends/backendsCommon/test/ArithmeticTestImpl.hpp')
-rw-r--r-- | src/backends/backendsCommon/test/ArithmeticTestImpl.hpp | 50 |
1 files changed, 28 insertions, 22 deletions
diff --git a/src/backends/backendsCommon/test/ArithmeticTestImpl.hpp b/src/backends/backendsCommon/test/ArithmeticTestImpl.hpp index 1d6cf1d99b..6f685ebb42 100644 --- a/src/backends/backendsCommon/test/ArithmeticTestImpl.hpp +++ b/src/backends/backendsCommon/test/ArithmeticTestImpl.hpp @@ -17,7 +17,7 @@ namespace { -template<typename armnn::DataType DataType> +template<armnn::DataType ArmnnTypeInput, armnn::DataType ArmnnTypeOutput> INetworkPtr CreateArithmeticNetwork(const std::vector<TensorShape>& inputShapes, const TensorShape& outputShape, const LayerType type, @@ -39,22 +39,25 @@ INetworkPtr CreateArithmeticNetwork(const std::vector<TensorShape>& inputShapes, for (unsigned int i = 0; i < inputShapes.size(); ++i) { - TensorInfo inputTensorInfo(inputShapes[i], DataType, qScale, qOffset); + TensorInfo inputTensorInfo(inputShapes[i], ArmnnTypeInput, qScale, qOffset); IConnectableLayer* input = net->AddInputLayer(boost::numeric_cast<LayerBindingId>(i)); Connect(input, arithmeticLayer, inputTensorInfo, 0, i); } - TensorInfo outputTensorInfo(outputShape, DataType, qScale, qOffset); + TensorInfo outputTensorInfo(outputShape, ArmnnTypeOutput, qScale, qOffset); IConnectableLayer* output = net->AddOutputLayer(0, "output"); Connect(arithmeticLayer, output, outputTensorInfo, 0, 0); return net; } -template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> +template<armnn::DataType ArmnnInputType, + armnn::DataType ArmnnOutputType, + typename TInput = armnn::ResolveType<ArmnnInputType>, + typename TOutput = armnn::ResolveType<ArmnnOutputType>> void ArithmeticSimpleEndToEnd(const std::vector<BackendId>& backends, const LayerType type, - const std::vector<T> expectedOutput) + const std::vector<TOutput> expectedOutput) { using namespace armnn; @@ -62,26 +65,29 @@ void ArithmeticSimpleEndToEnd(const std::vector<BackendId>& backends, const TensorShape& outputShape = { 2, 2, 2, 2 }; // Builds up the structure of the network - INetworkPtr net = CreateArithmeticNetwork<ArmnnType>(inputShapes, outputShape, type); + INetworkPtr net = CreateArithmeticNetwork<ArmnnInputType, ArmnnOutputType>(inputShapes, outputShape, type); BOOST_TEST_CHECKPOINT("create a network"); - const std::vector<T> input0({ 1, 1, 1, 1, 5, 5, 5, 5, - 3, 3, 3, 3, 4, 4, 4, 4 }); + const std::vector<TInput> input0({ 1, 1, 1, 1, 5, 5, 5, 5, + 3, 3, 3, 3, 4, 4, 4, 4 }); - const std::vector<T> input1({ 1, 1, 1, 1, 3, 3, 3, 3, - 5, 5, 5, 5, 4, 4, 4, 4 }); + const std::vector<TInput> input1({ 1, 1, 1, 1, 3, 3, 3, 3, + 5, 5, 5, 5, 4, 4, 4, 4 }); - std::map<int, std::vector<T>> inputTensorData = {{ 0, input0 }, { 1, input1 }}; - std::map<int, std::vector<T>> expectedOutputData = {{ 0, expectedOutput }}; + std::map<int, std::vector<TInput>> inputTensorData = {{ 0, input0 }, { 1, input1 }}; + std::map<int, std::vector<TOutput>> expectedOutputData = {{ 0, expectedOutput }}; - EndToEndLayerTestImpl<T>(move(net), inputTensorData, expectedOutputData, backends); + EndToEndLayerTestImpl<TInput, TOutput>(move(net), inputTensorData, expectedOutputData, backends); } -template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> +template<armnn::DataType ArmnnInputType, + armnn::DataType ArmnnOutputType, + typename TInput = armnn::ResolveType<ArmnnInputType>, + typename TOutput = armnn::ResolveType<ArmnnOutputType>> void ArithmeticBroadcastEndToEnd(const std::vector<BackendId>& backends, const LayerType type, - const std::vector<T> expectedOutput) + const std::vector<TOutput> expectedOutput) { using namespace armnn; @@ -89,19 +95,19 @@ void ArithmeticBroadcastEndToEnd(const std::vector<BackendId>& backends, const TensorShape& outputShape = { 1, 2, 2, 3 }; // Builds up the structure of the network - INetworkPtr net = CreateArithmeticNetwork<ArmnnType>(inputShapes, outputShape, type); + INetworkPtr net = CreateArithmeticNetwork<ArmnnInputType, ArmnnOutputType>(inputShapes, outputShape, type); BOOST_TEST_CHECKPOINT("create a network"); - const std::vector<T> input0({ 1, 2, 3, 1, 0, 6, - 7, 8, 9, 10, 11, 12 }); + const std::vector<TInput> input0({ 1, 2, 3, 1, 0, 6, + 7, 8, 9, 10, 11, 12 }); - const std::vector<T> input1({ 1, 1, 3 }); + const std::vector<TInput> input1({ 1, 1, 3 }); - std::map<int, std::vector<T>> inputTensorData = {{ 0, input0 }, { 1, input1 }}; - std::map<int, std::vector<T>> expectedOutputData = {{ 0, expectedOutput }}; + std::map<int, std::vector<TInput>> inputTensorData = {{ 0, input0 }, { 1, input1 }}; + std::map<int, std::vector<TOutput>> expectedOutputData = {{ 0, expectedOutput }}; - EndToEndLayerTestImpl<T>(move(net), inputTensorData, expectedOutputData, backends); + EndToEndLayerTestImpl<TInput, TOutput>(move(net), inputTensorData, expectedOutputData, backends); } } // anonymous namespace |