1 // 2 // Copyright © 2017 Arm Ltd. All rights reserved. 3 // SPDX-License-Identifier: MIT 4 // 5 #pragma once 6 7 #include "TensorCopyUtils.hpp" 8 #include "WorkloadTestUtils.hpp" 9 10 #include <armnn/utility/NumericCast.hpp> 11 12 #include <test/TensorHelpers.hpp> 13 14 #include <boost/multi_array.hpp> 15 16 struct ActivationFixture 17 { ActivationFixtureActivationFixture18 ActivationFixture() 19 { 20 auto boostArrayExtents = boost::extents 21 [armnn::numeric_cast<boost::multi_array_types::extent_gen::index>(batchSize)] 22 [armnn::numeric_cast<boost::multi_array_types::extent_gen::index>(channels)] 23 [armnn::numeric_cast<boost::multi_array_types::extent_gen::index>(height)] 24 [armnn::numeric_cast<boost::multi_array_types::extent_gen::index>(width)]; 25 output.resize(boostArrayExtents); 26 outputExpected.resize(boostArrayExtents); 27 input.resize(boostArrayExtents); 28 29 unsigned int inputShape[] = { batchSize, channels, height, width }; 30 unsigned int outputShape[] = { batchSize, channels, height, width }; 31 32 inputTensorInfo = armnn::TensorInfo(4, inputShape, armnn::DataType::Float32); 33 outputTensorInfo = armnn::TensorInfo(4, outputShape, armnn::DataType::Float32); 34 35 input = MakeRandomTensor<float, 4>(inputTensorInfo, 21453); 36 } 37 38 unsigned int width = 17; 39 unsigned int height = 29; 40 unsigned int channels = 2; 41 unsigned int batchSize = 5; 42 43 boost::multi_array<float, 4> output; 44 boost::multi_array<float, 4> outputExpected; 45 boost::multi_array<float, 4> input; 46 47 armnn::TensorInfo inputTensorInfo; 48 armnn::TensorInfo outputTensorInfo; 49 50 // Parameters used by some of the activation functions. 51 float a = 0.234f; 52 float b = -12.345f; 53 }; 54 55 56 struct PositiveActivationFixture : public ActivationFixture 57 { PositiveActivationFixturePositiveActivationFixture58 PositiveActivationFixture() 59 { 60 input = MakeRandomTensor<float, 4>(inputTensorInfo, 2342423, 0.0f, 1.0f); 61 } 62 };