Teresa Charlin | 4408850 | 2020-07-27 11:27:19 +0100 | [diff] [blame] | 1 | // |
Mike Kelly | a9c3267 | 2023-12-04 17:23:09 +0000 | [diff] [blame] | 2 | // Copyright © 2020-2021,2023 Arm Ltd and Contributors. All rights reserved. |
Teresa Charlin | 4408850 | 2020-07-27 11:27:19 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
Sadik Armagan | a097d2a | 2021-11-24 15:47:28 +0000 | [diff] [blame] | 8 | #include <CommonTestUtils.hpp> |
Teresa Charlin | 4408850 | 2020-07-27 11:27:19 +0100 | [diff] [blame] | 9 | |
| 10 | #include <armnn/INetwork.hpp> |
| 11 | #include <armnn/TypesUtils.hpp> |
| 12 | |
| 13 | #include <ResolveType.hpp> |
| 14 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 15 | #include <doctest/doctest.h> |
| 16 | |
Teresa Charlin | 4408850 | 2020-07-27 11:27:19 +0100 | [diff] [blame] | 17 | namespace |
| 18 | { |
| 19 | |
| 20 | armnn::INetworkPtr CreateFillNetwork(const armnn::TensorInfo& inputTensorInfo, |
| 21 | const armnn::TensorInfo& outputTensorInfo, |
| 22 | armnn::FillDescriptor descriptor) |
| 23 | { |
| 24 | armnn::INetworkPtr network(armnn::INetwork::Create()); |
| 25 | |
| 26 | armnn::IConnectableLayer* inputLayer = network->AddInputLayer(0, "Input"); |
| 27 | armnn::IConnectableLayer* fillLayer = network->AddFillLayer(descriptor, "Fill"); |
| 28 | armnn::IConnectableLayer* outputLayer = network->AddOutputLayer(0, "Output"); |
| 29 | |
| 30 | Connect(inputLayer, fillLayer, inputTensorInfo, 0, 0); |
| 31 | Connect(fillLayer, outputLayer, outputTensorInfo, 0, 0); |
| 32 | |
| 33 | return network; |
| 34 | } |
| 35 | |
| 36 | template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> |
| 37 | void FillEndToEnd(const std::vector<armnn::BackendId>& backends) |
| 38 | { |
| 39 | using namespace armnn; |
| 40 | |
| 41 | FillDescriptor descriptor; |
| 42 | descriptor.m_Value = 9; |
| 43 | |
Teresa Charlin | 4b10fef | 2020-07-29 09:36:41 +0100 | [diff] [blame] | 44 | std::vector<int32_t> inputData { |
Teresa Charlin | 4408850 | 2020-07-27 11:27:19 +0100 | [diff] [blame] | 45 | 1, 1, 5, 3 |
| 46 | }; |
| 47 | |
Teresa Charlin | 4b10fef | 2020-07-29 09:36:41 +0100 | [diff] [blame] | 48 | std::vector<float> floatExpectedOutputData { |
Teresa Charlin | 4408850 | 2020-07-27 11:27:19 +0100 | [diff] [blame] | 49 | 9, 9, 9, 9, 9, |
| 50 | 9, 9, 9, 9, 9, |
| 51 | 9, 9, 9, 9, 9 |
| 52 | }; |
Teresa Charlin | 4b10fef | 2020-07-29 09:36:41 +0100 | [diff] [blame] | 53 | std::vector<T> expectedOutputData = armnnUtils::QuantizedVector<T>(floatExpectedOutputData); |
Teresa Charlin | 4408850 | 2020-07-27 11:27:19 +0100 | [diff] [blame] | 54 | |
Cathal Corbett | 5b8093c | 2021-10-22 11:12:07 +0100 | [diff] [blame] | 55 | TensorInfo inputInfo ({ 4 }, DataType::Signed32, 0.0f, 0, true); |
Teresa Charlin | 4408850 | 2020-07-27 11:27:19 +0100 | [diff] [blame] | 56 | TensorInfo outputInfo({ 1, 1, 5, 3 }, ArmnnType); |
| 57 | |
| 58 | armnn::INetworkPtr network = CreateFillNetwork(inputInfo, outputInfo, descriptor); |
| 59 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 60 | CHECK(network); |
Teresa Charlin | 4408850 | 2020-07-27 11:27:19 +0100 | [diff] [blame] | 61 | |
Teresa Charlin | 4b10fef | 2020-07-29 09:36:41 +0100 | [diff] [blame] | 62 | std::map<int, std::vector<int32_t>> inputTensorData = {{ 0, inputData }}; |
Teresa Charlin | 4408850 | 2020-07-27 11:27:19 +0100 | [diff] [blame] | 63 | std::map<int, std::vector<T>> expectedOutputTensorData = {{ 0, expectedOutputData }}; |
| 64 | |
Mike Kelly | a9c3267 | 2023-12-04 17:23:09 +0000 | [diff] [blame] | 65 | EndToEndLayerTestImpl<DataType::Signed32, ArmnnType>(std::move(network), |
Teresa Charlin | 4b10fef | 2020-07-29 09:36:41 +0100 | [diff] [blame] | 66 | inputTensorData, |
| 67 | expectedOutputTensorData, |
| 68 | backends); |
Teresa Charlin | 4408850 | 2020-07-27 11:27:19 +0100 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | } // anonymous namespace |