aboutsummaryrefslogtreecommitdiff
path: root/delegate/test/ExpandDimsTest.cpp
blob: 25d911db8aa58e4a3e7f2ae4bc73f426f536fb55 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//
// Copyright © 2023-2024 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include "RedefineTestHelper.hpp"

#include <doctest/doctest.h>

namespace armnnDelegate
{

void ExpandDimsSimpleTest()
{
    // Set input data
    std::vector<int32_t> inputShape  { 2, 2, 1 };
    std::vector<int32_t> outputShape { 1, 2, 2, 1 };
    std::vector<int32_t> axis { 0 };

    std::vector<float> inputValues = { 1, 2, 3, 4 };
    std::vector<float> expectedOutputValues = { 1, 2, 3, 4 };

    RedefineTest<float>(tflite::BuiltinOperator_EXPAND_DIMS,
                        ::tflite::TensorType_FLOAT32,
                        inputShape,
                        outputShape,
                        inputValues,
                        expectedOutputValues,
                        axis,
                        true);
}

void ExpandDimsWithNegativeAxisTest()
{
    // Set input data
    std::vector<int32_t> inputShape  { 1, 2, 2 };
    std::vector<int32_t> outputShape { 1, 2, 2, 1 };
    std::vector<int32_t> axis { -1 };

    std::vector<float> inputValues = { 1, 2, 3, 4 };
    std::vector<float> expectedOutputValues = { 1, 2, 3, 4 };

    RedefineTest<float>(tflite::BuiltinOperator_EXPAND_DIMS,
                        ::tflite::TensorType_FLOAT32,
                        inputShape,
                        outputShape,
                        inputValues,
                        expectedOutputValues,
                        axis,
                        true);
}

TEST_SUITE("ExpandDimsTests")
{

TEST_CASE ("ExpandDims_Simple_Test")
{
    ExpandDimsSimpleTest();
}

TEST_CASE ("ExpandDims_With_Negative_Axis_Test")
{
    ExpandDimsWithNegativeAxisTest();
}

} // TEST_SUITE("ExpandDimsTests")

} // namespace armnnDelegate