Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 ARM Limited. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #ifndef __ARM_COMPUTE_TEST_DATASET_ACTIVATION_LAYER_DATASET_H__ |
| 25 | #define __ARM_COMPUTE_TEST_DATASET_ACTIVATION_LAYER_DATASET_H__ |
| 26 | |
| 27 | #include "TypePrinter.h" |
| 28 | |
| 29 | #include "arm_compute/core/TensorShape.h" |
| 30 | #include "arm_compute/core/Types.h" |
| 31 | #include "dataset/GenericDataset.h" |
| 32 | |
| 33 | #include <sstream> |
| 34 | #include <type_traits> |
| 35 | |
| 36 | #ifdef BOOST |
| 37 | #include "boost_wrapper.h" |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 38 | #endif /* BOOST */ |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 39 | |
| 40 | namespace arm_compute |
| 41 | { |
| 42 | namespace test |
| 43 | { |
| 44 | class ActivationLayerDataObject |
| 45 | { |
| 46 | public: |
| 47 | operator std::string() const |
| 48 | { |
| 49 | std::stringstream ss; |
| 50 | ss << "ActivationLayer"; |
| 51 | ss << "_I" << shape; |
| 52 | ss << "_F_" << info.activation(); |
| 53 | return ss.str(); |
| 54 | } |
| 55 | |
| 56 | public: |
| 57 | TensorShape shape; |
| 58 | ActivationLayerInfo info; |
| 59 | }; |
| 60 | |
| 61 | template <unsigned int Size> |
| 62 | using ActivationLayerDataset = GenericDataset<ActivationLayerDataObject, Size>; |
| 63 | |
| 64 | class AlexNetActivationLayerDataset final : public ActivationLayerDataset<5> |
| 65 | { |
| 66 | public: |
| 67 | AlexNetActivationLayerDataset() |
| 68 | : GenericDataset |
| 69 | { |
| 70 | ActivationLayerDataObject{ TensorShape(55U, 55U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 71 | ActivationLayerDataObject{ TensorShape(27U, 27U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 72 | ActivationLayerDataObject{ TensorShape(13U, 13U, 384U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 73 | ActivationLayerDataObject{ TensorShape(13U, 13U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 74 | ActivationLayerDataObject{ TensorShape(4096U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 75 | } |
| 76 | { |
| 77 | } |
| 78 | |
| 79 | ~AlexNetActivationLayerDataset() = default; |
| 80 | }; |
| 81 | |
| 82 | class LeNet5ActivationLayerDataset final : public ActivationLayerDataset<1> |
| 83 | { |
| 84 | public: |
| 85 | LeNet5ActivationLayerDataset() |
| 86 | : GenericDataset |
| 87 | { |
| 88 | ActivationLayerDataObject{ TensorShape(500U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 89 | } |
| 90 | { |
| 91 | } |
| 92 | |
| 93 | ~LeNet5ActivationLayerDataset() = default; |
| 94 | }; |
| 95 | |
| 96 | class GoogLeNetActivationLayerDataset final : public ActivationLayerDataset<33> |
| 97 | { |
| 98 | public: |
| 99 | GoogLeNetActivationLayerDataset() |
| 100 | : GenericDataset |
| 101 | { |
| 102 | // conv1/relu_7x7 |
| 103 | ActivationLayerDataObject{ TensorShape(112U, 112U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 104 | // conv2/relu_3x3_reduce |
| 105 | ActivationLayerDataObject{ TensorShape(56U, 56U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 106 | // conv2/relu_3x3 |
| 107 | ActivationLayerDataObject{ TensorShape(56U, 56U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 108 | // inception_3a/relu_1x1, inception_3b/relu_pool_proj |
| 109 | ActivationLayerDataObject{ TensorShape(28U, 28U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 110 | // inception_3a/relu_3x3_reduce, inception_3b/relu_5x5 |
| 111 | ActivationLayerDataObject{ TensorShape(28U, 28U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 112 | // inception_3a/relu_3x3, inception_3b/relu_1x1, inception_3b/relu_3x3_reduce |
| 113 | ActivationLayerDataObject{ TensorShape(28U, 28U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 114 | // inception_3a/relu_5x5_reduce |
| 115 | ActivationLayerDataObject{ TensorShape(28U, 28U, 16U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 116 | // inception_3a/relu_5x5, inception_3a/relu_pool_proj, inception_3b/relu_5x5_reduce |
| 117 | ActivationLayerDataObject{ TensorShape(28U, 28U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 118 | // inception_3b/relu_3x3 |
| 119 | ActivationLayerDataObject{ TensorShape(28U, 28U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 120 | // inception_4a/relu_1x1 |
| 121 | ActivationLayerDataObject{ TensorShape(14U, 14U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 122 | // inception_4a/relu_3x3_reduce |
| 123 | ActivationLayerDataObject{ TensorShape(14U, 14U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 124 | // inception_4a/relu_3x3 |
| 125 | ActivationLayerDataObject{ TensorShape(14U, 14U, 208U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 126 | // inception_4a/relu_5x5_reduce |
| 127 | ActivationLayerDataObject{ TensorShape(14U, 14U, 16U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 128 | // inception_4a/relu_5x5 |
| 129 | ActivationLayerDataObject{ TensorShape(14U, 14U, 48U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 130 | // inception_4a/relu_pool_proj, inception_4b/relu_5x5, inception_4b/relu_pool_proj, inception_4c/relu_5x5, inception_4c/relu_pool_proj, inception_4d/relu_5x5, inception_4d/relu_pool_proj |
| 131 | ActivationLayerDataObject{ TensorShape(14U, 14U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 132 | // inception_4b/relu_1x1, inception_4e/relu_3x3_reduce |
| 133 | ActivationLayerDataObject{ TensorShape(14U, 14U, 160U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 134 | // inception_4b/relu_3x3_reduce, inception_4d/relu_1x1 |
| 135 | ActivationLayerDataObject{ TensorShape(14U, 14U, 112U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 136 | // inception_4b/relu_3x3 |
| 137 | ActivationLayerDataObject{ TensorShape(14U, 14U, 224U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 138 | // inception_4b/relu_5x5_reduce, inception_4c/relu_5x5_reduce |
| 139 | ActivationLayerDataObject{ TensorShape(14U, 14U, 24U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 140 | // inception_4c/relu_1x1, inception_4c/relu_3x3_reduce, inception_4e/relu_5x5, inception_4e/relu_pool_proj |
| 141 | ActivationLayerDataObject{ TensorShape(14U, 14U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 142 | // inception_4c/relu_3x3, inception_4e/relu_1x1 |
| 143 | ActivationLayerDataObject{ TensorShape(14U, 14U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 144 | // inception_4d/relu_3x3_reduce |
| 145 | ActivationLayerDataObject{ TensorShape(14U, 14U, 144U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 146 | // inception_4d/relu_3x3 |
| 147 | ActivationLayerDataObject{ TensorShape(14U, 14U, 288U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 148 | // inception_4d/relu_5x5_reduce, inception_4e/relu_5x5_reduce |
| 149 | ActivationLayerDataObject{ TensorShape(14U, 14U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 150 | // inception_4e/relu_3x3 |
| 151 | ActivationLayerDataObject{ TensorShape(14U, 14U, 320U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 152 | // inception_5a/relu_1x1 |
| 153 | ActivationLayerDataObject{ TensorShape(7U, 7U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 154 | // inception_5a/relu_3x3_reduce |
| 155 | ActivationLayerDataObject{ TensorShape(7U, 7U, 160U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 156 | // inception_5a/relu_3x3 |
| 157 | ActivationLayerDataObject{ TensorShape(7U, 7U, 320U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 158 | // inception_5a/relu_5x5_reduce |
| 159 | ActivationLayerDataObject{ TensorShape(7U, 7U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 160 | // inception_5a/relu_5x5, inception_5a/relu_pool_proj, inception_5b/relu_5x5, inception_5b/relu_pool_proj |
| 161 | ActivationLayerDataObject{ TensorShape(7U, 7U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 162 | // inception_5b/relu_1x1, inception_5b/relu_3x3 |
| 163 | ActivationLayerDataObject{ TensorShape(7U, 7U, 384U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 164 | // inception_5b/relu_3x3_reduce |
| 165 | ActivationLayerDataObject{ TensorShape(7U, 7U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, |
| 166 | // inception_5b/relu_5x5_reduce |
| 167 | ActivationLayerDataObject{ TensorShape(7U, 7U, 48U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) } |
| 168 | } |
| 169 | { |
| 170 | } |
| 171 | |
| 172 | ~GoogLeNetActivationLayerDataset() = default; |
| 173 | }; |
| 174 | |
| 175 | } // namespace test |
| 176 | } // namespace arm_compute |
| 177 | #endif //__ARM_COMPUTE_TEST_DATASET_ACTIVATION_LAYER_DATASET_H__ |