aboutsummaryrefslogtreecommitdiff
path: root/src/backends/backendsCommon/test/ActivationFixture.hpp
blob: 879d7e2d950cf6fdb0b61fbb66101db32281c100 (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
//
// Copyright © 2017 Arm Ltd. All rights reserved.
// SPDX-License-Identifier: MIT
//
#pragma once

#include <armnnTestUtils/TensorCopyUtils.hpp>
#include <armnnTestUtils/WorkloadTestUtils.hpp>

#include <armnn/utility/NumericCast.hpp>

#include <armnnTestUtils/TensorHelpers.hpp>

struct ActivationFixture
{
    ActivationFixture()
    {
        output.resize(batchSize * channels * height * width);
        outputExpected.resize(batchSize * channels * height * width);
        input.resize(batchSize * channels * height * width);

        unsigned int inputShape[]  = { batchSize, channels, height, width };
        unsigned int outputShape[] = { batchSize, channels, height, width };

        inputTensorInfo = armnn::TensorInfo(4, inputShape, armnn::DataType::Float32);
        outputTensorInfo = armnn::TensorInfo(4, outputShape, armnn::DataType::Float32);

        input = MakeRandomTensor<float>(inputTensorInfo, 21453);
    }

    unsigned int width     = 17;
    unsigned int height    = 29;
    unsigned int channels  = 2;
    unsigned int batchSize = 5;

    std::vector<float> output;
    std::vector<float> outputExpected;
    std::vector<float> input;

    armnn::TensorInfo inputTensorInfo;
    armnn::TensorInfo outputTensorInfo;

    // Parameters used by some of the activation functions.
    float a = 0.234f;
    float b = -12.345f;
};


struct PositiveActivationFixture : public ActivationFixture
{
    PositiveActivationFixture()
    {
        input = MakeRandomTensor<float>(inputTensorInfo, 2342423, 0.0f, 1.0f);
    }
};