Teresa Charlin | 98427a1 | 2020-11-25 18:22:57 +0000 | [diff] [blame] | 1 | // |
Colm Donelan | 7bcae3c | 2024-01-22 10:07:14 +0000 | [diff] [blame] | 2 | // Copyright © 2020, 2023-2024 Arm Ltd and Contributors. All rights reserved. |
Teresa Charlin | 98427a1 | 2020-11-25 18:22:57 +0000 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "GatherTestHelper.hpp" |
| 7 | |
Teresa Charlin | 98427a1 | 2020-11-25 18:22:57 +0000 | [diff] [blame] | 8 | #include <doctest/doctest.h> |
| 9 | |
| 10 | namespace armnnDelegate |
| 11 | { |
| 12 | |
Colm Donelan | 7bcae3c | 2024-01-22 10:07:14 +0000 | [diff] [blame] | 13 | // Gather Operator |
| 14 | void GatherUint8Test() |
Teresa Charlin | 98427a1 | 2020-11-25 18:22:57 +0000 | [diff] [blame] | 15 | { |
| 16 | |
| 17 | std::vector<int32_t> paramsShape{8}; |
| 18 | std::vector<int32_t> indicesShape{3}; |
| 19 | std::vector<int32_t> expectedOutputShape{3}; |
| 20 | |
| 21 | int32_t axis = 0; |
| 22 | std::vector<uint8_t> paramsValues{1, 2, 3, 4, 5, 6, 7, 8}; |
| 23 | std::vector<int32_t> indicesValues{7, 6, 5}; |
| 24 | std::vector<uint8_t> expectedOutputValues{8, 7, 6}; |
| 25 | |
| 26 | GatherTest<uint8_t>(::tflite::TensorType_UINT8, |
Teresa Charlin | 98427a1 | 2020-11-25 18:22:57 +0000 | [diff] [blame] | 27 | paramsShape, |
| 28 | indicesShape, |
| 29 | expectedOutputShape, |
| 30 | axis, |
| 31 | paramsValues, |
| 32 | indicesValues, |
| 33 | expectedOutputValues); |
| 34 | } |
| 35 | |
Colm Donelan | 7bcae3c | 2024-01-22 10:07:14 +0000 | [diff] [blame] | 36 | void GatherFp32Test() |
Teresa Charlin | 98427a1 | 2020-11-25 18:22:57 +0000 | [diff] [blame] | 37 | { |
| 38 | std::vector<int32_t> paramsShape{8}; |
| 39 | std::vector<int32_t> indicesShape{3}; |
| 40 | std::vector<int32_t> expectedOutputShape{3}; |
| 41 | |
| 42 | int32_t axis = 0; |
| 43 | std::vector<float> paramsValues{1.1f, 2.2f, 3.3f, 4.4f, 5.5f, 6.6f, 7.7f, 8.8f}; |
| 44 | std::vector<int32_t> indicesValues{7, 6, 5}; |
| 45 | std::vector<float> expectedOutputValues{8.8f, 7.7f, 6.6f}; |
| 46 | |
| 47 | GatherTest<float>(::tflite::TensorType_FLOAT32, |
Teresa Charlin | 98427a1 | 2020-11-25 18:22:57 +0000 | [diff] [blame] | 48 | paramsShape, |
| 49 | indicesShape, |
| 50 | expectedOutputShape, |
| 51 | axis, |
| 52 | paramsValues, |
| 53 | indicesValues, |
| 54 | expectedOutputValues); |
| 55 | } |
| 56 | |
Colm Donelan | 7bcae3c | 2024-01-22 10:07:14 +0000 | [diff] [blame] | 57 | // Gather Test Suite |
| 58 | TEST_SUITE("GatherTests") |
Teresa Charlin | 98427a1 | 2020-11-25 18:22:57 +0000 | [diff] [blame] | 59 | { |
| 60 | |
Colm Donelan | 7bcae3c | 2024-01-22 10:07:14 +0000 | [diff] [blame] | 61 | TEST_CASE ("Gather_Uint8_Test") |
Teresa Charlin | 98427a1 | 2020-11-25 18:22:57 +0000 | [diff] [blame] | 62 | { |
Colm Donelan | 7bcae3c | 2024-01-22 10:07:14 +0000 | [diff] [blame] | 63 | GatherUint8Test(); |
Teresa Charlin | 98427a1 | 2020-11-25 18:22:57 +0000 | [diff] [blame] | 64 | } |
| 65 | |
Colm Donelan | 7bcae3c | 2024-01-22 10:07:14 +0000 | [diff] [blame] | 66 | TEST_CASE ("Gather_Fp32_Test") |
Teresa Charlin | 98427a1 | 2020-11-25 18:22:57 +0000 | [diff] [blame] | 67 | { |
Colm Donelan | 7bcae3c | 2024-01-22 10:07:14 +0000 | [diff] [blame] | 68 | GatherFp32Test(); |
Teresa Charlin | 98427a1 | 2020-11-25 18:22:57 +0000 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | } |
Colm Donelan | 7bcae3c | 2024-01-22 10:07:14 +0000 | [diff] [blame] | 72 | // End of Gather Test Suite |
Teresa Charlin | 98427a1 | 2020-11-25 18:22:57 +0000 | [diff] [blame] | 73 | |
| 74 | } // namespace armnnDelegate |