blob: c49c10d054a227dd3e723f601a71baf0c42103c9 [file] [log] [blame]
Teresa Charlin98427a12020-11-25 18:22:57 +00001//
Teresa Charlinad1b3d72023-03-14 12:10:28 +00002// Copyright © 2020, 2023 Arm Ltd and Contributors. All rights reserved.
Teresa Charlin98427a12020-11-25 18:22:57 +00003// SPDX-License-Identifier: MIT
4//
5
6#include "GatherTestHelper.hpp"
7
8#include <armnn_delegate.hpp>
9
10#include <flatbuffers/flatbuffers.h>
Teresa Charlin98427a12020-11-25 18:22:57 +000011
12#include <doctest/doctest.h>
13
14namespace armnnDelegate
15{
16
17// GATHER Operator
18void GatherUint8Test(std::vector<armnn::BackendId>& backends)
19{
20
21 std::vector<int32_t> paramsShape{8};
22 std::vector<int32_t> indicesShape{3};
23 std::vector<int32_t> expectedOutputShape{3};
24
25 int32_t axis = 0;
26 std::vector<uint8_t> paramsValues{1, 2, 3, 4, 5, 6, 7, 8};
27 std::vector<int32_t> indicesValues{7, 6, 5};
28 std::vector<uint8_t> expectedOutputValues{8, 7, 6};
29
30 GatherTest<uint8_t>(::tflite::TensorType_UINT8,
31 backends,
32 paramsShape,
33 indicesShape,
34 expectedOutputShape,
35 axis,
36 paramsValues,
37 indicesValues,
38 expectedOutputValues);
39}
40
41void GatherFp32Test(std::vector<armnn::BackendId>& backends)
42{
43 std::vector<int32_t> paramsShape{8};
44 std::vector<int32_t> indicesShape{3};
45 std::vector<int32_t> expectedOutputShape{3};
46
47 int32_t axis = 0;
48 std::vector<float> paramsValues{1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f};
49 std::vector<int32_t> indicesValues{7, 6, 5};
50 std::vector<float> expectedOutputValues{8.8f, 7.7f, 6.6f};
51
52 GatherTest<float>(::tflite::TensorType_FLOAT32,
53 backends,
54 paramsShape,
55 indicesShape,
56 expectedOutputShape,
57 axis,
58 paramsValues,
59 indicesValues,
60 expectedOutputValues);
61}
62
63// GATHER Test Suite
64TEST_SUITE("GATHER_CpuRefTests")
65{
66
67TEST_CASE ("GATHER_Uint8_CpuRef_Test")
68{
69 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
70 GatherUint8Test(backends);
71}
72
73TEST_CASE ("GATHER_Fp32_CpuRef_Test")
74{
75 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
76 GatherFp32Test(backends);
77}
78
79}
80
81TEST_SUITE("GATHER_CpuAccTests")
82{
83
84TEST_CASE ("GATHER_Uint8_CpuAcc_Test")
85{
86 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuAcc};
87 GatherUint8Test(backends);
88}
89
90TEST_CASE ("GATHER_Fp32_CpuAcc_Test")
91{
92 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuAcc};
93 GatherFp32Test(backends);
94}
95
96}
97
98TEST_SUITE("GATHER_GpuAccTests")
99{
100
101TEST_CASE ("GATHER_Uint8_GpuAcc_Test")
102{
103 std::vector<armnn::BackendId> backends = {armnn::Compute::GpuAcc};
104 GatherUint8Test(backends);
105}
106
107TEST_CASE ("GATHER_Fp32_GpuAcc_Test")
108{
109 std::vector<armnn::BackendId> backends = {armnn::Compute::GpuAcc};
110 GatherFp32Test(backends);
111}
112
113}
114// End of GATHER Test Suite
115
116} // namespace armnnDelegate