blob: 26dc332239d1baa7c907f572e0681ab99668826f [file] [log] [blame]
Teresa Charlind5c0ed22022-04-25 18:23:41 +01001//
Teresa Charlinad1b3d72023-03-14 12:10:28 +00002// Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved.
Teresa Charlind5c0ed22022-04-25 18:23:41 +01003// SPDX-License-Identifier: MIT
4//
5
6#include "GatherNdTestHelper.hpp"
7
8#include <armnn_delegate.hpp>
9
10#include <flatbuffers/flatbuffers.h>
Teresa Charlind5c0ed22022-04-25 18:23:41 +010011
12#include <doctest/doctest.h>
13
14namespace armnnDelegate
15{
16
17// GATHER_ND Operator
18void GatherNdUint8Test(std::vector<armnn::BackendId>& backends)
19{
20
Teresa Charlinbd22c7d2022-04-26 18:14:12 +010021 std::vector<int32_t> paramsShape{ 5, 2 };
22 std::vector<int32_t> indicesShape{ 3, 1 };
23 std::vector<int32_t> expectedOutputShape{ 3, 2 };
Teresa Charlind5c0ed22022-04-25 18:23:41 +010024
Teresa Charlinbd22c7d2022-04-26 18:14:12 +010025 std::vector<uint8_t> paramsValues{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
26 std::vector<int32_t> indicesValues{ 1, 0, 4 };
27 std::vector<uint8_t> expectedOutputValues{ 3, 4, 1, 2, 9, 10 };
Teresa Charlind5c0ed22022-04-25 18:23:41 +010028
29 GatherNdTest<uint8_t>(::tflite::TensorType_UINT8,
30 backends,
31 paramsShape,
32 indicesShape,
33 expectedOutputShape,
34 paramsValues,
35 indicesValues,
36 expectedOutputValues);
37}
38
39void GatherNdFp32Test(std::vector<armnn::BackendId>& backends)
40{
Teresa Charlinbd22c7d2022-04-26 18:14:12 +010041 std::vector<int32_t> paramsShape{ 5, 2 };
42 std::vector<int32_t> indicesShape{ 3, 1 };
43 std::vector<int32_t> expectedOutputShape{ 3, 2 };
Teresa Charlind5c0ed22022-04-25 18:23:41 +010044
Teresa Charlinbd22c7d2022-04-26 18:14:12 +010045 std::vector<float> paramsValues{ 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 10.10f };
46 std::vector<int32_t> indicesValues{ 1, 0, 4 };
47 std::vector<float> expectedOutputValues{ 3.3f, 4.4f, 1.1f, 2.2f, 9.9f, 10.10f };
Teresa Charlind5c0ed22022-04-25 18:23:41 +010048
49 GatherNdTest<float>(::tflite::TensorType_FLOAT32,
50 backends,
51 paramsShape,
52 indicesShape,
53 expectedOutputShape,
54 paramsValues,
55 indicesValues,
56 expectedOutputValues);
57}
58
59// GATHER_ND Test Suite
60TEST_SUITE("GATHER_ND_CpuRefTests")
61{
62
63TEST_CASE ("GATHER_ND_Uint8_CpuRef_Test")
64{
65 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
66 GatherNdUint8Test(backends);
67}
68
69TEST_CASE ("GATHER_ND_Fp32_CpuRef_Test")
70{
71 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
72 GatherNdFp32Test(backends);
73}
74
75}
76
77TEST_SUITE("GATHER_ND_CpuAccTests")
78{
79
80TEST_CASE ("GATHER_ND_Uint8_CpuAcc_Test")
81{
82 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuAcc};
83 GatherNdUint8Test(backends);
84}
85
86TEST_CASE ("GATHER_ND_Fp32_CpuAcc_Test")
87{
88 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuAcc};
89 GatherNdFp32Test(backends);
90}
91
92}
93
94TEST_SUITE("GATHER_ND_GpuAccTests")
95{
96
97TEST_CASE ("GATHER_ND_Uint8_GpuAcc_Test")
98{
99 std::vector<armnn::BackendId> backends = {armnn::Compute::GpuAcc};
100 GatherNdUint8Test(backends);
101}
102
103TEST_CASE ("GATHER_ND_Fp32_GpuAcc_Test")
104{
105 std::vector<armnn::BackendId> backends = {armnn::Compute::GpuAcc};
106 GatherNdFp32Test(backends);
107}
108
109}
110// End of GATHER_ND Test Suite
111
112} // namespace armnnDelegate