Cian McGriskin | 160edb3 | 2023-07-25 14:15:45 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2023 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | #pragma once |
| 6 | #include "armnn/INetwork.hpp" |
| 7 | #include "armnnUtils/QuantizeHelper.hpp" |
| 8 | #include <CommonTestUtils.hpp> |
| 9 | #include <ResolveType.hpp> |
| 10 | #include <doctest/doctest.h> |
| 11 | |
| 12 | namespace |
| 13 | { |
| 14 | using namespace armnn; |
| 15 | armnn::INetworkPtr CreateTileNetwork(TileDescriptor& descriptor, |
| 16 | const armnn::TensorInfo& inputInfo, |
| 17 | const armnn::TensorInfo& outputInfo) |
| 18 | { |
| 19 | INetworkPtr network(INetwork::Create()); |
| 20 | IConnectableLayer* inputLayer = network->AddInputLayer(0, "input"); |
| 21 | IConnectableLayer* tileLayer = network->AddTileLayer(descriptor, "tile"); |
| 22 | IConnectableLayer* outputLayer = network->AddOutputLayer(0, "output"); |
| 23 | Connect(inputLayer, tileLayer, inputInfo, 0, 0); |
| 24 | Connect(tileLayer, outputLayer, outputInfo, 0, 0); |
| 25 | return network; |
| 26 | } |
| 27 | |
| 28 | template <armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 29 | void TileEndToEnd(const std::vector<BackendId>& backends) |
| 30 | { |
| 31 | float qScale = 1.0f; |
| 32 | int32_t qOffset = 0; |
| 33 | bool qConst = true; |
| 34 | |
Cian McGriskin | 3b3dcbf | 2023-07-26 11:52:47 +0100 | [diff] [blame] | 35 | const TensorShape inputTensorShape = { 6 }; |
| 36 | const TensorShape outputTensorShape = { 30 }; |
Cian McGriskin | 160edb3 | 2023-07-25 14:15:45 +0100 | [diff] [blame] | 37 | |
| 38 | TensorInfo inputInfo (inputTensorShape, ArmnnType, qScale, qOffset, qConst); |
| 39 | TensorInfo outputInfo (outputTensorShape, ArmnnType,qScale, qOffset); |
| 40 | |
| 41 | std::vector<T> inputData = armnnUtils::QuantizedVector<T>({ |
Cian McGriskin | 3b3dcbf | 2023-07-26 11:52:47 +0100 | [diff] [blame] | 42 | 65, 144, 91, 161, 56, 73 |
Cian McGriskin | 160edb3 | 2023-07-25 14:15:45 +0100 | [diff] [blame] | 43 | }, qScale, qOffset); |
| 44 | |
| 45 | std::vector<T> expectedOutputData = armnnUtils::QuantizedVector<T>({ |
Cian McGriskin | 3b3dcbf | 2023-07-26 11:52:47 +0100 | [diff] [blame] | 46 | 65, 144, 91, 161, 56, 73, |
| 47 | 65, 144, 91, 161, 56, 73, |
| 48 | 65, 144, 91, 161, 56, 73, |
| 49 | 65, 144, 91, 161, 56, 73, |
| 50 | 65, 144, 91, 161, 56, 73 |
Cian McGriskin | 160edb3 | 2023-07-25 14:15:45 +0100 | [diff] [blame] | 51 | }, qScale, qOffset); |
| 52 | |
Cian McGriskin | 3b3dcbf | 2023-07-26 11:52:47 +0100 | [diff] [blame] | 53 | auto descriptor = armnn::TileDescriptor(std::vector<uint32_t>{ 5 }); |
Cian McGriskin | 160edb3 | 2023-07-25 14:15:45 +0100 | [diff] [blame] | 54 | INetworkPtr network = CreateTileNetwork(descriptor, inputInfo, outputInfo); |
| 55 | |
| 56 | std::map<int, std::vector<T>> inputTensor = { { 0, inputData } }; |
| 57 | std::map<int, std::vector<T>> expectedOutputTensor = { { 0, expectedOutputData } }; |
| 58 | EndToEndLayerTestImpl<ArmnnType, ArmnnType>(std::move(network), inputTensor, expectedOutputTensor, backends); |
| 59 | } |
| 60 | |
| 61 | } // anonymous namespace |