blob: caa67aca37e56a703c9b806310f16f9703e3c9fe [file] [log] [blame]
telsoa014fcda012018-03-09 14:13:49 +00001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
5#pragma once
6
Sadik Armagana097d2a2021-11-24 15:47:28 +00007#include <armnnTestUtils/TensorCopyUtils.hpp>
8#include <WorkloadTestUtils.hpp>
telsoa014fcda012018-03-09 14:13:49 +00009
Matthew Sloyan171214c2020-09-09 09:07:37 +010010#include <armnn/utility/NumericCast.hpp>
11
Sadik Armagana097d2a2021-11-24 15:47:28 +000012#include <TensorHelpers.hpp>
arovir0143095f32018-10-09 18:04:24 +010013
telsoa014fcda012018-03-09 14:13:49 +000014struct ActivationFixture
15{
16 ActivationFixture()
17 {
Sadik Armagan483c8112021-06-01 09:24:52 +010018 output.resize(batchSize * channels * height * width);
19 outputExpected.resize(batchSize * channels * height * width);
20 input.resize(batchSize * channels * height * width);
telsoa014fcda012018-03-09 14:13:49 +000021
22 unsigned int inputShape[] = { batchSize, channels, height, width };
23 unsigned int outputShape[] = { batchSize, channels, height, width };
24
25 inputTensorInfo = armnn::TensorInfo(4, inputShape, armnn::DataType::Float32);
26 outputTensorInfo = armnn::TensorInfo(4, outputShape, armnn::DataType::Float32);
27
Sadik Armagan483c8112021-06-01 09:24:52 +010028 input = MakeRandomTensor<float>(inputTensorInfo, 21453);
telsoa014fcda012018-03-09 14:13:49 +000029 }
30
31 unsigned int width = 17;
32 unsigned int height = 29;
33 unsigned int channels = 2;
34 unsigned int batchSize = 5;
35
Sadik Armagan483c8112021-06-01 09:24:52 +010036 std::vector<float> output;
37 std::vector<float> outputExpected;
38 std::vector<float> input;
telsoa014fcda012018-03-09 14:13:49 +000039
40 armnn::TensorInfo inputTensorInfo;
41 armnn::TensorInfo outputTensorInfo;
42
telsoa01c577f2c2018-08-31 09:22:23 +010043 // Parameters used by some of the activation functions.
telsoa014fcda012018-03-09 14:13:49 +000044 float a = 0.234f;
45 float b = -12.345f;
46};
47
48
49struct PositiveActivationFixture : public ActivationFixture
50{
51 PositiveActivationFixture()
52 {
Sadik Armagan483c8112021-06-01 09:24:52 +010053 input = MakeRandomTensor<float>(inputTensorInfo, 2342423, 0.0f, 1.0f);
telsoa014fcda012018-03-09 14:13:49 +000054 }
55};