aboutsummaryrefslogtreecommitdiff
path: root/delegate/test/TileTest.cpp
blob: 32f5610bce535ea6a9004c089a1c991b3cbfa87d (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
86
87
88
89
//
// Copyright © 2023 Arm Ltd and Contributors. All rights reserved.
// SPDX-License-Identifier: MIT
//

#include "TileTestHelper.hpp"

#include <armnn_delegate.hpp>
#include <flatbuffers/flatbuffers.h>
#include <tensorflow/lite/interpreter.h>
#include <tensorflow/lite/kernels/register.h>
#include <tensorflow/lite/model.h>
#include <schema_generated.h>
#include <tensorflow/lite/version.h>
#include <doctest/doctest.h>

namespace armnnDelegate
{
void TileFloat32Test(std::vector<armnn::BackendId>& backends)
{
    // Set input data
    std::vector<float> inputValues =
    {
        0.f, 1.f, 2.f,
        3.f, 4.f, 5.f
    };

    // Set output data
    std::vector<float> expectedOutputValues =
    {
        0.f, 1.f, 2.f, 0.f, 1.f, 2.f,
        3.f, 4.f, 5.f, 3.f, 4.f, 5.f,

        0.f, 1.f, 2.f, 0.f, 1.f, 2.f,
        3.f, 4.f, 5.f, 3.f, 4.f, 5.f
    };

    // The multiples
    const std::vector<int32_t> multiplesValues = { 2, 2 };

    // Set shapes
    const std::vector<int32_t> inputShape = { 2, 3 };
    const std::vector<int32_t> multiplesShape = { 2 };
    const std::vector<int32_t> expectedOutputShape = { 4, 6 };

    TileFP32TestImpl(tflite::BuiltinOperator_TILE,
                     backends,
                     inputValues,
                     inputShape,
                     multiplesValues,
                     multiplesShape,
                     expectedOutputValues,
                     expectedOutputShape);
}

TEST_SUITE("TileTests_GpuAccTests")
{

    TEST_CASE ("Tile_Float32_GpuAcc_Test")
    {
        std::vector<armnn::BackendId> backends = { armnn::Compute::GpuAcc };
        TileFloat32Test(backends);
    }

} // TEST_SUITE("Tile_Float32_GpuAcc_Test")

TEST_SUITE("TileTests_CpuAccTests")
{

    TEST_CASE ("Tile_Float32_CpuAcc_Test")
    {
        std::vector<armnn::BackendId> backends = { armnn::Compute::CpuAcc };
        TileFloat32Test(backends);
    }

} // TEST_SUITE("Tile_Float32_CpuAcc_Test")

TEST_SUITE("TileTests_CpuRefTests")
{

    TEST_CASE ("Tile_Float32_CpuRef_Test")
    {
        std::vector<armnn::BackendId> backends = { armnn::Compute::CpuRef };
        TileFloat32Test(backends);
    }

} // TEST_SUITE("Tile_Float32_CpuRef_Test")

} // namespace armnnDelegate