blob: 25d911db8aa58e4a3e7f2ae4bc73f426f536fb55 [file] [log] [blame]
Matthew Sloyan3504e422023-05-03 13:53:02 +01001//
Colm Donelan7bcae3c2024-01-22 10:07:14 +00002// Copyright © 2023-2024 Arm Ltd and Contributors. All rights reserved.
Matthew Sloyan3504e422023-05-03 13:53:02 +01003// SPDX-License-Identifier: MIT
4//
5
6#include "RedefineTestHelper.hpp"
7
Colm Donelan7bcae3c2024-01-22 10:07:14 +00008#include <doctest/doctest.h>
9
Matthew Sloyan3504e422023-05-03 13:53:02 +010010namespace armnnDelegate
11{
12
Colm Donelan7bcae3c2024-01-22 10:07:14 +000013void ExpandDimsSimpleTest()
Matthew Sloyan3504e422023-05-03 13:53:02 +010014{
15 // Set input data
16 std::vector<int32_t> inputShape { 2, 2, 1 };
17 std::vector<int32_t> outputShape { 1, 2, 2, 1 };
18 std::vector<int32_t> axis { 0 };
19
20 std::vector<float> inputValues = { 1, 2, 3, 4 };
21 std::vector<float> expectedOutputValues = { 1, 2, 3, 4 };
22
23 RedefineTest<float>(tflite::BuiltinOperator_EXPAND_DIMS,
24 ::tflite::TensorType_FLOAT32,
Matthew Sloyan3504e422023-05-03 13:53:02 +010025 inputShape,
26 outputShape,
27 inputValues,
28 expectedOutputValues,
Colm Donelan7bcae3c2024-01-22 10:07:14 +000029 axis,
30 true);
Matthew Sloyan3504e422023-05-03 13:53:02 +010031}
32
Colm Donelan7bcae3c2024-01-22 10:07:14 +000033void ExpandDimsWithNegativeAxisTest()
Matthew Sloyan3504e422023-05-03 13:53:02 +010034{
35 // Set input data
36 std::vector<int32_t> inputShape { 1, 2, 2 };
37 std::vector<int32_t> outputShape { 1, 2, 2, 1 };
38 std::vector<int32_t> axis { -1 };
39
40 std::vector<float> inputValues = { 1, 2, 3, 4 };
41 std::vector<float> expectedOutputValues = { 1, 2, 3, 4 };
42
43 RedefineTest<float>(tflite::BuiltinOperator_EXPAND_DIMS,
44 ::tflite::TensorType_FLOAT32,
Matthew Sloyan3504e422023-05-03 13:53:02 +010045 inputShape,
46 outputShape,
47 inputValues,
48 expectedOutputValues,
Colm Donelan7bcae3c2024-01-22 10:07:14 +000049 axis,
50 true);
Matthew Sloyan3504e422023-05-03 13:53:02 +010051}
52
Colm Donelan7bcae3c2024-01-22 10:07:14 +000053TEST_SUITE("ExpandDimsTests")
Matthew Sloyan3504e422023-05-03 13:53:02 +010054{
55
Colm Donelan7bcae3c2024-01-22 10:07:14 +000056TEST_CASE ("ExpandDims_Simple_Test")
Matthew Sloyan3504e422023-05-03 13:53:02 +010057{
Colm Donelan7bcae3c2024-01-22 10:07:14 +000058 ExpandDimsSimpleTest();
Matthew Sloyan3504e422023-05-03 13:53:02 +010059}
60
Colm Donelan7bcae3c2024-01-22 10:07:14 +000061TEST_CASE ("ExpandDims_With_Negative_Axis_Test")
Matthew Sloyan3504e422023-05-03 13:53:02 +010062{
Colm Donelan7bcae3c2024-01-22 10:07:14 +000063 ExpandDimsWithNegativeAxisTest();
Matthew Sloyan3504e422023-05-03 13:53:02 +010064}
65
Colm Donelan7bcae3c2024-01-22 10:07:14 +000066} // TEST_SUITE("ExpandDimsTests")
Matthew Sloyan3504e422023-05-03 13:53:02 +010067
68} // namespace armnnDelegate