1 //
2 // Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include "SliceTestHelper.hpp"
7
8 #include <armnn_delegate.hpp>
9
10 #include <flatbuffers/flatbuffers.h>
11
12 #include <doctest/doctest.h>
13
14 namespace armnnDelegate
15 {
16
SliceFixtureSimpleTest(std::vector<armnn::BackendId> & backends)17 void SliceFixtureSimpleTest(std::vector<armnn::BackendId>& backends)
18 {
19 std::vector<int32_t> inputShape { 3, 2, 3 };
20 std::vector<int32_t> outputShape { 2, 1, 3 };
21 std::vector<int32_t> beginShape { 3 };
22 std::vector<int32_t> sizeShape { 3 };
23
24 std::vector<int32_t> beginData { 1, 0, 0 };
25 std::vector<int32_t> sizeData { 2, 1, 3 };
26 std::vector<float> inputData { 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f,
27 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 4.0f,
28 5.0f, 5.0f, 5.0f, 6.0f, 6.0f, 6.0f };
29 std::vector<float> outputData { 3.0f, 3.0f, 3.0f,
30 5.0f, 5.0f, 5.0f };
31
32 SliceTestImpl<float>(
33 backends,
34 inputData,
35 outputData,
36 beginData,
37 sizeData,
38 inputShape,
39 beginShape,
40 sizeShape,
41 outputShape);
42 }
43
44 TEST_SUITE("Slice_CpuRefTests")
45 {
46
47 TEST_CASE ("Slice_Simple_CpuRef_Test")
48 {
49 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
50 SliceFixtureSimpleTest(backends);
51 }
52
53 } // Slice_CpuRefTests TestSuite
54
55
56
57 TEST_SUITE("Slice_CpuAccTests")
58 {
59
60 TEST_CASE ("Slice_Simple_CpuAcc_Test")
61 {
62 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
63 SliceFixtureSimpleTest(backends);
64 }
65
66 } // Slice_CpuAccTests TestSuite
67
68
69
70 TEST_SUITE("StridedSlice_GpuAccTests")
71 {
72
73 TEST_CASE ("Slice_Simple_GpuAcc_Test")
74 {
75 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
76 SliceFixtureSimpleTest(backends);
77 }
78
79 } // Slice_GpuAccTests TestSuite
80
81 } // namespace armnnDelegate