blob: 03b76849e15879444bbc78c216d13e017bb98021 [file] [log] [blame]
Cian McGriskin160edb32023-07-25 14:15:45 +01001//
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
12namespace
13{
14using namespace armnn;
15armnn::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
28template <armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
29void TileEndToEnd(const std::vector<BackendId>& backends)
30{
31 float qScale = 1.0f;
32 int32_t qOffset = 0;
33 bool qConst = true;
34
Cian McGriskin3b3dcbf2023-07-26 11:52:47 +010035 const TensorShape inputTensorShape = { 6 };
36 const TensorShape outputTensorShape = { 30 };
Cian McGriskin160edb32023-07-25 14:15:45 +010037
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 McGriskin3b3dcbf2023-07-26 11:52:47 +010042 65, 144, 91, 161, 56, 73
Cian McGriskin160edb32023-07-25 14:15:45 +010043 }, qScale, qOffset);
44
45 std::vector<T> expectedOutputData = armnnUtils::QuantizedVector<T>({
Cian McGriskin3b3dcbf2023-07-26 11:52:47 +010046 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 McGriskin160edb32023-07-25 14:15:45 +010051 }, qScale, qOffset);
52
Cian McGriskin3b3dcbf2023-07-26 11:52:47 +010053 auto descriptor = armnn::TileDescriptor(std::vector<uint32_t>{ 5 });
Cian McGriskin160edb32023-07-25 14:15:45 +010054 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