blob: 88a70de03f45ee04ed6cff3b4b069fd868b25401 [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
Cathal Corbett839b9322022-11-18 08:52:18 +000044TEST_SUITE("Slice_CpuRefTests")
Jan Eilers2ffddda2021-02-03 09:14:30 +000045{
46
Cathal Corbett839b9322022-11-18 08:52:18 +000047TEST_CASE ("Slice_Simple_CpuRef_Test")
Jan Eilers2ffddda2021-02-03 09:14:30 +000048{
49 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
Cathal Corbett839b9322022-11-18 08:52:18 +000050 SliceFixtureSimpleTest(backends);
Jan Eilers2ffddda2021-02-03 09:14:30 +000051}
52
Cathal Corbett839b9322022-11-18 08:52:18 +000053} // Slice_CpuRefTests TestSuite
54
55
56
57TEST_SUITE("Slice_CpuAccTests")
58{
59
60TEST_CASE ("Slice_Simple_CpuAcc_Test")
Jan Eilers2ffddda2021-02-03 09:14:30 +000061{
62 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
Cathal Corbett839b9322022-11-18 08:52:18 +000063 SliceFixtureSimpleTest(backends);
Jan Eilers2ffddda2021-02-03 09:14:30 +000064}
65
Cathal Corbett839b9322022-11-18 08:52:18 +000066} // Slice_CpuAccTests TestSuite
Jan Eilers2ffddda2021-02-03 09:14:30 +000067
68
69
70TEST_SUITE("StridedSlice_GpuAccTests")
71{
72
Cathal Corbett839b9322022-11-18 08:52:18 +000073TEST_CASE ("Slice_Simple_GpuAcc_Test")
Jan Eilers2ffddda2021-02-03 09:14:30 +000074{
Cathal Corbett839b9322022-11-18 08:52:18 +000075 std::vector<armnn::BackendId> backends = {armnn::Compute::CpuRef};
76 SliceFixtureSimpleTest(backends);
Jan Eilers2ffddda2021-02-03 09:14:30 +000077}
78
Cathal Corbett839b9322022-11-18 08:52:18 +000079} // Slice_GpuAccTests TestSuite
Jan Eilers2ffddda2021-02-03 09:14:30 +000080
81} // namespace armnnDelegate