aboutsummaryrefslogtreecommitdiff
path: root/delegate/test/ResizeTest.cpp
blob: de042db512f745424f33adc0a96f09b982289367 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//
// Copyright © 2020, 2023-2024 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include "ResizeTestHelper.hpp"

#include <doctest/doctest.h>

namespace armnnDelegate
{

void ResizeBiliniarFloat32Test(const std::vector<armnn::BackendId>& backends = {})
{
    // Set input data
    std::vector<float> input1Values
        {
            0.0f, 1.0f, 2.0f,
            3.0f, 4.0f, 5.0f,
            6.0f, 7.0f, 8.0f
        };
    const std::vector<int32_t> input2NewShape { 5, 5 };

    // Calculate output data
    std::vector<float> expectedOutputValues
        {
            0.0f, 0.6f, 1.2f, 1.8f, 2.0f,
            1.8f, 2.4f, 3.0f, 3.6f, 3.8f,
            3.6f, 4.2f, 4.8f, 5.4f, 5.6f,
            5.4f, 6.0f, 6.6f, 7.2f, 7.4f,
            6.0f, 6.6f, 7.2f, 7.8f, 8.0f
        };

    const std::vector<int32_t> input1Shape { 1, 3, 3, 1 };
    const std::vector<int32_t> input2Shape { 2 };
    const std::vector<int32_t> expectedOutputShape = { 1, 5, 5, 1 };

    ResizeFP32TestImpl(tflite::BuiltinOperator_RESIZE_BILINEAR,
                       input1Values,
                       input1Shape,
                       input2NewShape,
                       input2Shape,
                       expectedOutputValues,
                       expectedOutputShape);
}

void ResizeNearestNeighbourFloat32Test(const std::vector<armnn::BackendId>& backends = {})
{
    // Set input data
    std::vector<float> input1Values {  1.0f, 2.0f, 3.0f, 4.0f }
    ;
    const std::vector<int32_t> input2NewShape { 1, 1 };

    // Calculate output data
    std::vector<float> expectedOutputValues { 1.0f };

    const std::vector<int32_t> input1Shape { 1, 2, 2, 1 };
    const std::vector<int32_t> input2Shape { 2 };
    const std::vector<int32_t> expectedOutputShape = { 1, 1, 1, 1 };

    ResizeFP32TestImpl(tflite::BuiltinOperator_RESIZE_NEAREST_NEIGHBOR,
                       input1Values,
                       input1Shape,
                       input2NewShape,
                       input2Shape,
                       expectedOutputValues,
                       expectedOutputShape);
}

TEST_SUITE("ResizeTestsTests")
{

TEST_CASE ("Resize_Biliniar_Float32_Test")
{
    ResizeBiliniarFloat32Test();
}

TEST_CASE ("Resize_NearestNeighbour_Float32_Test")
{
    ResizeNearestNeighbourFloat32Test();
}

} // TEST_SUITE("ResizeTestsTests")

} // namespace armnnDelegate