xref: /aosp_15_r20/external/armnn/delegate/test/RoundTest.cpp (revision 89c4ff92f2867872bb9e2354d150bf0c8c502810)
1 //
2 // Copyright © 2021, 2023 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #include "RoundTestHelper.hpp"
7 
8 #include <armnn_delegate.hpp>
9 
10 #include <flatbuffers/flatbuffers.h>
11 #include <schema_generated.h>
12 
13 #include <doctest/doctest.h>
14 
15 namespace armnnDelegate
16 {
17 
FloorFp32Test(std::vector<armnn::BackendId> & backends)18 void FloorFp32Test(std::vector<armnn::BackendId>& backends)
19 {
20     std::vector<int32_t> inputShape  {1, 3, 2, 3};
21     std::vector<int32_t> outputShape {1, 3, 2, 3};
22 
23     std::vector<float> inputValues { -37.5f, -15.2f, -8.76f, -2.0f, -1.5f, -1.3f, -0.5f, -0.4f, 0.0f,
24                                      1.0f, 0.4f, 0.5f, 1.3f, 1.5f, 2.0f, 8.76f, 15.2f, 37.5f };
25 
26     std::vector<float> expectedOutputValues { -38.0f, -16.0f, -9.0f, -2.0f, -2.0f, -2.0f, -1.0f, -1.0f, 0.0f,
27                                               1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 2.0f, 8.0f, 15.0f, 37.0f };
28 
29     RoundTest<float>(tflite::BuiltinOperator_FLOOR,
30                      ::tflite::TensorType_FLOAT32,
31                      backends,
32                      inputShape,
33                      inputValues,
34                      expectedOutputValues);
35 }
36 
37 // FLOOR Test Suite
38 TEST_SUITE("FLOOR_CpuRefTests")
39 {
40 
41 TEST_CASE ("FLOOR_Fp32_CpuRef_Test")
42 {
43     std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
44     FloorFp32Test(backends);
45 }
46 
47 }
48 
49 TEST_SUITE("FLOOR_CpuAccTests")
50 {
51 
52 TEST_CASE ("FLOOR_Fp32_CpuAcc_Test")
53 {
54     std::vector<armnn::BackendId> backends = {armnn::Compute::CpuAcc};
55     FloorFp32Test(backends);
56 }
57 
58 }
59 
60 TEST_SUITE("FLOOR_GpuAccTests")
61 {
62 
63 TEST_CASE ("FLOOR_Fp32_GpuAcc_Test")
64 {
65     std::vector<armnn::BackendId> backends = {armnn::Compute::GpuAcc};
66     FloorFp32Test(backends);
67 }
68 
69 }
70 // End of FLOOR Test Suite
71 
72 } // namespace armnnDelegate