From 6ff3b19ee6120edf015fad8caab2991faa3070af Mon Sep 17 00:00:00 2001 From: Anthony Barbier Date: Mon, 4 Sep 2017 18:44:23 +0100 Subject: COMPMID-344 Updated doxygen Change-Id: I32f7b84daa560e460b77216add529c8fa8b327ae --- tests/dataset/ActivationFunctionDataset.h | 66 ++++++ tests/dataset/ActivationLayerDataset.h | 177 ++++++++++++++++ tests/dataset/BatchNormalizationLayerDataset.h | 90 +++++++++ tests/dataset/BorderModeDataset.h | 82 ++++++++ tests/dataset/ConvertPolicyDataset.h | 82 ++++++++ tests/dataset/ConvolutionLayerDataset.h | 269 +++++++++++++++++++++++++ tests/dataset/DataTypeDatasets.h | 193 ++++++++++++++++++ tests/dataset/FullyConnectedLayerDataset.h | 155 ++++++++++++++ tests/dataset/GEMMDataset.h | 204 +++++++++++++++++++ tests/dataset/GenericDataset.h | 97 +++++++++ tests/dataset/ImageDatasets.h | 120 +++++++++++ tests/dataset/InterpolationPolicyDataset.h | 80 ++++++++ tests/dataset/NormalizationLayerDataset.h | 99 +++++++++ tests/dataset/NormalizationTypeDataset.h | 80 ++++++++ tests/dataset/PoolingLayerDataset.h | 159 +++++++++++++++ tests/dataset/RoundingPolicyDataset.h | 82 ++++++++ tests/dataset/ShapeDatasets.h | 130 ++++++++++++ tests/dataset/ThresholdDataset.h | 95 +++++++++ 18 files changed, 2260 insertions(+) create mode 100644 tests/dataset/ActivationFunctionDataset.h create mode 100644 tests/dataset/ActivationLayerDataset.h create mode 100644 tests/dataset/BatchNormalizationLayerDataset.h create mode 100644 tests/dataset/BorderModeDataset.h create mode 100644 tests/dataset/ConvertPolicyDataset.h create mode 100644 tests/dataset/ConvolutionLayerDataset.h create mode 100644 tests/dataset/DataTypeDatasets.h create mode 100644 tests/dataset/FullyConnectedLayerDataset.h create mode 100644 tests/dataset/GEMMDataset.h create mode 100644 tests/dataset/GenericDataset.h create mode 100644 tests/dataset/ImageDatasets.h create mode 100644 tests/dataset/InterpolationPolicyDataset.h create mode 100644 tests/dataset/NormalizationLayerDataset.h create mode 100644 tests/dataset/NormalizationTypeDataset.h create mode 100644 tests/dataset/PoolingLayerDataset.h create mode 100644 tests/dataset/RoundingPolicyDataset.h create mode 100644 tests/dataset/ShapeDatasets.h create mode 100644 tests/dataset/ThresholdDataset.h (limited to 'tests/dataset') diff --git a/tests/dataset/ActivationFunctionDataset.h b/tests/dataset/ActivationFunctionDataset.h new file mode 100644 index 0000000000..11e4baac78 --- /dev/null +++ b/tests/dataset/ActivationFunctionDataset.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_ACTIVATION_FUNCTION_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_ACTIVATION_FUNCTION_DATASET_H__ + +#include "arm_compute/core/Types.h" +#include "dataset/GenericDataset.h" + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible activation functions. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on all activation functions. + */ +class ActivationFunctions final : public GenericDataset +{ +public: + ActivationFunctions() + : GenericDataset + { + ActivationLayerInfo::ActivationFunction::ABS, + ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, + ActivationLayerInfo::ActivationFunction::LINEAR, + ActivationLayerInfo::ActivationFunction::LOGISTIC, + ActivationLayerInfo::ActivationFunction::RELU, + ActivationLayerInfo::ActivationFunction::SOFT_RELU, + ActivationLayerInfo::ActivationFunction::SQRT, + ActivationLayerInfo::ActivationFunction::SQUARE, + ActivationLayerInfo::ActivationFunction::TANH + } + { + } + + ~ActivationFunctions() = default; +}; +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_ACTIVATION_FUNCTION_DATASET_H__ diff --git a/tests/dataset/ActivationLayerDataset.h b/tests/dataset/ActivationLayerDataset.h new file mode 100644 index 0000000000..9d7cffba14 --- /dev/null +++ b/tests/dataset/ActivationLayerDataset.h @@ -0,0 +1,177 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_ACTIVATION_LAYER_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_ACTIVATION_LAYER_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "dataset/GenericDataset.h" + +#include +#include + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +class ActivationLayerDataObject +{ +public: + operator std::string() const + { + std::stringstream ss; + ss << "ActivationLayer"; + ss << "_I" << shape; + ss << "_F_" << info.activation(); + return ss.str(); + } + +public: + TensorShape shape; + ActivationLayerInfo info; +}; + +template +using ActivationLayerDataset = GenericDataset; + +class AlexNetActivationLayerDataset final : public ActivationLayerDataset<5> +{ +public: + AlexNetActivationLayerDataset() + : GenericDataset + { + ActivationLayerDataObject{ TensorShape(55U, 55U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + ActivationLayerDataObject{ TensorShape(27U, 27U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + ActivationLayerDataObject{ TensorShape(13U, 13U, 384U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + ActivationLayerDataObject{ TensorShape(13U, 13U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + ActivationLayerDataObject{ TensorShape(4096U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + } + { + } + + ~AlexNetActivationLayerDataset() = default; +}; + +class LeNet5ActivationLayerDataset final : public ActivationLayerDataset<1> +{ +public: + LeNet5ActivationLayerDataset() + : GenericDataset + { + ActivationLayerDataObject{ TensorShape(500U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + } + { + } + + ~LeNet5ActivationLayerDataset() = default; +}; + +class GoogLeNetActivationLayerDataset final : public ActivationLayerDataset<33> +{ +public: + GoogLeNetActivationLayerDataset() + : GenericDataset + { + // conv1/relu_7x7 + ActivationLayerDataObject{ TensorShape(112U, 112U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // conv2/relu_3x3_reduce + ActivationLayerDataObject{ TensorShape(56U, 56U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // conv2/relu_3x3 + ActivationLayerDataObject{ TensorShape(56U, 56U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_3a/relu_1x1, inception_3b/relu_pool_proj + ActivationLayerDataObject{ TensorShape(28U, 28U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_3a/relu_3x3_reduce, inception_3b/relu_5x5 + ActivationLayerDataObject{ TensorShape(28U, 28U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_3a/relu_3x3, inception_3b/relu_1x1, inception_3b/relu_3x3_reduce + ActivationLayerDataObject{ TensorShape(28U, 28U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_3a/relu_5x5_reduce + ActivationLayerDataObject{ TensorShape(28U, 28U, 16U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_3a/relu_5x5, inception_3a/relu_pool_proj, inception_3b/relu_5x5_reduce + ActivationLayerDataObject{ TensorShape(28U, 28U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_3b/relu_3x3 + ActivationLayerDataObject{ TensorShape(28U, 28U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4a/relu_1x1 + ActivationLayerDataObject{ TensorShape(14U, 14U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4a/relu_3x3_reduce + ActivationLayerDataObject{ TensorShape(14U, 14U, 96U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4a/relu_3x3 + ActivationLayerDataObject{ TensorShape(14U, 14U, 208U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4a/relu_5x5_reduce + ActivationLayerDataObject{ TensorShape(14U, 14U, 16U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4a/relu_5x5 + ActivationLayerDataObject{ TensorShape(14U, 14U, 48U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // 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 + ActivationLayerDataObject{ TensorShape(14U, 14U, 64U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4b/relu_1x1, inception_4e/relu_3x3_reduce + ActivationLayerDataObject{ TensorShape(14U, 14U, 160U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4b/relu_3x3_reduce, inception_4d/relu_1x1 + ActivationLayerDataObject{ TensorShape(14U, 14U, 112U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4b/relu_3x3 + ActivationLayerDataObject{ TensorShape(14U, 14U, 224U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4b/relu_5x5_reduce, inception_4c/relu_5x5_reduce + ActivationLayerDataObject{ TensorShape(14U, 14U, 24U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4c/relu_1x1, inception_4c/relu_3x3_reduce, inception_4e/relu_5x5, inception_4e/relu_pool_proj + ActivationLayerDataObject{ TensorShape(14U, 14U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4c/relu_3x3, inception_4e/relu_1x1 + ActivationLayerDataObject{ TensorShape(14U, 14U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4d/relu_3x3_reduce + ActivationLayerDataObject{ TensorShape(14U, 14U, 144U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4d/relu_3x3 + ActivationLayerDataObject{ TensorShape(14U, 14U, 288U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4d/relu_5x5_reduce, inception_4e/relu_5x5_reduce + ActivationLayerDataObject{ TensorShape(14U, 14U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_4e/relu_3x3 + ActivationLayerDataObject{ TensorShape(14U, 14U, 320U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5a/relu_1x1 + ActivationLayerDataObject{ TensorShape(7U, 7U, 256U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5a/relu_3x3_reduce + ActivationLayerDataObject{ TensorShape(7U, 7U, 160U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5a/relu_3x3 + ActivationLayerDataObject{ TensorShape(7U, 7U, 320U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5a/relu_5x5_reduce + ActivationLayerDataObject{ TensorShape(7U, 7U, 32U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5a/relu_5x5, inception_5a/relu_pool_proj, inception_5b/relu_5x5, inception_5b/relu_pool_proj + ActivationLayerDataObject{ TensorShape(7U, 7U, 128U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5b/relu_1x1, inception_5b/relu_3x3 + ActivationLayerDataObject{ TensorShape(7U, 7U, 384U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5b/relu_3x3_reduce + ActivationLayerDataObject{ TensorShape(7U, 7U, 192U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) }, + // inception_5b/relu_5x5_reduce + ActivationLayerDataObject{ TensorShape(7U, 7U, 48U), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU) } + } + { + } + + ~GoogLeNetActivationLayerDataset() = default; +}; + +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_ACTIVATION_LAYER_DATASET_H__ diff --git a/tests/dataset/BatchNormalizationLayerDataset.h b/tests/dataset/BatchNormalizationLayerDataset.h new file mode 100644 index 0000000000..4323b8fe93 --- /dev/null +++ b/tests/dataset/BatchNormalizationLayerDataset.h @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_BATCH_NORMALIZATION_LAYER_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_BATCH_NORMALIZATION_LAYER_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "dataset/GenericDataset.h" + +#include +#include + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +class BatchNormalizationLayerDataObject +{ +public: + operator std::string() const + { + std::stringstream ss; + ss << "BatchNormalizationLayer"; + ss << "_I" << shape0; + ss << "_I" << shape1; + ss << "_I" << epsilon; + return ss.str(); + } + + friend std::ostream &operator<<(std::ostream &s, const BatchNormalizationLayerDataObject &obj) + { + s << static_cast(obj); + return s; + } + +public: + TensorShape shape0; + TensorShape shape1; + float epsilon; +}; + +template +using BatchNormalizationLayerDataset = GenericDataset; + +class RandomBatchNormalizationLayerDataset final : public BatchNormalizationLayerDataset<3> +{ +public: + RandomBatchNormalizationLayerDataset() + : GenericDataset + { + BatchNormalizationLayerDataObject{ TensorShape(15U, 16U, 2U, 12U), TensorShape(2U), 0.1f }, + BatchNormalizationLayerDataObject{ TensorShape(21U, 11U, 12U, 7U), TensorShape(12U), 0.1f }, + BatchNormalizationLayerDataObject{ TensorShape(7U, 3U, 6U, 11U), TensorShape(6U), 0.1f }, + } + { + } + + ~RandomBatchNormalizationLayerDataset() = default; +}; + +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_BATCH_NORMALIZATION_LAYER_DATASET_H__ diff --git a/tests/dataset/BorderModeDataset.h b/tests/dataset/BorderModeDataset.h new file mode 100644 index 0000000000..37c7a5ba10 --- /dev/null +++ b/tests/dataset/BorderModeDataset.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ +#define __ARM_COMPUTE_TEST_BORDER_MODE_DATASET_H__ + +#include "arm_compute/core/Types.h" + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +#include + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible border modes. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on all border modes. + */ +class BorderModes +{ +public: + /** Type of the samples in the data set. */ + using sample = BorderMode; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else + unsigned int size() const +#endif + { + return _modes.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const BorderMode *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _modes.data(); + } + +private: + std::array _modes{ { BorderMode::UNDEFINED, BorderMode::CONSTANT, BorderMode::REPLICATE } }; +}; +} // namespace test +} // namespace arm_compute +#endif diff --git a/tests/dataset/ConvertPolicyDataset.h b/tests/dataset/ConvertPolicyDataset.h new file mode 100644 index 0000000000..697dba615b --- /dev/null +++ b/tests/dataset/ConvertPolicyDataset.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_CONVERT_POLICY_DATASETS_H__ +#define __ARM_COMPUTE_TEST_CONVERT_POLICY_DATASETS_H__ + +#include "arm_compute/core/Types.h" + +#include + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible convert/overflow policies. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on different convert policies. + */ +class ConvertPolicies +{ +public: + /** Type of the samples in the data set. */ + using sample = ConvertPolicy; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else + unsigned int size() const +#endif + { + return _policies.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const ConvertPolicy *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _policies.data(); + } + +private: + std::array _policies{ { ConvertPolicy::WRAP, ConvertPolicy::SATURATE } }; +}; +} // namespace test +} // namespace arm_compute +#endif diff --git a/tests/dataset/ConvolutionLayerDataset.h b/tests/dataset/ConvolutionLayerDataset.h new file mode 100644 index 0000000000..e66117e0d8 --- /dev/null +++ b/tests/dataset/ConvolutionLayerDataset.h @@ -0,0 +1,269 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_CONVOLUTION_LAYER_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_CONVOLUTION_LAYER_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "dataset/GenericDataset.h" +#include "dataset/ShapeDatasets.h" + +#include +#include + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +/** Convolution Layer data object */ +class ConvolutionLayerDataObject +{ +public: + operator std::string() const + { + std::stringstream ss; + ss << "ConvolutionLayer"; + ss << "_I" << src_shape; + ss << "_K" << weights_shape; + ss << "_PS" << info; + return ss.str(); + } + + friend std::ostream &operator<<(std::ostream &os, const ConvolutionLayerDataObject &obj) + { + os << static_cast(obj); + return os; + } + +public: + TensorShape src_shape; + TensorShape weights_shape; + TensorShape bias_shape; + TensorShape dst_shape; + PadStrideInfo info; +}; + +template +using ConvolutionLayerDataset = GenericDataset; + +/** Data set containing small convolution layer shapes */ +class SmallConvolutionLayerDataset final : public ConvolutionLayerDataset<3> +{ +public: + SmallConvolutionLayerDataset() + : GenericDataset + { + ConvolutionLayerDataObject{ TensorShape(23U, 27U, 5U), TensorShape(3U, 3U, 5U, 21U), TensorShape(21U), TensorShape(11U, 25U, 21U), PadStrideInfo(2, 1, 0, 0) }, + ConvolutionLayerDataObject{ TensorShape(33U, 27U, 7U), TensorShape(5U, 5U, 7U, 11U), TensorShape(11U), TensorShape(11U, 12U, 11U), PadStrideInfo(3, 2, 1, 0) }, + ConvolutionLayerDataObject{ TensorShape(17U, 31U, 2U, 7U), TensorShape(5U, 5U, 2U, 5U), TensorShape(5U), TensorShape(15U, 15U, 5U, 7U), PadStrideInfo(1, 2, 1, 1) } + } + { + } + + ~SmallConvolutionLayerDataset() = default; +}; + +/** Data set containing direct convolution tensor shapes. */ +class DirectConvolutionShapes final : public ShapeDataset<3> +{ +public: + DirectConvolutionShapes() + : ShapeDataset(TensorShape(3U, 3U, 3U, 2U, 4U, 5U), + TensorShape(32U, 37U, 3U), + TensorShape(13U, 15U, 8U, 3U)) + { + } +}; + +/** AlexNet's convolution layers tensor shapes. */ +class AlexNetConvolutionLayerDataset final : public ConvolutionLayerDataset<5> +{ +public: + AlexNetConvolutionLayerDataset() + : GenericDataset + { + ConvolutionLayerDataObject{ TensorShape(227U, 227U, 3U), TensorShape(11U, 11U, 3U, 96U), TensorShape(96U), TensorShape(55U, 55U, 96U), PadStrideInfo(4, 4, 0, 0) }, + ConvolutionLayerDataObject{ TensorShape(27U, 27U, 96U), TensorShape(5U, 5U, 96U, 256U), TensorShape(256U), TensorShape(27U, 27U, 256U), PadStrideInfo(1, 1, 2, 2) }, + ConvolutionLayerDataObject{ TensorShape(13U, 13U, 256U), TensorShape(3U, 3U, 256U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1) }, + ConvolutionLayerDataObject{ TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 384U), TensorShape(384U), TensorShape(13U, 13U, 384U), PadStrideInfo(1, 1, 1, 1) }, + ConvolutionLayerDataObject{ TensorShape(13U, 13U, 384U), TensorShape(3U, 3U, 384U, 256U), TensorShape(256U), TensorShape(13U, 13U, 256U), PadStrideInfo(1, 1, 1, 1) } + } + { + } + + ~AlexNetConvolutionLayerDataset() = default; +}; + +/** LeNet5's convolution layers tensor shapes. */ +class LeNet5ConvolutionLayerDataset final : public ConvolutionLayerDataset<2> +{ +public: + LeNet5ConvolutionLayerDataset() + : GenericDataset + { + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 1U), TensorShape(5U, 5U, 1U, 20U), TensorShape(20U), TensorShape(24U, 24U, 20U), PadStrideInfo(1, 1, 0, 0) }, + ConvolutionLayerDataObject{ TensorShape(12U, 12U, 20U), TensorShape(5U, 5U, 20U, 50U), TensorShape(50U), TensorShape(8U, 8U, 50U), PadStrideInfo(1, 1, 0, 0) }, + } + { + } + + ~LeNet5ConvolutionLayerDataset() = default; +}; + +/** GoogleLeNet v1 convolution layers tensor shapes (Part 1). + * + * @note Dataset is split into two to avoid a register allocation failure produced by clang in Android debug builds. + */ +class GoogLeNetConvolutionLayerDataset1 final : public ConvolutionLayerDataset<32> +{ +public: + GoogLeNetConvolutionLayerDataset1() + : GenericDataset + { + // conv1/7x7_s2 + ConvolutionLayerDataObject{ TensorShape(224U, 224U, 3U), TensorShape(7U, 7U, 3U, 64U), TensorShape(64U), TensorShape(112U, 112U, 64U), PadStrideInfo(2, 2, 3, 3) }, + // conv2/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(56U, 56U, 64U), TensorShape(1U, 1U, 64U, 64U), TensorShape(64U), TensorShape(56U, 56U, 64U), PadStrideInfo(1, 1, 0, 0) }, + // conv2/3x3 + ConvolutionLayerDataObject{ TensorShape(56U, 56U, 64U), TensorShape(3U, 3U, 64U, 192U), TensorShape(192U), TensorShape(56U, 56U, 192U), PadStrideInfo(1, 1, 1, 1) }, + // inception_3a/1x1 + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0) }, + // inception_3a/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 0, 0) }, + // inception_3a/3x3 + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 96U), TensorShape(3U, 3U, 96U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 1, 1) }, + // inception_3a/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 16U), TensorShape(16U), TensorShape(28U, 28U, 16U), PadStrideInfo(1, 1, 0, 0) }, + // inception_3a/5x5 + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 16U), TensorShape(5U, 5U, 16U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 2, 2) }, + // inception_3a/pool_proj + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(1U, 1U, 192U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0) }, + // inception_3b/1x1, inception_3b/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 128U), TensorShape(128U), TensorShape(28U, 28U, 128U), PadStrideInfo(1, 1, 0, 0) }, + // inception_3b/3x3 + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 128U), TensorShape(3U, 3U, 128U, 192U), TensorShape(192U), TensorShape(28U, 28U, 192U), PadStrideInfo(1, 1, 1, 1) }, + // inception_3b/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 32U), TensorShape(32U), TensorShape(28U, 28U, 32U), PadStrideInfo(1, 1, 0, 0) }, + // inception_3b/5x5 + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 32U), TensorShape(5U, 5U, 32U, 96U), TensorShape(96U), TensorShape(28U, 28U, 96U), PadStrideInfo(1, 1, 2, 2) }, + // inception_3b/pool_proj + ConvolutionLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(1U, 1U, 256U, 64U), TensorShape(64U), TensorShape(28U, 28U, 64U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4a/1x1 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 192U), TensorShape(192U), TensorShape(14U, 14U, 192U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4a/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 96U), TensorShape(96U), TensorShape(14U, 14U, 96U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4a/3x3 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 96U), TensorShape(3U, 3U, 96U, 208U), TensorShape(208U), TensorShape(14U, 14U, 208U), PadStrideInfo(1, 1, 1, 1) }, + // inception_4a/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 16U), TensorShape(16U), TensorShape(14U, 14U, 16U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4a/5x5 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 16U), TensorShape(5U, 5U, 16U, 48U), TensorShape(48U), TensorShape(14U, 14U, 48U), PadStrideInfo(1, 1, 2, 2) }, + // inception_4a/pool_proj + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(1U, 1U, 480U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4b/1x1 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4b/3x3_reduce, inception_4d/1x1 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 112U), TensorShape(112U), TensorShape(14U, 14U, 112U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4b/3x3 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 112U), TensorShape(3U, 3U, 112U, 224U), TensorShape(224U), TensorShape(14U, 14U, 224U), PadStrideInfo(1, 1, 1, 1) }, + // inception_4b/5x5_reduce, inception_4c/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 24U), TensorShape(24U), TensorShape(14U, 14U, 24U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4b/5x5, inception_4c/5x5 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 24U), TensorShape(5U, 5U, 24U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 2, 2) }, + // inception_4b/pool_proj, inception_4c/pool_proj, inception_4d/pool_proj + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4c/1x1, inception_4c/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4c/3x3 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 128U), TensorShape(3U, 3U, 128U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 1, 1) }, + // inception_4d/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 144U), TensorShape(144U), TensorShape(14U, 14U, 144U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4d/3x3 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 144U), TensorShape(3U, 3U, 144U, 288U), TensorShape(288U), TensorShape(14U, 14U, 288U), PadStrideInfo(1, 1, 1, 1) }, + // inception_4d/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(1U, 1U, 512U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4d/5x5 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 32U), TensorShape(5U, 5U, 32U, 64U), TensorShape(64U), TensorShape(14U, 14U, 64U), PadStrideInfo(1, 1, 2, 2) }, + } + { + } + + ~GoogLeNetConvolutionLayerDataset1() = default; +}; + +/** GoogleLeNet v1 convolution layers tensor shapes (Part 2). */ +class GoogLeNetConvolutionLayerDataset2 final : public ConvolutionLayerDataset<17> +{ +public: + GoogLeNetConvolutionLayerDataset2() + : GenericDataset + { + // inception_4e/1x1 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 256U), TensorShape(256U), TensorShape(14U, 14U, 256U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4e/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 160U), TensorShape(160U), TensorShape(14U, 14U, 160U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4e/3x3 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(14U, 14U, 320U), PadStrideInfo(1, 1, 1, 1) }, + // inception_4e/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 32U), TensorShape(32U), TensorShape(14U, 14U, 32U), PadStrideInfo(1, 1, 0, 0) }, + // inception_4e/5x5 + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 32U), TensorShape(5U, 5U, 32U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 2, 2) }, + // inception_4e/pool_proj + ConvolutionLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(1U, 1U, 528U, 128U), TensorShape(128U), TensorShape(14U, 14U, 128U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5a/1x1 + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 256U), TensorShape(256U), TensorShape(7U, 7U, 256U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5a/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 160U), TensorShape(160U), TensorShape(7U, 7U, 160U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5a/3x3 + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 160U), TensorShape(3U, 3U, 160U, 320U), TensorShape(320U), TensorShape(7U, 7U, 320U), PadStrideInfo(1, 1, 1, 1) }, + // inception_5a/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 32U), TensorShape(32U), TensorShape(7U, 7U, 32U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5a/5x5 + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 32U), TensorShape(5U, 5U, 32U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 2, 2) }, + // inception_5a/pool_proj, inception_5b/pool_proj + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5b/1x1 + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5b/3x3_reduce + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 192U), TensorShape(192U), TensorShape(7U, 7U, 192U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5b/3x3 + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 192U), TensorShape(3U, 3U, 192U, 384U), TensorShape(384U), TensorShape(7U, 7U, 384U), PadStrideInfo(1, 1, 1, 1) }, + // inception_5b/5x5_reduce + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(1U, 1U, 832U, 48U), TensorShape(48U), TensorShape(7U, 7U, 48U), PadStrideInfo(1, 1, 0, 0) }, + // inception_5b/5x5 + ConvolutionLayerDataObject{ TensorShape(7U, 7U, 48U), TensorShape(5U, 5U, 48U, 128U), TensorShape(128U), TensorShape(7U, 7U, 128U), PadStrideInfo(1, 1, 2, 2) } + } + { + } + + ~GoogLeNetConvolutionLayerDataset2() = default; +}; +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_CONVOLUTION_LAYER_DATASET_H__ diff --git a/tests/dataset/DataTypeDatasets.h b/tests/dataset/DataTypeDatasets.h new file mode 100644 index 0000000000..8c63857477 --- /dev/null +++ b/tests/dataset/DataTypeDatasets.h @@ -0,0 +1,193 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATA_TYPE_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATA_TYPE_DATASET_H__ + +#include "arm_compute/core/Types.h" + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +/** Abstract data set containing data types. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on different data types. + */ +template +class DataTypes +{ +public: + /** Type of the samples in the data set. */ + using sample = DataType; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else + unsigned int size() const +#endif + { + return _types.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const DataType *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _types.data(); + } + +protected: + /** Protected constructor to make the class abstract. */ + template + DataTypes(Ts &&... types) + : _types{ { types... } } + { + } + + /** Protected destructor to prevent deletion of derived classes through a + * pointer to the base class. + */ + ~DataTypes() = default; + +private: + std::array _types; +}; + +/** Data set containing all data types. */ +class AllDataTypes final : public DataTypes<14> +{ +public: + AllDataTypes() + : DataTypes{ DataType::U8, DataType::S8, DataType::U16, DataType::S16, + DataType::U32, DataType::S32, DataType::U64, DataType::S64, + DataType::F16, DataType::F32, DataType::F64, DataType::SIZET, + DataType::QS8, DataType::QS16 } + { + } + + ~AllDataTypes() = default; +}; + +/** Data set containing all unsigned data types. */ +class UnsignedDataTypes final : public DataTypes<4> +{ +public: + UnsignedDataTypes() + : DataTypes{ DataType::U8, DataType::U16, DataType::U32, DataType::U64 } + { + } + + ~UnsignedDataTypes() = default; +}; + +/** Data set containing all signed data types. */ +class SignedDataTypes final : public DataTypes<4> +{ +public: + SignedDataTypes() + : DataTypes{ DataType::S8, DataType::S16, DataType::S32, DataType::S64 } + { + } + + ~SignedDataTypes() = default; +}; + +/** Data set containing all floating point data types. */ +class FloatDataTypes final : public DataTypes<3> +{ +public: + FloatDataTypes() + : DataTypes{ DataType::F16, DataType::F32, DataType::F64 } + { + } + + ~FloatDataTypes() = default; +}; + +/** Data set containing all fixed point data types. */ +class FixedPointDataTypes final : public DataTypes<2> +{ +public: + FixedPointDataTypes() + : DataTypes{ DataType::QS8, DataType::QS16 } + { + } + + ~FixedPointDataTypes() = default; +}; + +/** Supported CNN float types. */ +class CNNFloatDataTypes final : public DataTypes<1> +{ +public: + CNNFloatDataTypes() + : DataTypes{ DataType::F32 } + { + } + + ~CNNFloatDataTypes() = default; +}; + +/** Supported CNN fixed point types. */ +class CNNFixedPointDataTypes final : public DataTypes<1> +{ +public: + CNNFixedPointDataTypes() + : DataTypes{ DataType::QS8 } + { + } + + ~CNNFixedPointDataTypes() = default; +}; + +/** Supported CNN types. */ +class CNNDataTypes final : public DataTypes<2> +{ +public: + CNNDataTypes() + : DataTypes{ DataType::F32, DataType::QS8 } + { + } + + ~CNNDataTypes() = default; +}; +} // namespace test +} // namespace arm_compute +#endif diff --git a/tests/dataset/FullyConnectedLayerDataset.h b/tests/dataset/FullyConnectedLayerDataset.h new file mode 100644 index 0000000000..53b7d022d7 --- /dev/null +++ b/tests/dataset/FullyConnectedLayerDataset.h @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_FULLY_CONNECTED_LAYER_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_FULLY_CONNECTED_LAYER_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "dataset/GenericDataset.h" + +#include +#include + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +class FullyConnectedLayerDataObject +{ +public: + operator std::string() const + { + std::stringstream ss; + ss << "FullyConnectedLayer"; + ss << "_I" << src_shape; + ss << "_K" << weights_shape; + return ss.str(); + } + + friend std::ostream &operator<<(std::ostream &os, const FullyConnectedLayerDataObject &obj) + { + os << static_cast(obj); + return os; + } + +public: + TensorShape src_shape; + TensorShape weights_shape; + TensorShape bias_shape; + TensorShape dst_shape; + bool transpose_weights; + bool are_weights_reshaped; +}; + +template +using FullyConnectedLayerDataset = GenericDataset; + +class SmallFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<5> +{ +public: + SmallFullyConnectedLayerDataset() + : GenericDataset + { + FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 7U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U), true, false }, + FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 7U, 3U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U, 3U), true, false }, + FullyConnectedLayerDataObject{ TensorShape(201U), TensorShape(201U, 529U), TensorShape(529U), TensorShape(529U), true, false }, + FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 7U), TensorShape(315U, 271U), TensorShape(271U), TensorShape(271U), true, true }, + FullyConnectedLayerDataObject{ TensorShape(201U), TensorShape(201U, 529U), TensorShape(529U), TensorShape(529U), true, true }, + } + { + } + + ~SmallFullyConnectedLayerDataset() = default; +}; + +class LargeFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<5> +{ +public: + LargeFullyConnectedLayerDataset() + : GenericDataset + { + FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 257U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U), true, false }, + FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 257U, 2U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U, 2U), true, false }, + FullyConnectedLayerDataObject{ TensorShape(3127U), TensorShape(3127U, 989U), TensorShape(989U), TensorShape(989U), true, false }, + FullyConnectedLayerDataObject{ TensorShape(9U, 5U, 257U), TensorShape(11565U, 2123U), TensorShape(2123U), TensorShape(2123U), true, true }, + FullyConnectedLayerDataObject{ TensorShape(3127U), TensorShape(3127U, 989U), TensorShape(989U), TensorShape(989U), true, true }, + } + { + } + + ~LargeFullyConnectedLayerDataset() = default; +}; + +class AlexNetFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<3> +{ +public: + AlexNetFullyConnectedLayerDataset() + : GenericDataset + { + FullyConnectedLayerDataObject{ TensorShape(6U, 6U, 256U), TensorShape(9216U, 4096U), TensorShape(4096U), TensorShape(4096U), true }, + FullyConnectedLayerDataObject{ TensorShape(4096U), TensorShape(4096U, 4096U), TensorShape(4096U), TensorShape(4096U), true }, + FullyConnectedLayerDataObject{ TensorShape(4096U), TensorShape(4096U, 1000U), TensorShape(1000U), TensorShape(1000U), true }, + } + { + } + + ~AlexNetFullyConnectedLayerDataset() = default; +}; + +class LeNet5FullyConnectedLayerDataset final : public FullyConnectedLayerDataset<2> +{ +public: + LeNet5FullyConnectedLayerDataset() + : GenericDataset + { + FullyConnectedLayerDataObject{ TensorShape(4U, 4U, 50U), TensorShape(800U, 500U), TensorShape(500U), TensorShape(500U) }, + FullyConnectedLayerDataObject{ TensorShape(500U), TensorShape(500U, 10U), TensorShape(10U), TensorShape(10U) }, + } + { + } + + ~LeNet5FullyConnectedLayerDataset() = default; +}; + +class GoogLeNetFullyConnectedLayerDataset final : public FullyConnectedLayerDataset<1> +{ +public: + GoogLeNetFullyConnectedLayerDataset() + : GenericDataset + { + FullyConnectedLayerDataObject{ TensorShape(1024U), TensorShape(1024U, 1000U), TensorShape(1000U), TensorShape(1000U), true }, + } + { + } + + ~GoogLeNetFullyConnectedLayerDataset() = default; +}; +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_FULLY_CONNECTED_LAYER_DATASET_H__ diff --git a/tests/dataset/GEMMDataset.h b/tests/dataset/GEMMDataset.h new file mode 100644 index 0000000000..f45bc3e838 --- /dev/null +++ b/tests/dataset/GEMMDataset.h @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_GEMM_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_GEMM_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "dataset/GenericDataset.h" + +#include +#include + +#include +#include + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +class GEMMDataObject +{ +public: + //Data object used for matrix multiple + //D = alpha * A * B + beta * C; + TensorShape shape_a; + TensorShape shape_b; + TensorShape shape_c; + TensorShape shape_d; + float alpha; + float beta; + + operator std::string() const + { + std::stringstream ss; + ss << "GEMM"; + ss << "_A" << shape_a; + ss << "_B" << shape_b; + ss << "_C" << shape_c; + ss << "_D" << shape_d; + ss << "_alpha" << alpha; + ss << "_beta" << beta; + return ss.str(); + } + + friend std::ostream &operator<<(std::ostream &os, const GEMMDataObject &obj) + { + os << static_cast(obj); + return os; + } +}; + +class SmallGEMMDataset : public GenericDataset +{ +public: + SmallGEMMDataset() + : GenericDataset + { + GEMMDataObject{ TensorShape(21u, 13u), TensorShape(33u, 21u), TensorShape(33u, 13u), TensorShape(33u, 13u), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(31u, 1u), TensorShape(23u, 31u), TensorShape(23u, 1u), TensorShape(23u, 1u), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(38u, 12u), TensorShape(21u, 38u), TensorShape(21u, 12u), TensorShape(21u, 12u), 0.2f, 1.2f }, + GEMMDataObject{ TensorShape(32u, 1u), TensorShape(17u, 32u), TensorShape(17u, 1u), TensorShape(17u, 1u), 0.4f, 0.7f }, + } + { + } + + ~SmallGEMMDataset() = default; +}; + +class LargeGEMMDataset : public GenericDataset +{ +public: + LargeGEMMDataset() + : GenericDataset + { + GEMMDataObject{ TensorShape(923u, 429u), TensorShape(871u, 923u), TensorShape(871u, 429u), TensorShape(871u, 429u), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1021u, 1u), TensorShape(783u, 1021u), TensorShape(783u, 1u), TensorShape(783u, 1u), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(681u, 1023u), TensorShape(213u, 681u), TensorShape(213u, 1023u), TensorShape(213u, 1023u), 0.2f, 1.2f }, + GEMMDataObject{ TensorShape(941u, 1u), TensorShape(623u, 941u), TensorShape(623u, 1u), TensorShape(623u, 1u), 0.4f, 0.7f }, + } + { + } + + ~LargeGEMMDataset() = default; +}; + +class GoogLeNetGEMMDataset1 : public GenericDataset +{ +public: + GoogLeNetGEMMDataset1() + : GenericDataset + { + GEMMDataObject{ TensorShape(147U, 12544U), TensorShape(64U, 147U), TensorShape(64U, 12544U), TensorShape(64U, 12544U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(64U, 3136U), TensorShape(64U, 64U), TensorShape(64U, 3136U), TensorShape(64U, 3136U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(576U, 3136U), TensorShape(192U, 576U), TensorShape(192U, 3136U), TensorShape(192U, 3136U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(192U, 784U), TensorShape(64U, 192U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(192U, 784U), TensorShape(96U, 192U), TensorShape(96U, 784U), TensorShape(96U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(864U, 784U), TensorShape(128U, 864U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(192U, 784U), TensorShape(16U, 192U), TensorShape(16U, 784U), TensorShape(16U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(400U, 784U), TensorShape(32U, 400U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(192U, 784U), TensorShape(32U, 192U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(256U, 784U), TensorShape(128U, 256U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(256U, 784U), TensorShape(128U, 256U), TensorShape(128U, 784U), TensorShape(128U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1152U, 784U), TensorShape(192U, 1152U), TensorShape(192U, 784U), TensorShape(192U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(256U, 784U), TensorShape(32U, 256U), TensorShape(32U, 784U), TensorShape(32U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(800U, 784U), TensorShape(96U, 800U), TensorShape(96U, 784U), TensorShape(96U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(256U, 784U), TensorShape(64U, 256U), TensorShape(64U, 784U), TensorShape(64U, 784U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(480U, 196U), TensorShape(192U, 480U), TensorShape(192U, 196U), TensorShape(192U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(480U, 196U), TensorShape(96U, 480U), TensorShape(96U, 196U), TensorShape(96U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(864U, 196U), TensorShape(204U, 864U), TensorShape(204U, 196U), TensorShape(204U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(480U, 196U), TensorShape(16U, 480U), TensorShape(16U, 196U), TensorShape(16U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(400U, 196U), TensorShape(48U, 400U), TensorShape(48U, 196U), TensorShape(48U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(480U, 196U), TensorShape(64U, 480U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(508U, 196U), TensorShape(160U, 508U), TensorShape(160U, 196U), TensorShape(160U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(508U, 196U), TensorShape(112U, 508U), TensorShape(112U, 196U), TensorShape(112U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1008U, 196U), TensorShape(224U, 1008U), TensorShape(224U, 196U), TensorShape(224U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(508U, 196U), TensorShape(24U, 508U), TensorShape(24U, 196U), TensorShape(24U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(600U, 196U), TensorShape(64U, 600U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(508U, 196U), TensorShape(64U, 508U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(128U, 512U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(128U, 512U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1152U, 196U), TensorShape(256U, 1152U), TensorShape(256U, 196U), TensorShape(256U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(24U, 512U), TensorShape(24U, 196U), TensorShape(24U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(600U, 196U), TensorShape(64U, 600U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f } + } + { + } + + ~GoogLeNetGEMMDataset1() = default; +}; + +class GoogLeNetGEMMDataset2 : public GenericDataset +{ +public: + GoogLeNetGEMMDataset2() + : GenericDataset + { + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(64U, 512U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(112U, 512U), TensorShape(112U, 196U), TensorShape(112U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(144U, 512U), TensorShape(144U, 196U), TensorShape(144U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1296U, 196U), TensorShape(288U, 1296U), TensorShape(288U, 196U), TensorShape(288U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(32U, 512U), TensorShape(32U, 196U), TensorShape(32U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(800U, 196U), TensorShape(64U, 800U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(512U, 196U), TensorShape(64U, 512U), TensorShape(64U, 196U), TensorShape(64U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(528U, 196U), TensorShape(256U, 528U), TensorShape(256U, 196U), TensorShape(256U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(528U, 196U), TensorShape(160U, 528U), TensorShape(160U, 196U), TensorShape(160U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1440U, 196U), TensorShape(320U, 1440U), TensorShape(320U, 196U), TensorShape(320U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(528U, 196U), TensorShape(32U, 528U), TensorShape(32U, 196U), TensorShape(32U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(800U, 196U), TensorShape(128U, 800U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(528U, 196U), TensorShape(128U, 528U), TensorShape(128U, 196U), TensorShape(128U, 196U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(256U, 832U), TensorShape(256U, 49U), TensorShape(256U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(160U, 832U), TensorShape(160U, 49U), TensorShape(160U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1440U, 49U), TensorShape(320U, 1440U), TensorShape(320U, 49U), TensorShape(320U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(48U, 832U), TensorShape(48U, 49U), TensorShape(48U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1200U, 49U), TensorShape(128U, 1200U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(128U, 832U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(384U, 832U), TensorShape(384U, 49U), TensorShape(384U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(192U, 832U), TensorShape(192U, 49U), TensorShape(192U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1728U, 49U), TensorShape(384U, 1728U), TensorShape(384U, 49U), TensorShape(384U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(48U, 832U), TensorShape(48U, 49U), TensorShape(48U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1200U, 49U), TensorShape(128U, 1200U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(832U, 49U), TensorShape(128U, 832U), TensorShape(128U, 49U), TensorShape(128U, 49U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(508U, 16U), TensorShape(128U, 508U), TensorShape(128U, 16U), TensorShape(128U, 16U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(2048U, 1U), TensorShape(1024U, 2048U), TensorShape(1024U, 1U), TensorShape(1024U, 1U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(528U, 16U), TensorShape(128U, 528U), TensorShape(128U, 16U), TensorShape(128U, 16U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(2048U, 1U), TensorShape(1024U, 2048U), TensorShape(1024U, 1U), TensorShape(1024U, 1U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f }, + GEMMDataObject{ TensorShape(1024U, 1U), TensorShape(1008U, 1024U), TensorShape(1008U, 1U), TensorShape(1008U, 1U), 1.0f, 0.0f } + } + { + } + + ~GoogLeNetGEMMDataset2() = default; +}; +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_GEMM_DATASET_H__ diff --git a/tests/dataset/GenericDataset.h b/tests/dataset/GenericDataset.h new file mode 100644 index 0000000000..4ca489bd82 --- /dev/null +++ b/tests/dataset/GenericDataset.h @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_GENERIC_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_GENERIC_DATASET_H__ + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +#include + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +/** Abstract data set containing multiple objects T. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on different configurations. + */ +template +class GenericDataset +{ +public: + /** Type of the samples in the data set. */ + using sample = T; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else + unsigned int size() const +#endif + { + return _data.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const T *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _data.data(); + } + +protected: + /** Protected constructor to make the class abstract. */ + template + GenericDataset(Ts... objs) + : _data{ { objs... } } + { + } + + /** Protected destructor to prevent deletion of derived class through a + * pointer to the base class. + */ + ~GenericDataset() = default; + +private: + std::array _data; +}; +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_GENERIC_DATASET_H__ diff --git a/tests/dataset/ImageDatasets.h b/tests/dataset/ImageDatasets.h new file mode 100644 index 0000000000..555227e83b --- /dev/null +++ b/tests/dataset/ImageDatasets.h @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_IMAGE_DATASETS_H__ +#define __ARM_COMPUTE_TEST_IMAGE_DATASETS_H__ + +#include +#include + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +/** Abstract data set containing image names. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on different images. + */ +template +class ImageDataset +{ +public: + /** Type of the samples in the data set. */ + using sample = const std::string; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else + unsigned int size() const +#endif + { + return _images.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const std::string *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _images.data(); + } + +protected: + /** Protected constructor to make the class abstract. */ + template + ImageDataset(Ts... images) + : _images{ { images... } } + { + } + + /** Protected destructor to prevent deletion of derived class through a + * pointer to the base class. + */ + ~ImageDataset() = default; + +private: + std::array _images; +}; + +/** Data set containing names of small images. */ +class SmallImages final : public ImageDataset<2> +{ +public: + SmallImages() + : ImageDataset("128x128.ppm", "640x480.ppm") + { + } +}; + +/** Data set containing names of large images. */ +class LargeImages final : public ImageDataset<3> +{ +public: + LargeImages() +#ifdef INTERNAL_ONLY + : ImageDataset("1280x720.ppm", "1920x1080.ppm", "4160x3120.ppm") + // The 4k image is too large to distribute +#else + : ImageDataset("1280x720.ppm", "1920x1080.ppm") +#endif /* INTERNAL_ONLY */ + { + } +}; +} // namespace test +} // namespace arm_compute +#endif diff --git a/tests/dataset/InterpolationPolicyDataset.h b/tests/dataset/InterpolationPolicyDataset.h new file mode 100644 index 0000000000..e6062eae53 --- /dev/null +++ b/tests/dataset/InterpolationPolicyDataset.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_INTERPOLATION_POLICY_DATASET_H__ +#define __ARM_COMPUTE_TEST_INTERPOLATION_POLICY_DATASET_H__ + +#include "arm_compute/core/Types.h" + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible interpolation policies. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on all interpolation policies. + */ +class InterpolationPolicies +{ +public: + /** Type of the samples in the data set. */ + using sample = InterpolationPolicy; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else + unsigned int size() const +#endif + { + return _policies.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const InterpolationPolicy *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _policies.data(); + } + +private: + std::array _policies{ { InterpolationPolicy::NEAREST_NEIGHBOR, InterpolationPolicy::BILINEAR, InterpolationPolicy::AREA } }; +}; +} // namespace test +} // namespace arm_compute +#endif diff --git a/tests/dataset/NormalizationLayerDataset.h b/tests/dataset/NormalizationLayerDataset.h new file mode 100644 index 0000000000..7234f41551 --- /dev/null +++ b/tests/dataset/NormalizationLayerDataset.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_NORMALIZATION_LAYER_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_NORMALIZATION_LAYER_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "dataset/GenericDataset.h" + +#include +#include + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +class NormalizationLayerDataObject +{ +public: + operator std::string() const + { + std::stringstream ss; + ss << "NormalizationLayer"; + ss << "_I" << shape; + ss << "_F_" << info.type(); + ss << "_S_" << info.norm_size(); + return ss.str(); + } + +public: + TensorShape shape; + NormalizationLayerInfo info; +}; + +template +using NormalizationLayerDataset = GenericDataset; + +class GoogLeNetNormalizationLayerDataset final : public NormalizationLayerDataset<2> +{ +public: + GoogLeNetNormalizationLayerDataset() + : GenericDataset + { + // conv2/norm2 + NormalizationLayerDataObject{ TensorShape(56U, 56U, 192U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) }, + // pool1/norm1 + NormalizationLayerDataObject{ TensorShape(56U, 56U, 64U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) } + } + { + } + + ~GoogLeNetNormalizationLayerDataset() = default; +}; + +class AlexNetNormalizationLayerDataset final : public NormalizationLayerDataset<2> +{ +public: + AlexNetNormalizationLayerDataset() + : GenericDataset + { + NormalizationLayerDataObject{ TensorShape(55U, 55U, 96U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) }, + NormalizationLayerDataObject{ TensorShape(27U, 27U, 256U), NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f) }, + } + { + } + + ~AlexNetNormalizationLayerDataset() = default; +}; + +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_NORMALIZATION_LAYER_DATASET_H__ diff --git a/tests/dataset/NormalizationTypeDataset.h b/tests/dataset/NormalizationTypeDataset.h new file mode 100644 index 0000000000..bb1975c6c9 --- /dev/null +++ b/tests/dataset/NormalizationTypeDataset.h @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_NORMALIZATION_TYPE_DATASET_H__ +#define __ARM_COMPUTE_TEST_NORMALIZATION_TYPE_DATASET_H__ + +#include "arm_compute/core/Types.h" + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible normalization types. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on all normalization types. + */ +class NormalizationTypes +{ +public: + /** Type of the samples in the data set. */ + using sample = NormType; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else + unsigned int size() const +#endif + { + return _types.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const NormType *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _types.data(); + } + +private: + std::array _types{ { NormType::IN_MAP_1D, NormType::IN_MAP_2D, NormType::CROSS_MAP } }; +}; +} // namespace test +} // namespace arm_compute +#endif diff --git a/tests/dataset/PoolingLayerDataset.h b/tests/dataset/PoolingLayerDataset.h new file mode 100644 index 0000000000..0a50a763ce --- /dev/null +++ b/tests/dataset/PoolingLayerDataset.h @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_POOLING_LAYER_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_POOLING_LAYER_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "dataset/GenericDataset.h" + +#include + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +class PoolingLayerDataObject +{ +public: + operator std::string() const + { + std::stringstream ss; + ss << "PoolingLayer"; + ss << "_I" << src_shape; + ss << "_S_" << info.pool_size(); + ss << "_F_" << info.pool_type(); + ss << "_PS" << info.pad_stride_info(); + return ss.str(); + } + + friend std::ostream &operator<<(std::ostream &s, const PoolingLayerDataObject &obj) + { + s << static_cast(obj); + return s; + } + +public: + TensorShape src_shape; + TensorShape dst_shape; + PoolingLayerInfo info; +}; + +template +using PoolingLayerDataset = GenericDataset; + +class AlexNetPoolingLayerDataset final : public PoolingLayerDataset<3> +{ +public: + AlexNetPoolingLayerDataset() + : GenericDataset + { + PoolingLayerDataObject{ TensorShape(55U, 55U, 96U), TensorShape(27U, 27U, 96U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) }, + PoolingLayerDataObject{ TensorShape(27U, 27U, 256U), TensorShape(13U, 13U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) }, + PoolingLayerDataObject{ TensorShape(13U, 13U, 256U), TensorShape(6U, 6U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) }, + } + { + } + + ~AlexNetPoolingLayerDataset() = default; +}; + +class LeNet5PoolingLayerDataset final : public PoolingLayerDataset<2> +{ +public: + LeNet5PoolingLayerDataset() + : GenericDataset + { + PoolingLayerDataObject{ TensorShape(24U, 24U, 20U), TensorShape(12U, 12U, 20U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0)) }, + PoolingLayerDataObject{ TensorShape(8U, 8U, 50U), TensorShape(4U, 4U, 50U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0)) }, + } + { + } + + ~LeNet5PoolingLayerDataset() = default; +}; + +class GoogLeNetPoolingLayerDataset final : public PoolingLayerDataset<10> +{ +public: + GoogLeNetPoolingLayerDataset() + : GenericDataset + { + // FIXME: Add support for 7x7 pooling layer pool5/7x7_s1 + // pool1/3x3_s2 + PoolingLayerDataObject{ TensorShape(112U, 112U, 64U), TensorShape(56U, 56U, 64U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, + // pool2/3x3_s2 + PoolingLayerDataObject{ TensorShape(56U, 56U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, + // inception_3a/pool + PoolingLayerDataObject{ TensorShape(28U, 28U, 192U), TensorShape(28U, 28U, 192U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, + // inception_3b/pool + PoolingLayerDataObject{ TensorShape(28U, 28U, 256U), TensorShape(28U, 28U, 256U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, + // pool3/3x3_s2 + PoolingLayerDataObject{ TensorShape(28U, 28U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, + // inception_4a/pool + PoolingLayerDataObject{ TensorShape(14U, 14U, 480U), TensorShape(14U, 14U, 480U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, + // inception_4b/pool, inception_4c/pool, inception_4d/pool + PoolingLayerDataObject{ TensorShape(14U, 14U, 512U), TensorShape(14U, 14U, 512U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, + // inception_4e/pool + PoolingLayerDataObject{ TensorShape(14U, 14U, 528U), TensorShape(14U, 14U, 528U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, + // pool4/3x3_s2 + PoolingLayerDataObject{ TensorShape(14U, 14U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL)) }, + // inception_5a/pool, inception_5b/pool + PoolingLayerDataObject{ TensorShape(7U, 7U, 832U), TensorShape(7U, 7U, 832U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL)) }, + } + { + } + + ~GoogLeNetPoolingLayerDataset() = default; +}; + +class RandomPoolingLayerDataset final : public PoolingLayerDataset<8> +{ +public: + RandomPoolingLayerDataset() + : GenericDataset + { + PoolingLayerDataObject{ TensorShape(27U, 27U, 16U), TensorShape(13U, 13U, 16U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) }, + PoolingLayerDataObject{ TensorShape(13U, 13U, 32U), TensorShape(6U, 6U, 32U), PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0)) }, + PoolingLayerDataObject{ TensorShape(24U, 24U, 10U), TensorShape(12U, 12U, 10U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0)) }, + PoolingLayerDataObject{ TensorShape(8U, 8U, 30U), TensorShape(4U, 4U, 30U), PoolingLayerInfo(PoolingType::MAX, 2, PadStrideInfo(2, 2, 0, 0)) }, + PoolingLayerDataObject{ TensorShape(27U, 27U, 16U), TensorShape(13U, 13U, 16U), PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(2, 2, 0, 0)) }, + PoolingLayerDataObject{ TensorShape(13U, 13U, 32U), TensorShape(6U, 6U, 32U), PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(2, 2, 0, 0)) }, + PoolingLayerDataObject{ TensorShape(24U, 24U, 10U), TensorShape(12U, 12U, 10U), PoolingLayerInfo(PoolingType::AVG, 2, PadStrideInfo(2, 2, 0, 0)) }, + PoolingLayerDataObject{ TensorShape(8U, 8U, 30U), TensorShape(4U, 4U, 30U), PoolingLayerInfo(PoolingType::AVG, 2, PadStrideInfo(2, 2, 0, 0)) }, + } + { + } + + ~RandomPoolingLayerDataset() = default; +}; +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_POOLING_LAYER_DATASET_H__ diff --git a/tests/dataset/RoundingPolicyDataset.h b/tests/dataset/RoundingPolicyDataset.h new file mode 100644 index 0000000000..c70872020b --- /dev/null +++ b/tests/dataset/RoundingPolicyDataset.h @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_ROUNDING_POLICY_DATASETS_H__ +#define __ARM_COMPUTE_TEST_ROUNDING_POLICY_DATASETS_H__ + +#include "arm_compute/core/Types.h" + +#include + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +/** Data set containing all possible rounding policies. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on different rounding policies. + */ +class RoundingPolicies +{ +public: + /** Type of the samples in the data set. */ + using sample = RoundingPolicy; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else + unsigned int size() const +#endif + { + return _policies.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const RoundingPolicy *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _policies.data(); + } + +private: + std::array _policies{ { RoundingPolicy::TO_ZERO, RoundingPolicy::TO_NEAREST_UP, RoundingPolicy::TO_NEAREST_EVEN } }; +}; +} // namespace test +} // namespace arm_compute +#endif diff --git a/tests/dataset/ShapeDatasets.h b/tests/dataset/ShapeDatasets.h new file mode 100644 index 0000000000..73bdb8ea0e --- /dev/null +++ b/tests/dataset/ShapeDatasets.h @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ +#define __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ + +#include "arm_compute/core/TensorShape.h" + +#include + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +/** Abstract data set containing tensor shapes. + * + * Can be used as input for Boost data test cases to automatically run a test + * case on different tensor shapes. + */ +template +class ShapeDataset +{ +public: + /** Type of the samples in the data set. */ + using sample = TensorShape; + + /** Dimensionality of the data set. */ + enum + { + arity = 1 + }; + + /** Number of samples in the data set. */ +#ifdef BOOST + boost::unit_test::data::size_t size() const +#else + unsigned int size() const +#endif + { + return _shapes.size(); + } + + /** Type of the iterator used to step through all samples in the data set. + * Needs to support operator*() and operator++() which a pointer does. + */ + using iterator = const TensorShape *; + + /** Iterator to the first sample in the data set. */ + iterator begin() const + { + return _shapes.data(); + } + +protected: + /** Protected constructor to make the class abstract. */ + template + ShapeDataset(Ts... shapes) + : _shapes{ { shapes... } } + { + } + + /** Protected destructor to prevent deletion of derived class through a + * pointer to the base class. + */ + ~ShapeDataset() = default; + +private: + std::array _shapes; +}; + +/** Data set containing one 1D tensor shape. */ +class Small1DShape final : public ShapeDataset<1> +{ +public: + Small1DShape() + : ShapeDataset(TensorShape(128U)) + { + } +}; + +/** Data set containing small tensor shapes. */ +class SmallShapes final : public ShapeDataset<3> +{ +public: + SmallShapes() + : ShapeDataset(TensorShape(5U, 5U), + TensorShape(27U, 13U, 2U), + TensorShape(128U, 64U, 1U, 3U)) + { + } +}; + +/** Data set containing large tensor shapes. */ +class LargeShapes final : public ShapeDataset<3> +{ +public: + LargeShapes() + : ShapeDataset(TensorShape(1920U, 1080U), + TensorShape(1245U, 652U, 1U, 3U), + TensorShape(4160U, 3120U)) + { + } +}; +} // namespace test +} // namespace arm_compute +#endif diff --git a/tests/dataset/ThresholdDataset.h b/tests/dataset/ThresholdDataset.h new file mode 100644 index 0000000000..956cf3d54d --- /dev/null +++ b/tests/dataset/ThresholdDataset.h @@ -0,0 +1,95 @@ +/* + * Copyright (c) 2017 ARM Limited. + * + * SPDX-License-Identifier: MIT + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +#ifndef __ARM_COMPUTE_TEST_DATASET_THRESHOLD_DATASET_H__ +#define __ARM_COMPUTE_TEST_DATASET_THRESHOLD_DATASET_H__ + +#include "TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" +#include "dataset/GenericDataset.h" + +#include +#include + +#include +#include + +#ifdef BOOST +#include "boost_wrapper.h" +#endif + +namespace arm_compute +{ +namespace test +{ +class ThresholdDataObject +{ +public: + uint8_t threshold; + uint8_t false_value; + uint8_t true_value; + ThresholdType type; + uint8_t upper; + + operator std::string() const + { + std::stringstream ss; + ss << "Threshold"; + ss << "_threshold_value" << threshold; + ss << "_false_value" << false_value; + ss << "_true_value" << true_value; + ss << "_type"; + ss << ((type == ThresholdType::BINARY) ? "binary" : "range"); + ss << "_upper" << upper; + return ss.str(); + } + + friend std::ostream &operator<<(std::ostream &os, const ThresholdDataObject &obj) + { + os << static_cast(obj); + return os; + } +}; + +class ThresholdDataset : public GenericDataset +{ +public: + ThresholdDataset() + : GenericDataset + { + ThresholdDataObject{ 10U, 25U, 3U, ThresholdType::BINARY, 0U }, + ThresholdDataObject{ 20U, 1U, 0U, ThresholdType::BINARY, 0U }, + ThresholdDataObject{ 30U, 1U, 0U, ThresholdType::RANGE, 100U }, + ThresholdDataObject{ 100U, 1U, 0U, ThresholdType::RANGE, 200U }, + } + { + } + + ~ThresholdDataset() = default; +}; + +} // namespace test +} // namespace arm_compute +#endif //__ARM_COMPUTE_TEST_DATASET_THRESHOLD_DATASET_H__ -- cgit v1.2.1