blob: 066248f22ad17c13698b0ffde2725dfe8f78e350 [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 Charlinad1b3d72023-03-14 12:10:28 +000011#include <schema_generated.h>
Teresa Charlind5c0ed22022-04-25 18:23:41 +010012
13#include <doctest/doctest.h>
14
15namespace armnnDelegate
16{
17
18// GATHER_ND Operator
19void GatherNdUint8Test(std::vector<armnn::BackendId>& backends)
20{
21
Teresa Charlinbd22c7d2022-04-26 18:14:12 +010022 std::vector<int32_t> paramsShape{ 5, 2 };
23 std::vector<int32_t> indicesShape{ 3, 1 };
24 std::vector<int32_t> expectedOutputShape{ 3, 2 };
Teresa Charlind5c0ed22022-04-25 18:23:41 +010025
Teresa Charlinbd22c7d2022-04-26 18:14:12 +010026 std::vector<uint8_t> paramsValues{ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
27 std::vector<int32_t> indicesValues{ 1, 0, 4 };
28 std::vector<uint8_t> expectedOutputValues{ 3, 4, 1, 2, 9, 10 };
Teresa Charlind5c0ed22022-04-25 18:23:41 +010029
30 GatherNdTest<uint8_t>(::tflite::TensorType_UINT8,
31 backends,
32 paramsShape,
33 indicesShape,
34 expectedOutputShape,
35 paramsValues,
36 indicesValues,
37 expectedOutputValues);
38}
39
40void GatherNdFp32Test(std::vector<armnn::BackendId>& backends)
41{
Teresa Charlinbd22c7d2022-04-26 18:14:12 +010042 std::vector<int32_t> paramsShape{ 5, 2 };
43 std::vector<int32_t> indicesShape{ 3, 1 };
44 std::vector<int32_t> expectedOutputShape{ 3, 2 };
Teresa Charlind5c0ed22022-04-25 18:23:41 +010045
Teresa Charlinbd22c7d2022-04-26 18:14:12 +010046 std::vector<float> paramsValues{ 1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f, 9.9f, 10.10f };
47 std::vector<int32_t> indicesValues{ 1, 0, 4 };
48 std::vector<float> expectedOutputValues{ 3.3f, 4.4f, 1.1f, 2.2f, 9.9f, 10.10f };
Teresa Charlind5c0ed22022-04-25 18:23:41 +010049
50 GatherNdTest<float>(::tflite::TensorType_FLOAT32,
51 backends,
52 paramsShape,
53 indicesShape,
54 expectedOutputShape,
55 paramsValues,
56 indicesValues,
57 expectedOutputValues);
58}
59
60// GATHER_ND Test Suite
61TEST_SUITE("GATHER_ND_CpuRefTests")
62{
63
64TEST_CASE ("GATHER_ND_Uint8_CpuRef_Test")
65{
66 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
67 GatherNdUint8Test(backends);
68}
69
70TEST_CASE ("GATHER_ND_Fp32_CpuRef_Test")
71{
72 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
73 GatherNdFp32Test(backends);
74}
75
76}
77
78TEST_SUITE("GATHER_ND_CpuAccTests")
79{
80
81TEST_CASE ("GATHER_ND_Uint8_CpuAcc_Test")
82{
83 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuAcc};
84 GatherNdUint8Test(backends);
85}
86
87TEST_CASE ("GATHER_ND_Fp32_CpuAcc_Test")
88{
89 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuAcc};
90 GatherNdFp32Test(backends);
91}
92
93}
94
95TEST_SUITE("GATHER_ND_GpuAccTests")
96{
97
98TEST_CASE ("GATHER_ND_Uint8_GpuAcc_Test")
99{
100 std::vector<armnn::BackendId> backends = {armnn::Compute::GpuAcc};
101 GatherNdUint8Test(backends);
102}
103
104TEST_CASE ("GATHER_ND_Fp32_GpuAcc_Test")
105{
106 std::vector<armnn::BackendId> backends = {armnn::Compute::GpuAcc};
107 GatherNdFp32Test(backends);
108}
109
110}
111// End of GATHER_ND Test Suite
112
113} // namespace armnnDelegate