blob: 9e54f735f816f136b0e20079477f0d5bffaa8846 [file] [log] [blame]
Jan Eilers2ffddda2021-02-03 09:14:30 +00001//
Teresa Charlinad1b3d72023-03-14 12:10:28 +00002// Copyright © 2022-2023 Arm Ltd and Contributors. All rights reserved.
Jan Eilers2ffddda2021-02-03 09:14:30 +00003// SPDX-License-Identifier: MIT
4//
5
6#include "SliceTestHelper.hpp"
7
8#include <armnn_delegate.hpp>
9
10#include <flatbuffers/flatbuffers.h>
Jan Eilers2ffddda2021-02-03 09:14:30 +000011
12#include <doctest/doctest.h>
13
14namespace armnnDelegate
15{
16
Cathal Corbett839b9322022-11-18 08:52:18 +000017void SliceFixtureSimpleTest(std::vector<armnn::BackendId>& backends)
Jan Eilers2ffddda2021-02-03 09:14:30 +000018{
Cathal Corbett839b9322022-11-18 08:52:18 +000019 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 };
Jan Eilers2ffddda2021-02-03 09:14:30 +000023
Cathal Corbett839b9322022-11-18 08:52:18 +000024 std::vector<int32_t> beginData { 1, 0, 0 };
25 std::vector<int32_t> sizeData { 2, 1, 3 };
Jan Eilers2ffddda2021-02-03 09:14:30 +000026 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 };
Cathal Corbett839b9322022-11-18 08:52:18 +000029 std::vector<float> outputData { 3.0f, 3.0f, 3.0f,
30 5.0f, 5.0f, 5.0f };
Jan Eilers2ffddda2021-02-03 09:14:30 +000031
Cathal Corbett839b9322022-11-18 08:52:18 +000032 SliceTestImpl<float>(
33 backends,
34 inputData,
35 outputData,
36 beginData,
37 sizeData,
38 inputShape,
39 beginShape,
40 sizeShape,
41 outputShape);
Jan Eilers2ffddda2021-02-03 09:14:30 +000042}
43
Mike Kelly04f71202023-05-05 15:35:18 +010044void SliceFixtureSizeTest(std::vector<armnn::BackendId>& backends)
45{
46 std::vector<int32_t> inputShape { 3, 2, 3 };
47 std::vector<int32_t> outputShape { 2, 1, 3 };
48 std::vector<int32_t> beginShape { 3 };
49 std::vector<int32_t> sizeShape { 3 };
50
51 std::vector<int32_t> beginData { 1, 0, 0 };
52 std::vector<int32_t> sizeData { 2, 1, -1 };
53 std::vector<float> inputData { 1.0f, 1.0f, 1.0f, 2.0f, 2.0f, 2.0f,
54 3.0f, 3.0f, 3.0f, 4.0f, 4.0f, 4.0f,
55 5.0f, 5.0f, 5.0f, 6.0f, 6.0f, 6.0f };
56 std::vector<float> outputData { 3.0f, 3.0f, 3.0f,
57 5.0f, 5.0f, 5.0f };
58
59 SliceTestImpl<float>(
60 backends,
61 inputData,
62 outputData,
63 beginData,
64 sizeData,
65 inputShape,
66 beginShape,
67 sizeShape,
68 outputShape);
69}
70
Cathal Corbett839b9322022-11-18 08:52:18 +000071TEST_SUITE("Slice_CpuRefTests")
Jan Eilers2ffddda2021-02-03 09:14:30 +000072{
73
Cathal Corbett839b9322022-11-18 08:52:18 +000074TEST_CASE ("Slice_Simple_CpuRef_Test")
Jan Eilers2ffddda2021-02-03 09:14:30 +000075{
76 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
Cathal Corbett839b9322022-11-18 08:52:18 +000077 SliceFixtureSimpleTest(backends);
Jan Eilers2ffddda2021-02-03 09:14:30 +000078}
79
Mike Kelly04f71202023-05-05 15:35:18 +010080TEST_CASE ("Slice_Size_CpuRef_Test")
81{
82 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
83 SliceFixtureSizeTest(backends);
84}
85
Cathal Corbett839b9322022-11-18 08:52:18 +000086} // Slice_CpuRefTests TestSuite
87
Cathal Corbett839b9322022-11-18 08:52:18 +000088TEST_SUITE("Slice_CpuAccTests")
89{
90
91TEST_CASE ("Slice_Simple_CpuAcc_Test")
Jan Eilers2ffddda2021-02-03 09:14:30 +000092{
Mike Kelly04f71202023-05-05 15:35:18 +010093 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuAcc};
Cathal Corbett839b9322022-11-18 08:52:18 +000094 SliceFixtureSimpleTest(backends);
Jan Eilers2ffddda2021-02-03 09:14:30 +000095}
96
Mike Kelly04f71202023-05-05 15:35:18 +010097TEST_CASE ("Slice_Size_CpuAcc_Test")
98{
99 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuAcc};
100 SliceFixtureSizeTest(backends);
101}
102
Cathal Corbett839b9322022-11-18 08:52:18 +0000103} // Slice_CpuAccTests TestSuite
Jan Eilers2ffddda2021-02-03 09:14:30 +0000104
Jan Eilers2ffddda2021-02-03 09:14:30 +0000105TEST_SUITE("StridedSlice_GpuAccTests")
106{
107
Cathal Corbett839b9322022-11-18 08:52:18 +0000108TEST_CASE ("Slice_Simple_GpuAcc_Test")
Jan Eilers2ffddda2021-02-03 09:14:30 +0000109{
Mike Kelly04f71202023-05-05 15:35:18 +0100110 std::vector<armnn::BackendId> backends = {armnn::Compute::GpuAcc};
Cathal Corbett839b9322022-11-18 08:52:18 +0000111 SliceFixtureSimpleTest(backends);
Jan Eilers2ffddda2021-02-03 09:14:30 +0000112}
113
Mike Kelly04f71202023-05-05 15:35:18 +0100114TEST_CASE ("Slice_Size_GpuAcc_Test")
115{
116 std::vector<armnn::BackendId> backends = {armnn::Compute::GpuAcc};
117 SliceFixtureSizeTest(backends);
118}
119
Cathal Corbett839b9322022-11-18 08:52:18 +0000120} // Slice_GpuAccTests TestSuite
Jan Eilers2ffddda2021-02-03 09:14:30 +0000121
122} // namespace armnnDelegate