diff options
Diffstat (limited to 'tests')
58 files changed, 723 insertions, 184 deletions
diff --git a/tests/AssetsLibrary.h b/tests/AssetsLibrary.h index 7e2a042e9d..ae88824298 100644 --- a/tests/AssetsLibrary.h +++ b/tests/AssetsLibrary.h @@ -66,27 +66,39 @@ public: */ AssetsLibrary(std::string path, std::random_device::result_type seed); - /** Path to assets directory used to initialise library. */ + /** Path to assets directory used to initialise library. + * + * @return the path to the assets directory. + */ std::string path() const; - /** Seed that is used to fill tensors with random values. */ + /** Seed that is used to fill tensors with random values. + * + * @return the initial random seed. + */ std::random_device::result_type seed() const; /** Provides a tensor shape for the specified image. * * @param[in] name Image file used to look up the raw tensor. + * + * @return the tensor shape for the specified image. */ TensorShape get_image_shape(const std::string &name); - /** Provides a contant raw tensor for the specified image. + /** Provides a constant raw tensor for the specified image. * * @param[in] name Image file used to look up the raw tensor. + * + * @return a raw tensor for the specified image. */ const RawTensor &get(const std::string &name) const; /** Provides a raw tensor for the specified image. * * @param[in] name Image file used to look up the raw tensor. + * + * @return a raw tensor for the specified image. */ RawTensor get(const std::string &name); @@ -96,6 +108,8 @@ public: * @param[in] name Image file used to initialise the tensor. * @param[in] data_type Data type used to initialise the tensor. * @param[in] num_channels Number of channels used to initialise the tensor. + * + * @return a raw tensor for the specified image. */ RawTensor get(const std::string &name, DataType data_type, int num_channels = 1) const; @@ -104,6 +118,8 @@ public: * * @param[in] name Image file used to look up the raw tensor. * @param[in] format Format used to look up the raw tensor. + * + * @return a raw tensor for the specified image. */ const RawTensor &get(const std::string &name, Format format) const; @@ -112,6 +128,8 @@ public: * * @param[in] name Image file used to look up the raw tensor. * @param[in] format Format used to look up the raw tensor. + * + * @return a raw tensor for the specified image. */ RawTensor get(const std::string &name, Format format); @@ -123,6 +141,8 @@ public: * * @note The channel has to be unambiguous so that the format can be * inferred automatically. + * + * @return a raw tensor for the specified image channel. */ const RawTensor &get(const std::string &name, Channel channel) const; @@ -134,6 +154,8 @@ public: * * @note The channel has to be unambiguous so that the format can be * inferred automatically. + * + * @return a raw tensor for the specified image channel. */ RawTensor get(const std::string &name, Channel channel); @@ -143,6 +165,8 @@ public: * @param[in] name Image file used to look up the raw tensor. * @param[in] format Format used to look up the raw tensor. * @param[in] channel Channel used to look up the raw tensor. + * + * @return a raw tensor for the specified image channel. */ const RawTensor &get(const std::string &name, Format format, Channel channel) const; @@ -152,6 +176,8 @@ public: * @param[in] name Image file used to look up the raw tensor. * @param[in] format Format used to look up the raw tensor. * @param[in] channel Channel used to look up the raw tensor. + * + * @return a raw tensor for the specified image channel. */ RawTensor get(const std::string &name, Format format, Channel channel); diff --git a/tests/CL/CLAccessor.h b/tests/CL/CLAccessor.h index f2e13f1232..66f3df06af 100644 --- a/tests/CL/CLAccessor.h +++ b/tests/CL/CLAccessor.h @@ -44,14 +44,30 @@ public: */ CLAccessor(CLTensor &tensor); + /** Prevent instances of this class from being copy constructed */ CLAccessor(const CLAccessor &) = delete; + /** Prevent instances of this class from being copied */ CLAccessor &operator=(const CLAccessor &) = delete; - CLAccessor(CLAccessor &&) = default; + /** Allow instances of this class to be move constructed */ + CLAccessor(CLAccessor &&) = default; + /** Allow instances of this class to be moved */ CLAccessor &operator=(CLAccessor &&) = default; /** Destructor that unmaps the CL memory. */ ~CLAccessor(); + /** Get the tensor data. + * + * @return a constant pointer to the tensor data. + */ + const void *data() const; + /** Get the tensor data. + * + * @return a pointer to the tensor data. + */ + void *data(); + + // Inherited method overrides TensorShape shape() const override; size_t element_size() const override; size_t size() const override; @@ -65,8 +81,6 @@ public: QuantizationInfo quantization_info() const override; const void *operator()(const Coordinates &coord) const override; void *operator()(const Coordinates &coord) override; - const void *data() const; - void *data(); private: CLTensor &_tensor; diff --git a/tests/CL/CLArrayAccessor.h b/tests/CL/CLArrayAccessor.h index a516a9d96a..c1638ae0df 100644 --- a/tests/CL/CLArrayAccessor.h +++ b/tests/CL/CLArrayAccessor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -49,9 +49,13 @@ public: _array.map(); } + /** Prevent instances of this class from being copy constructed */ CLArrayAccessor(const CLArrayAccessor &) = delete; + /** Prevent instances of this class from being copied */ CLArrayAccessor &operator=(const CLArrayAccessor &) = delete; - CLArrayAccessor(CLArrayAccessor &&) = default; + /** Allow instances of this class to be move constructed */ + CLArrayAccessor(CLArrayAccessor &&) = default; + /** Allow instances of this class to be moved */ CLArrayAccessor &operator=(CLArrayAccessor &&) = default; /** Destructor that unmaps the CL memory. */ diff --git a/tests/CL/CLLutAccessor.h b/tests/CL/CLLutAccessor.h index aa0285845d..ee5886191c 100644 --- a/tests/CL/CLLutAccessor.h +++ b/tests/CL/CLLutAccessor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -44,14 +44,19 @@ public: { _lut.map(true); } + /** Default destructor */ ~CLLutAccessor() { _lut.unmap(); } + /** Prevent instances of this class from being copy constructed */ CLLutAccessor(const CLLutAccessor &) = delete; + /** Prevent instances of this class from being copied */ CLLutAccessor &operator=(const CLLutAccessor &) = delete; - CLLutAccessor(CLLutAccessor &&) = default; + /** Allow instances of this class to be move constructed */ + CLLutAccessor(CLLutAccessor &&) = default; + /** Allow instance of this class to be moved */ CLLutAccessor &operator=(CLLutAccessor &&) = default; int num_elements() const override diff --git a/tests/CL/Helper.h b/tests/CL/Helper.h index 3f19d61a7d..30fbe568f4 100644 --- a/tests/CL/Helper.h +++ b/tests/CL/Helper.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -31,11 +31,15 @@ namespace arm_compute { namespace test { -// This template synthetizes an ICLSimpleFunction which runs the given kernel K +/** This template synthetizes an ICLSimpleFunction which runs the given kernel K */ template <typename K> class CLSynthetizeFunction : public ICLSimpleFunction { public: + /** Configure the kernel. + * + * @param[in] args Configuration arguments. + */ template <typename... Args> void configure(Args &&... args) { @@ -45,11 +49,16 @@ public: } }; -// As above but this also setups a Zero border on the input tensor of the specified bordersize +/** As above but this also setups a Zero border on the input tensor of the specified bordersize */ template <typename K, int bordersize> class CLSynthetizeFunctionWithZeroConstantBorder : public ICLSimpleFunction { public: + /** Configure the kernel. + * + * @param[in] first First configuration argument. + * @param[in] args Rest of the configuration arguments. + */ template <typename T, typename... Args> void configure(T first, Args &&... args) { diff --git a/tests/GLES_COMPUTE/GCAccessor.h b/tests/GLES_COMPUTE/GCAccessor.h index ccf4caabaf..df0fbaa72e 100644 --- a/tests/GLES_COMPUTE/GCAccessor.h +++ b/tests/GLES_COMPUTE/GCAccessor.h @@ -44,9 +44,13 @@ public: */ GCAccessor(GCTensor &tensor); + /** Prevent instances of this class from being copy constructed */ GCAccessor(const GCAccessor &) = delete; + /** Prevent instances of this class from being copied */ GCAccessor &operator=(const GCAccessor &) = delete; - GCAccessor(GCAccessor &&) = default; + /** Allow instances of this class to be move constructed */ + GCAccessor(GCAccessor &&) = default; + /** Allow instances of this class to be moved */ GCAccessor &operator=(GCAccessor &&) = default; /** Destructor that unmaps the GLES memory. */ diff --git a/tests/IAccessor.h b/tests/IAccessor.h index 6170bc0ba1..609eafec13 100644 --- a/tests/IAccessor.h +++ b/tests/IAccessor.h @@ -40,37 +40,70 @@ public: /** Virtual destructor. */ virtual ~IAccessor() = default; - /** Shape of the tensor. */ + /** Shape of the tensor. + * + * @return the shape of the tensor. + */ virtual TensorShape shape() const = 0; - /** Size of each element in the tensor in bytes. */ + /** Size of each element in the tensor in bytes. + * + * @return the size of each element in the tensor in bytes. + */ virtual size_t element_size() const = 0; - /** Total size of the tensor in bytes. */ + /** Total size of the tensor in bytes. + * + * @return the total size of the tensor in bytes. + */ virtual size_t size() const = 0; - /** Image format of the tensor. */ + /** Image format of the tensor. + * + * @return the format of the tensor. + */ virtual Format format() const = 0; - /** Data layout of the tensor. */ + /** Data layout of the tensor. + * + * @return the data layout of the tensor. + */ virtual DataLayout data_layout() const = 0; - /** Data type of the tensor. */ + /** Data type of the tensor. + * + * @return the data type of the tensor. + */ virtual DataType data_type() const = 0; - /** Number of channels of the tensor. */ + /** Number of channels of the tensor. + * + * @return the number of channels of the tensor. + */ virtual int num_channels() const = 0; - /** Number of elements of the tensor. */ + /** Number of elements of the tensor. + * + * @return the number of elements of the tensor. + */ virtual int num_elements() const = 0; - /** Available padding around the tensor. */ + /** Available padding around the tensor. + * + * @return the available padding around the tensor. + */ virtual PaddingSize padding() const = 0; - /** Number of bits for the fractional part. */ + /** Number of bits for the fractional part. + * + * @return the number of bits for the fractional part. + */ virtual int fixed_point_position() const = 0; - /** Quantization info in case of asymmetric quantized type */ + /** Quantization info in case of asymmetric quantized type + * + * @return + */ virtual QuantizationInfo quantization_info() const = 0; /** Read only access to the specified element. diff --git a/tests/IArrayAccessor.h b/tests/IArrayAccessor.h index 8c73046cd9..e5d2f94998 100644 --- a/tests/IArrayAccessor.h +++ b/tests/IArrayAccessor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -35,12 +35,16 @@ template <typename T> class IArrayAccessor { public: + /** Array value type */ using value_type = T; /** Virtual destructor. */ virtual ~IArrayAccessor() = default; - /** Number of elements of the tensor. */ + /** Number of elements of the tensor. + * + * @return the number of elements. + */ virtual size_t num_values() const = 0; /** Access to the buffer. diff --git a/tests/ILutAccessor.h b/tests/ILutAccessor.h index 6431ed141f..3178df89de 100644 --- a/tests/ILutAccessor.h +++ b/tests/ILutAccessor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -38,12 +38,16 @@ template <typename T> class ILutAccessor { public: + /** Lut value type */ using value_type = T; /** Pure virtual destructor. */ virtual ~ILutAccessor() = default; - /** Number of elements of the Lut. */ + /** Number of elements of the Lut. + * + * @return the number of elements. + */ virtual int num_elements() const = 0; /** Read access to the specified element. diff --git a/tests/NEON/Accessor.h b/tests/NEON/Accessor.h index e285f227de..60a94c20d4 100644 --- a/tests/NEON/Accessor.h +++ b/tests/NEON/Accessor.h @@ -41,11 +41,26 @@ public: */ Accessor(Tensor &tensor); + /** Prevent instances of this class from being copy constructed */ Accessor(const Accessor &) = delete; + /** Prevent instances of this class from being copied */ Accessor &operator=(const Accessor &) = delete; - Accessor(Accessor &&) = default; + /** Allow instances of this class to be move constructed */ + Accessor(Accessor &&) = default; + /** Allow instances of this class to be moved */ Accessor &operator=(Accessor &&) = default; + /** Get the tensor data. + * + * @return a constant pointer to the tensor data. + */ + const void *data() const; + /** Get the tensor data. + * + * @return a pointer to the tensor data. + */ + void *data(); + TensorShape shape() const override; size_t element_size() const override; size_t size() const override; @@ -59,8 +74,6 @@ public: QuantizationInfo quantization_info() const override; const void *operator()(const Coordinates &coord) const override; void *operator()(const Coordinates &coord) override; - const void *data() const; - void *data(); private: Tensor &_tensor; diff --git a/tests/NEON/ArrayAccessor.h b/tests/NEON/ArrayAccessor.h index 26bae10e00..e6911027a7 100644 --- a/tests/NEON/ArrayAccessor.h +++ b/tests/NEON/ArrayAccessor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -45,9 +45,13 @@ public: { } + /** Prevent instances of this class from being copy constructed */ ArrayAccessor(const ArrayAccessor &) = delete; + /** Prevent instances of this class from being copied */ ArrayAccessor &operator=(const ArrayAccessor &) = delete; - ArrayAccessor(ArrayAccessor &&) = default; + /** Allow instances of this class to be move constructed */ + ArrayAccessor(ArrayAccessor &&) = default; + /** Allow instances of this class to be moved */ ArrayAccessor &operator=(ArrayAccessor &&) = default; size_t num_values() const override diff --git a/tests/NEON/Helper.h b/tests/NEON/Helper.h index 93f2010b95..b9f961243a 100644 --- a/tests/NEON/Helper.h +++ b/tests/NEON/Helper.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -50,11 +50,15 @@ void fill_tensors(D &&dist, std::initializer_list<int> seeds, T &&tensor, Ts &&. } } -// This template synthetizes an INESimpleFunction which runs the given kernel K +/** This template synthetizes an INESimpleFunction which runs the given kernel K */ template <typename K> class NESynthetizeFunction : public INESimpleFunction { public: + /** Configure the kernel. + * + * @param[in] args Configuration arguments. + */ template <typename... Args> void configure(Args &&... args) { @@ -64,11 +68,16 @@ public: } }; -// As above but this also setups a Zero border on the input tensor of the specified bordersize +/** As above but this also setups a Zero border on the input tensor of the specified bordersize */ template <typename K, int bordersize> class NESynthetizeFunctionWithZeroConstantBorder : public INESimpleFunction { public: + /** Configure the kernel. + * + * @param[in] first First configuration argument. + * @param[in] args Rest of the configuration arguments. + */ template <typename T, typename... Args> void configure(T first, Args &&... args) { diff --git a/tests/NEON/LutAccessor.h b/tests/NEON/LutAccessor.h index 388e036edb..046d1b87ff 100644 --- a/tests/NEON/LutAccessor.h +++ b/tests/NEON/LutAccessor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -44,9 +44,13 @@ public: { } + /** Prevent instances of this class from being copy constructed */ LutAccessor(const LutAccessor &) = delete; + /** Prevent instances of this class from being copied */ LutAccessor &operator=(const LutAccessor &) = delete; - LutAccessor(LutAccessor &&) = default; + /** Allow instances of this class to be move constructed */ + LutAccessor(LutAccessor &&) = default; + /** Allow instances of this class to be moved */ LutAccessor &operator=(LutAccessor &&) = default; int num_elements() const override diff --git a/tests/RawLutAccessor.h b/tests/RawLutAccessor.h index 61b3194523..c61a0e1e55 100644 --- a/tests/RawLutAccessor.h +++ b/tests/RawLutAccessor.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -44,9 +44,13 @@ public: { } + /** Prevent instances of this class from being copy constructed */ RawLutAccessor(const RawLutAccessor &) = delete; + /** Prevent instances of this class from being copied */ RawLutAccessor &operator=(const RawLutAccessor &) = delete; - RawLutAccessor(RawLutAccessor &&) = default; + /** Allow instances of this class to be move constructed */ + RawLutAccessor(RawLutAccessor &&) = default; + /** Allow instances of this class to be moved */ RawLutAccessor &operator=(RawLutAccessor &&) = default; int num_elements() const override diff --git a/tests/RawTensor.h b/tests/RawTensor.h index 6b1b904e13..3501ad16ff 100644 --- a/tests/RawTensor.h +++ b/tests/RawTensor.h @@ -101,9 +101,17 @@ public: */ RawTensor(const RawTensor &tensor); - RawTensor &operator =(RawTensor tensor); + /** Copy the given @p tensor. + * + * @param[in] tensor To be copied tensor. + * + * @return a copy of the given tensor. + */ + RawTensor &operator=(RawTensor tensor); + /** Allow instances of this class to be move constructed */ RawTensor(RawTensor &&) = default; - ~RawTensor() = default; + /** Default destructor. */ + ~RawTensor() = default; /** Read only access to the specified element. * diff --git a/tests/SimpleTensor.h b/tests/SimpleTensor.h index f9e49bc85b..5a55a9535e 100644 --- a/tests/SimpleTensor.h +++ b/tests/SimpleTensor.h @@ -94,65 +94,104 @@ public: /** Create a deep copy of the given @p tensor. * * @param[in] tensor To be copied tensor. + * + * @return a copy of the given tensor. */ - SimpleTensor &operator =(SimpleTensor tensor); + SimpleTensor &operator=(SimpleTensor tensor); + /** Allow instances of this class to be move constructed */ SimpleTensor(SimpleTensor &&) = default; - ~SimpleTensor() = default; + /** Default destructor. */ + ~SimpleTensor() = default; + /** Tensor value type */ using value_type = T; - using Buffer = std::unique_ptr<value_type[]>; + /** Tensor buffer pointer type */ + using Buffer = std::unique_ptr<value_type[]>; friend class RawTensor; /** Return value at @p offset in the buffer. * * @param[in] offset Offset within the buffer. + * + * @return value in the buffer. */ T &operator[](size_t offset); /** Return constant value at @p offset in the buffer. * * @param[in] offset Offset within the buffer. + * + * @return constant value in the buffer. */ const T &operator[](size_t offset) const; - /** Shape of the tensor. */ + /** Shape of the tensor. + * + * @return the shape of the tensor. + */ TensorShape shape() const override; - - /** Size of each element in the tensor in bytes. */ + /** Size of each element in the tensor in bytes. + * + * @return the size of each element in the tensor in bytes. + */ size_t element_size() const override; - - /** Total size of the tensor in bytes. */ + /** Total size of the tensor in bytes. + * + * @return the total size of the tensor in bytes. + */ size_t size() const override; - - /** Data layout of the tensor. */ - DataLayout data_layout() const override; - - /** Image format of the tensor. */ + /** Image format of the tensor. + * + * @return the format of the tensor. + */ Format format() const override; - - /** Data type of the tensor. */ + /** Data layout of the tensor. + * + * @return the data layout of the tensor. + */ + DataLayout data_layout() const override; + /** Data type of the tensor. + * + * @return the data type of the tensor. + */ DataType data_type() const override; - - /** Number of channels of the tensor. */ + /** Number of channels of the tensor. + * + * @return the number of channels of the tensor. + */ int num_channels() const override; - - /** Number of elements of the tensor. */ + /** Number of elements of the tensor. + * + * @return the number of elements of the tensor. + */ int num_elements() const override; - - /** Available padding around the tensor. */ + /** Available padding around the tensor. + * + * @return the available padding around the tensor. + */ PaddingSize padding() const override; - - /** The number of bits for the fractional part of the fixed point numbers. */ + /** Number of bits for the fractional part. + * + * @return the number of bits for the fractional part. + */ int fixed_point_position() const override; - - /** Quantization info in case of asymmetric quantized type */ + /** Quantization info in case of asymmetric quantized type + * + * @return + */ QuantizationInfo quantization_info() const override; - /** Constant pointer to the underlying buffer. */ + /** Constant pointer to the underlying buffer. + * + * @return a constant pointer to the data. + */ const T *data() const; - /** Pointer to the underlying buffer. */ + /** Pointer to the underlying buffer. + * + * @return a pointer to the data. + */ T *data(); /** Read only access to the specified element. diff --git a/tests/TensorCache.h b/tests/TensorCache.h index 4bb059e203..7cf64ffbe5 100644 --- a/tests/TensorCache.h +++ b/tests/TensorCache.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -40,7 +40,7 @@ namespace test class TensorCache { public: - /* Search the cache for a tensor of created from the specified image and + /** Search the cache for a tensor of created from the specified image and * format. * * @param[in] key Key to look up the tensor. Consists of image name and format. @@ -50,7 +50,7 @@ public: */ RawTensor *find(std::tuple<const std::string &, Format> key); - /* Search the cache for a tensor of created from the specified image, + /** Search the cache for a tensor of created from the specified image, * format and channel. * * @param[in] key Key to look up the tensor. Consists of image name, format and channel. diff --git a/tests/TypeReader.h b/tests/TypeReader.h index 2be76ba63f..5c37aaba74 100644 --- a/tests/TypeReader.h +++ b/tests/TypeReader.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -32,7 +32,13 @@ namespace arm_compute { -/** Formatted input of the BorderMode type. */ +/** Formatted input of the BorderMode type. + * + * @param[out] is Input stream. + * @param[in] mode Border mode. + * + * @return the modified input stream. + */ inline ::std::istream &operator>>(::std::istream &is, BorderMode &mode) { std::string value; diff --git a/tests/Types.h b/tests/Types.h index acd82afb60..f6ceb13de4 100644 --- a/tests/Types.h +++ b/tests/Types.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -50,13 +50,14 @@ enum class GradientDimension GRAD_XY, /**< x and y gradient dimension */ }; +/** Min and max values and locations */ template <typename MinMaxType> struct MinMaxLocationValues { - MinMaxType min{}; - MinMaxType max{}; - std::vector<Coordinates2D> min_loc{}; - std::vector<Coordinates2D> max_loc{}; + MinMaxType min{}; /**< Min value */ + MinMaxType max{}; /**< Max value */ + std::vector<Coordinates2D> min_loc{}; /**< Min value location */ + std::vector<Coordinates2D> max_loc{}; /**< Max value location */ }; } // namespace arm_compute #endif /* __ARM_COMPUTE_TEST_TYPES_H__ */ diff --git a/tests/Utils.h b/tests/Utils.h index 5d24f5c0a1..e9a953d727 100644 --- a/tests/Utils.h +++ b/tests/Utils.h @@ -105,17 +105,26 @@ namespace traits { // *INDENT-OFF* // clang-format off +/** Promote a type */ template <typename T> struct promote { }; -template <> struct promote<uint8_t> { using type = uint16_t; }; -template <> struct promote<int8_t> { using type = int16_t; }; -template <> struct promote<uint16_t> { using type = uint32_t; }; -template <> struct promote<int16_t> { using type = int32_t; }; -template <> struct promote<uint32_t> { using type = uint64_t; }; -template <> struct promote<int32_t> { using type = int64_t; }; -template <> struct promote<float> { using type = float; }; -template <> struct promote<half> { using type = half; }; - - +/** Promote uint8_t to uint16_t */ +template <> struct promote<uint8_t> { using type = uint16_t; /**< Promoted type */ }; +/** Promote int8_t to int16_t */ +template <> struct promote<int8_t> { using type = int16_t; /**< Promoted type */ }; +/** Promote uint16_t to uint32_t */ +template <> struct promote<uint16_t> { using type = uint32_t; /**< Promoted type */ }; +/** Promote int16_t to int32_t */ +template <> struct promote<int16_t> { using type = int32_t; /**< Promoted type */ }; +/** Promote uint32_t to uint64_t */ +template <> struct promote<uint32_t> { using type = uint64_t; /**< Promoted type */ }; +/** Promote int32_t to int64_t */ +template <> struct promote<int32_t> { using type = int64_t; /**< Promoted type */ }; +/** Promote float to float */ +template <> struct promote<float> { using type = float; /**< Promoted type */ }; +/** Promote half to half */ +template <> struct promote<half> { using type = half; /**< Promoted type */ }; + +/** Get promoted type */ template <typename T> using promote_t = typename promote<T>::type; @@ -378,8 +387,11 @@ T saturate_cast(T val) template <typename... T> struct common_promoted_signed_type { - using common_type = typename std::common_type<T...>::type; - using promoted_type = traits::promote_t<common_type>; + /** Common type */ + using common_type = typename std::common_type<T...>::type; + /** Promoted type */ + using promoted_type = traits::promote_t<common_type>; + /** Intermediate type */ using intermediate_type = typename traits::make_signed_conditional_t<promoted_type>::type; }; @@ -388,8 +400,11 @@ struct common_promoted_signed_type template <typename... T> struct common_promoted_unsigned_type { - using common_type = typename std::common_type<T...>::type; - using promoted_type = traits::promote_t<common_type>; + /** Common type */ + using common_type = typename std::common_type<T...>::type; + /** Promoted type */ + using promoted_type = traits::promote_t<common_type>; + /** Intermediate type */ using intermediate_type = typename traits::make_unsigned_conditional_t<promoted_type>::type; }; diff --git a/tests/datasets/DepthwiseConvolutionLayerDataset.h b/tests/datasets/DepthwiseConvolutionLayerDataset.h index 4a0637d77f..0413cd0c94 100644 --- a/tests/datasets/DepthwiseConvolutionLayerDataset.h +++ b/tests/datasets/DepthwiseConvolutionLayerDataset.h @@ -113,6 +113,8 @@ private: std::vector<TensorShape> _dst_shapes{}; std::vector<PadStrideInfo> _infos{}; }; + +/** Dataset containing small, generic depthwise convolution shapes. */ class SmallDepthwiseConvolutionLayerDataset final : public DepthwiseConvolutionLayerDataset { public: @@ -135,6 +137,7 @@ public: } }; +/** Dataset containing large, generic depthwise convolution shapes. */ class LargeDepthwiseConvolutionLayerDataset final : public DepthwiseConvolutionLayerDataset { public: @@ -149,6 +152,7 @@ public: } }; +/** Dataset containing small, 3x3 depthwise convolution shapes. */ class SmallDepthwiseConvolutionLayerDataset3x3 final : public DepthwiseConvolutionLayerDataset { public: @@ -165,6 +169,7 @@ public: } }; +/** Dataset containing large, 3x3 depthwise convolution shapes. */ class LargeDepthwiseConvolutionLayerDataset3x3 final : public DepthwiseConvolutionLayerDataset { public: @@ -178,6 +183,8 @@ public: add_config(TensorShape(177U, 311U, 22U), TensorShape(3U, 3U, 22U), TensorShape(89U, 311U, 22U), PadStrideInfo(2, 1, 1, 1)); } }; + +/** Dataset containing optimized, 3x3 depthwise convolution shapes. */ class OptimizedDepthwiseConvolutionLayerDataset3x3 final : public DepthwiseConvolutionLayerDataset { public: diff --git a/tests/framework/Exceptions.h b/tests/framework/Exceptions.h index f35c35020c..687305b452 100644 --- a/tests/framework/Exceptions.h +++ b/tests/framework/Exceptions.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -94,6 +94,10 @@ public: */ LogLevel level() const; + /** Get the error message. + * + * @return error message. + */ const char *what() const noexcept override; private: diff --git a/tests/framework/Framework.h b/tests/framework/Framework.h index d7a9cfba9b..65ffc0a818 100644 --- a/tests/framework/Framework.h +++ b/tests/framework/Framework.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -65,10 +65,10 @@ namespace framework */ struct TestInfo { - int id; - std::string name; - DatasetMode mode; - TestCaseFactory::Status status; + int id; /**< Test ID */ + std::string name; /**< Test name */ + DatasetMode mode; /**< Test data set mode */ + TestCaseFactory::Status status; /**< Test status */ }; inline bool operator<(const TestInfo &lhs, const TestInfo &rhs) diff --git a/tests/framework/Profiler.h b/tests/framework/Profiler.h index 930075e214..62a3dee92e 100644 --- a/tests/framework/Profiler.h +++ b/tests/framework/Profiler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -63,7 +63,10 @@ public: /** Stop all added instruments. */ void stop(); - /** Return measurements for all instruments. */ + /** Return measurements for all instruments. + * + * @return measurements for all instruments. + */ const MeasurementsMap &measurements() const; private: diff --git a/tests/framework/TestCase.h b/tests/framework/TestCase.h index 18dd12e442..d7bf54d2fc 100644 --- a/tests/framework/TestCase.h +++ b/tests/framework/TestCase.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -40,9 +40,13 @@ namespace framework class TestCase { public: + /** Setup the test */ virtual void do_setup() {}; + /** Run the test */ virtual void do_run() {}; + /** Sync the test */ virtual void do_sync() {}; + /** Teardown the test */ virtual void do_teardown() {}; /** Default destructor. */ @@ -54,10 +58,15 @@ protected: friend class TestCaseFactory; }; +/** Data test case class */ template <typename T> class DataTestCase : public TestCase { protected: + /** Construct a data test case. + * + * @param[in] data Test data. + */ explicit DataTestCase(T data) : _data{ std::move(data) } { diff --git a/tests/framework/TestCaseFactory.h b/tests/framework/TestCaseFactory.h index b8c8cdbeb0..7164f8f3e2 100644 --- a/tests/framework/TestCaseFactory.h +++ b/tests/framework/TestCaseFactory.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -110,6 +110,7 @@ public: std::unique_ptr<TestCase> make() const override; }; +/** Implementation of a test case factory to create data test cases. */ template <typename T, typename D> class DataTestCaseFactory final : public TestCaseFactory { diff --git a/tests/framework/TestResult.h b/tests/framework/TestResult.h index e71ef95112..cdace17047 100644 --- a/tests/framework/TestResult.h +++ b/tests/framework/TestResult.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -71,8 +71,8 @@ struct TestResult { } - Status status{ Status::NOT_RUN }; //< Execution status - Profiler::MeasurementsMap measurements{}; //< Profiling information + Status status{ Status::NOT_RUN }; /**< Execution status */ + Profiler::MeasurementsMap measurements{}; /**< Profiling information */ }; } // namespace framework } // namespace test diff --git a/tests/framework/command_line/CommonOptions.h b/tests/framework/command_line/CommonOptions.h index 2da2c99874..651316c557 100644 --- a/tests/framework/command_line/CommonOptions.h +++ b/tests/framework/command_line/CommonOptions.h @@ -40,15 +40,15 @@ enum class LogFormat; enum class LogLevel; /** Common command line options used to configure the framework - * - * The options in this object get populated when "parse()" is called on the parser used to construct it. - * The expected workflow is: - * - * CommandLineParser parser; - * CommonOptions options( parser ); - * parser.parse(argc, argv); - * if(options.log_level->value() > LogLevel::NONE) --> Use the options values - */ + * + * The options in this object get populated when "parse()" is called on the parser used to construct it. + * The expected workflow is: + * + * CommandLineParser parser; + * CommonOptions options( parser ); + * parser.parse(argc, argv); + * if(options.log_level->value() > LogLevel::NONE) --> Use the options values + */ class CommonOptions { public: @@ -57,7 +57,9 @@ public: * @param[in,out] parser A parser on which "parse()" hasn't been called yet. */ CommonOptions(CommandLineParser &parser); + /** Prevent instances of this class from being copy constructed */ CommonOptions(const CommonOptions &) = delete; + /** Prevent instances of this class from being copied */ CommonOptions &operator=(const CommonOptions &) = delete; /** Create the printers based on parsed command line options * @@ -67,19 +69,19 @@ public: */ std::vector<std::unique_ptr<Printer>> create_printers(); - ToggleOption *help; - EnumListOption<InstrumentsDescription> *instruments; - SimpleOption<int> *iterations; - SimpleOption<int> *threads; - EnumOption<LogFormat> *log_format; - SimpleOption<std::string> *log_file; - EnumOption<LogLevel> *log_level; - ToggleOption *throw_errors; - ToggleOption *color_output; - ToggleOption *pretty_console; - SimpleOption<std::string> *json_file; - SimpleOption<std::string> *pretty_file; - std::vector<std::shared_ptr<std::ofstream>> log_streams; + ToggleOption *help; /**< Show help option */ + EnumListOption<InstrumentsDescription> *instruments; /**< Instruments option */ + SimpleOption<int> *iterations; /**< Number of iterations option */ + SimpleOption<int> *threads; /**< Number of threads option */ + EnumOption<LogFormat> *log_format; /**< Log format option */ + SimpleOption<std::string> *log_file; /**< Log file option */ + EnumOption<LogLevel> *log_level; /**< Logging level option */ + ToggleOption *throw_errors; /**< Throw errors option */ + ToggleOption *color_output; /**< Color output option */ + ToggleOption *pretty_console; /**< Pretty console option */ + SimpleOption<std::string> *json_file; /**< JSON output file option */ + SimpleOption<std::string> *pretty_file; /**< Pretty output file option */ + std::vector<std::shared_ptr<std::ofstream>> log_streams; /**< Log streams */ }; } // namespace framework diff --git a/tests/framework/command_line/EnumListOption.h b/tests/framework/command_line/EnumListOption.h index 6155a5da4c..39006d86b9 100644 --- a/tests/framework/command_line/EnumListOption.h +++ b/tests/framework/command_line/EnumListOption.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -60,7 +60,12 @@ public: EnumListOption(std::string name, std::set<T> allowed_values, std::initializer_list<T> &&default_values); bool parse(std::string value) override; - std::string help() const override; + std::string help() const override; + + /** Get the values of the option. + * + * @return a list of the selected option values. + */ const std::vector<T> &value() const; private: diff --git a/tests/framework/command_line/EnumOption.h b/tests/framework/command_line/EnumOption.h index 1abba77b4b..14d61859ae 100644 --- a/tests/framework/command_line/EnumOption.h +++ b/tests/framework/command_line/EnumOption.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -59,7 +59,12 @@ public: bool parse(std::string value) override; std::string help() const override; - const T &value() const; + + /** Get the selected value. + * + * @return get the selected enum value. + */ + const T &value() const; private: std::set<T> _allowed_values{}; diff --git a/tests/framework/command_line/ListOption.h b/tests/framework/command_line/ListOption.h index 8b1bb3d05a..07184e8e3b 100644 --- a/tests/framework/command_line/ListOption.h +++ b/tests/framework/command_line/ListOption.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -53,7 +53,12 @@ public: ListOption(std::string name, std::initializer_list<T> &&default_values); bool parse(std::string value) override; - std::string help() const override; + std::string help() const override; + + /** Get the list of option values. + * + * @return get the list of option values. + */ const std::vector<T> &value() const; private: diff --git a/tests/framework/command_line/SimpleOption.h b/tests/framework/command_line/SimpleOption.h index e6e8045840..d02778e781 100644 --- a/tests/framework/command_line/SimpleOption.h +++ b/tests/framework/command_line/SimpleOption.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -50,9 +50,25 @@ public: */ SimpleOption(std::string name, T default_value); + /** Parses the given string. + * + * @param[in] value String representation as passed on the command line. + * + * @return True if the value could be parsed by the specific subclass. + */ bool parse(std::string value) override; + + /** Help message for the option. + * + * @return String representing the help message for the specific subclass. + */ std::string help() const override; - const T &value() const; + + /** Get the option value. + * + * @return the option value. + */ + const T &value() const; protected: T _value{}; diff --git a/tests/framework/datasets/CartesianProductDataset.h b/tests/framework/datasets/CartesianProductDataset.h index 438a782c46..b2790d7525 100644 --- a/tests/framework/datasets/CartesianProductDataset.h +++ b/tests/framework/datasets/CartesianProductDataset.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -64,6 +64,7 @@ public: { } + /** Allow instances of this class to be move constructed */ CartesianProductDataset(CartesianProductDataset &&) = default; /** Type of the dataset. */ @@ -72,6 +73,11 @@ public: /** Iterator for the dataset. */ struct iterator { + /** Construct an iterator. + * + * @param[in] dataset1 Dataset 1. + * @param[in] dataset2 Dataset 2. + */ iterator(const T_noref *dataset1, const U_noref *dataset2) : _iter1{ dataset1->begin() }, _dataset2{ dataset2 }, @@ -79,23 +85,40 @@ public: { } + /** Allow instances of this class to be copy constructed */ iterator(const iterator &) = default; + /** Allow instances of this class to be copied */ iterator &operator=(const iterator &) = default; - iterator(iterator &&) = default; + /** Allow instances of this class to be move constructed */ + iterator(iterator &&) = default; + /** Allow instances of this class to be moved */ iterator &operator=(iterator &&) = default; + /** Default destructor */ ~iterator() = default; + /** Get the description of the current value. + * + * @return description of the current value. + */ std::string description() const { return _iter1.description() + ":" + _iter2.description(); } + /** Get the value of the iterator. + * + * @return the value of the iterator. + */ CartesianProductDataset::type operator*() const { return std::tuple_cat(*_iter1, *_iter2); } + /** Inrement the iterator. + * + * @return *this; + */ iterator &operator++() { ++_second_pos; @@ -159,6 +182,13 @@ CartesianProductDataset<T, U> combine(T &&dataset1, U &&dataset2) return CartesianProductDataset<T, U>(std::forward<T>(dataset1), std::forward<U>(dataset2)); } +/** Helper function to create a @ref CartesianProductDataset. + * + * @param[in] dataset1 First dataset. + * @param[in] dataset2 Second dataset. + * + * @return A grid dataset. + */ template <typename T, typename U> CartesianProductDataset<T, U> operator*(T &&dataset1, U &&dataset2) diff --git a/tests/framework/datasets/ContainerDataset.h b/tests/framework/datasets/ContainerDataset.h index 80616c46fc..8dfd2164c7 100644 --- a/tests/framework/datasets/ContainerDataset.h +++ b/tests/framework/datasets/ContainerDataset.h @@ -72,8 +72,10 @@ public: { } + /** Allow instances of this class to be copy constructed */ ContainerDataset(const ContainerDataset &) = default; - ContainerDataset(ContainerDataset &&) = default; + /** Allow instances of this class to be move constructed */ + ContainerDataset(ContainerDataset &&) = default; /** Type of the dataset. */ using type = std::tuple<container_value_type>; @@ -81,22 +83,39 @@ public: /** Iterator for the dataset. */ struct iterator { + /** Construct iterator + * + * @param[in] name Description of the values. + * @param[in] iterator Iterator for the values. + */ iterator(std::string name, container_const_iterator iterator) : _name{ name }, _iterator{ iterator } { } + /** Get a description of the current value. + * + * @return a description. + */ std::string description() const { using support::cpp11::to_string; return _name + "=" + to_string(*_iterator); } + /** Get the current value. + * + * @return the current value. + */ ContainerDataset::type operator*() const { return std::make_tuple(*_iterator); } + /** Increment the iterator. + * + * @return this. + */ iterator &operator++() { ++_iterator; diff --git a/tests/framework/datasets/Dataset.h b/tests/framework/datasets/Dataset.h index d91673073a..5fcdc49e01 100644 --- a/tests/framework/datasets/Dataset.h +++ b/tests/framework/datasets/Dataset.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -39,10 +39,13 @@ namespace dataset class Dataset { protected: - Dataset() = default; + /** Default constructor. */ + Dataset() = default; + /** Default destructor. */ ~Dataset() = default; public: + /** Allow instances of this class to be move constructed */ Dataset(Dataset &&) = default; }; @@ -62,9 +65,11 @@ protected: { } + /** Default destructor. */ ~NamedDataset() = default; public: + /** Allow instances of this class to be move constructed */ NamedDataset(NamedDataset &&) = default; /** Return name of the dataset. diff --git a/tests/framework/datasets/InitializerListDataset.h b/tests/framework/datasets/InitializerListDataset.h index 7d32234fab..f90e0b747a 100644 --- a/tests/framework/datasets/InitializerListDataset.h +++ b/tests/framework/datasets/InitializerListDataset.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -59,6 +59,7 @@ public: { } + /** Allow instances of this class to be move constructed */ InitializerListDataset(InitializerListDataset &&) = default; /** Type of the dataset. */ @@ -67,22 +68,39 @@ public: /** Iterator for the dataset. */ struct iterator { + /** Construct an iterator for the dataset + * + * @param[in] name Name of the dataset. + * @param[in] iterator Iterator of the dataset values. + */ iterator(std::string name, data_const_iterator iterator) : _name{ name }, _iterator{ iterator } { } + /** Get a description of the current value. + * + * @return a description. + */ std::string description() const { using support::cpp11::to_string; return _name + "=" + to_string(*_iterator); } + /** Get the current value. + * + * @return the current value. + */ InitializerListDataset::type operator*() const { return std::make_tuple(*_iterator); } + /** Increment the iterator. + * + * @return *this. + */ iterator &operator++() { ++_iterator; diff --git a/tests/framework/datasets/JoinDataset.h b/tests/framework/datasets/JoinDataset.h index d682c19d6b..bf504ec3ce 100644 --- a/tests/framework/datasets/JoinDataset.h +++ b/tests/framework/datasets/JoinDataset.h @@ -64,6 +64,7 @@ public: { } + /** Allow instances of this class to be move constructed */ JoinDataset(JoinDataset &&) = default; /** Type of the dataset. */ @@ -72,21 +73,38 @@ public: /** Iterator for the dataset. */ struct iterator { + /** Construct an iterator. + * + * @param[in] dataset1 Dataset 1. + * @param[in] dataset2 Dataset 2. + */ iterator(const T_noref *dataset1, const U_noref *dataset2) : _iter1{ dataset1->begin() }, _iter2{ dataset2->begin() }, _first_size{ dataset1->size() } { } + /** Get the description of the current value. + * + * @return description of the current value. + */ std::string description() const { return _first_size > 0 ? _iter1.description() : _iter2.description(); } + /** Get the value of the iterator. + * + * @return the value of the iterator. + */ JoinDataset::type operator*() const { return _first_size > 0 ? *_iter1 : *_iter2; } + /** Inrement the iterator. + * + * @return *this; + */ iterator &operator++() { if(_first_size > 0) diff --git a/tests/framework/datasets/RangeDataset.h b/tests/framework/datasets/RangeDataset.h index 637abe0a83..a08756694a 100644 --- a/tests/framework/datasets/RangeDataset.h +++ b/tests/framework/datasets/RangeDataset.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -60,6 +60,7 @@ public: { } + /** Allow instances of this class to be move constructed */ RangeDataset(RangeDataset &&) = default; /** Type of the dataset. */ @@ -68,22 +69,40 @@ public: /** Iterator for the dataset. */ struct iterator { + /** Construct an iterator. + * + * @param[in] name Dataset name. + * @param[in] start Dataset start value. + * @param[in] step Dataset step size. + */ iterator(std::string name, T start, T step) : _name{ name }, _value{ start }, _step{ step } { } + /** Get the description of the current value. + * + * @return description of the current value. + */ std::string description() const { using support::cpp11::to_string; return _name + "=" + to_string(_value); } + /** Get the value of the iterator. + * + * @return the value of the iterator. + */ RangeDataset::type operator*() const { return std::make_tuple(_value); } + /** Inrement the iterator. + * + * @return *this; + */ iterator &operator++() { _value += _step; diff --git a/tests/framework/datasets/SingletonDataset.h b/tests/framework/datasets/SingletonDataset.h index 1acb5765e5..47a38ec6f2 100644 --- a/tests/framework/datasets/SingletonDataset.h +++ b/tests/framework/datasets/SingletonDataset.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -56,6 +56,7 @@ public: { } + /** Allow instances of this class to be move constructed */ SingletonDataset(SingletonDataset &&) = default; /** Type of the dataset. */ @@ -64,29 +65,51 @@ public: /** Iterator for the dataset. */ struct iterator { + /** Construct an iterator. + * + * @param[in] name Name of the dataset. + * @param[in] value The singleton value. + */ iterator(std::string name, const T *value) : _name{ name }, _value{ value } { } + /** Default destructor. */ ~iterator() = default; + /** Allow instances of this class to be copy constructed */ iterator(const iterator &) = default; + /** Allow instances of this class to be copied */ iterator &operator=(const iterator &) = default; - iterator(iterator &&) = default; + /** Allow instances of this class to be move constructed */ + iterator(iterator &&) = default; + /** Allow instances of this class to be moved */ iterator &operator=(iterator &&) = default; + /** Get the description of the current value. + * + * @return description of the current value. + */ std::string description() const { using support::cpp11::to_string; return _name + "=" + to_string(*_value); } + /** Get the value of the iterator. + * + * @return the value of the iterator. + */ SingletonDataset::type operator*() const { return std::make_tuple(*_value); } + /** Inrement the iterator. + * + * @return *this; + */ iterator &operator++() { return *this; diff --git a/tests/framework/datasets/ZipDataset.h b/tests/framework/datasets/ZipDataset.h index b95b7209a7..3d93b92506 100644 --- a/tests/framework/datasets/ZipDataset.h +++ b/tests/framework/datasets/ZipDataset.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -62,6 +62,7 @@ public: { } + /** Allow instances of this class to be move constructed */ ZipDataset(ZipDataset &&) = default; /** Type of the dataset. */ @@ -70,21 +71,38 @@ public: /** Iterator for the dataset. */ struct iterator { + /** Construct an iterator. + * + * @param[in] iter1 Iterator 1. + * @param[in] iter2 Iterator 2. + */ iterator(iter1_type iter1, iter2_type iter2) : _iter1{ std::move(iter1) }, _iter2{ std::move(iter2) } { } + /** Get the description of the current value. + * + * @return description of the current value. + */ std::string description() const { return _iter1.description() + ":" + _iter2.description(); } + /** Get the value of the iterator. + * + * @return the value of the iterator. + */ ZipDataset::type operator*() const { return std::tuple_cat(*_iter1, *_iter2); } + /** Inrement the iterator. + * + * @return *this; + */ iterator &operator++() { ++_iter1; diff --git a/tests/framework/instruments/Instrument.h b/tests/framework/instruments/Instrument.h index e25939a284..0df53f4210 100644 --- a/tests/framework/instruments/Instrument.h +++ b/tests/framework/instruments/Instrument.h @@ -57,13 +57,19 @@ public: template <typename T, ScaleFactor scale> static std::unique_ptr<Instrument> make_instrument(); + /** Default constructor. */ Instrument() = default; + /** Allow instances of this class to be copy constructed */ Instrument(const Instrument &) = default; - Instrument(Instrument &&) = default; + /** Allow instances of this class to be move constructed */ + Instrument(Instrument &&) = default; + /** Allow instances of this class to be copied */ Instrument &operator=(const Instrument &) = default; + /** Allow instances of this class to be moved */ Instrument &operator=(Instrument &&) = default; - virtual ~Instrument() = default; + /** Default destructor. */ + virtual ~Instrument() = default; /** Identifier for the instrument */ virtual std::string id() const = 0; @@ -74,9 +80,13 @@ public: /** Stop measuring. */ virtual void stop() = 0; + /** Map of measurements */ using MeasurementsMap = std::map<std::string, Measurement>; - /** Return the latest measurement. */ + /** Return the latest measurement. + * + * @return the latest measurement. + */ virtual MeasurementsMap measurements() const = 0; protected: diff --git a/tests/framework/instruments/MaliCounter.h b/tests/framework/instruments/MaliCounter.h index b7c3483817..a3cc446cb2 100644 --- a/tests/framework/instruments/MaliCounter.h +++ b/tests/framework/instruments/MaliCounter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -41,10 +41,15 @@ namespace framework class MaliCounter : public Instrument { public: - /** Default constructor. */ + /** Default constructor. + * + * @param[in] scale_factor Measurement scale factor; + */ MaliCounter(ScaleFactor scale_factor); + /** Prevent instances of this class from being copy constructed */ MaliCounter(const MaliCounter &) = delete; + /** Prevent instances of this class from being copied */ MaliCounter &operator=(const MaliCounter &) = delete; /** Default destructor */ diff --git a/tests/framework/instruments/Measurement.h b/tests/framework/instruments/Measurement.h index 1beacf6cc5..5c62977b91 100644 --- a/tests/framework/instruments/Measurement.h +++ b/tests/framework/instruments/Measurement.h @@ -40,6 +40,7 @@ namespace framework /** Generic measurement that stores values as either double or long long int. */ struct Measurement { + /** Measurement value */ struct Value { /** Constructor @@ -187,6 +188,13 @@ struct Measurement } } + /** Get the relative standard deviation to a given distribution as a percentage. + * + * @param[in] variance The variance of the distribution. + * @param[in] mean The mean of the distribution. + * + * @return the relative standard deviation. + */ static double relative_standard_deviation(const Value &variance, const Value &mean) { if(variance.is_floating_point) @@ -222,6 +230,11 @@ struct Measurement /** Stream output operator to print the measurement. * * Prints value and unit. + * + * @param[out] os Output stream. + * @param[in] measurement Measurement. + * + * @return the modified output stream. */ friend inline std::ostream &operator<<(std::ostream &os, const Measurement &measurement) { diff --git a/tests/framework/instruments/OpenCLTimer.h b/tests/framework/instruments/OpenCLTimer.h index a3dc107bf8..44578782ed 100644 --- a/tests/framework/instruments/OpenCLTimer.h +++ b/tests/framework/instruments/OpenCLTimer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -42,6 +42,10 @@ namespace framework class OpenCLTimer : public Instrument { public: + /** Construct an OpenCL timer. + * + * @param[in] scale_factor Measurement scale factor. + */ OpenCLTimer(ScaleFactor scale_factor); std::string id() const override; void start() override; diff --git a/tests/framework/instruments/PMU.h b/tests/framework/instruments/PMU.h index c069a6366b..1dc41bef51 100644 --- a/tests/framework/instruments/PMU.h +++ b/tests/framework/instruments/PMU.h @@ -64,10 +64,16 @@ public: template <typename T> T get_value() const; - /** Open the specified counter based on the default configuration. */ + /** Open the specified counter based on the default configuration. + * + * @param[in] config The default configuration. + */ void open(uint64_t config); - /** Open the specified configuration. */ + /** Open the specified configuration. + * + * @param[in] perf_config The specified configuration. + */ void open(const perf_event_attr &perf_config); /** Close the currently open counter. */ diff --git a/tests/framework/instruments/PMUCounter.h b/tests/framework/instruments/PMUCounter.h index e1b9433eda..0719b10864 100644 --- a/tests/framework/instruments/PMUCounter.h +++ b/tests/framework/instruments/PMUCounter.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -37,6 +37,10 @@ namespace framework class PMUCounter : public Instrument { public: + /** Construct a PMU counter. + * + * @param[in] scale_factor Measurement scale factor. + */ PMUCounter(ScaleFactor scale_factor) { switch(scale_factor) diff --git a/tests/framework/instruments/SchedulerTimer.h b/tests/framework/instruments/SchedulerTimer.h index 446506ad73..ec282cc905 100644 --- a/tests/framework/instruments/SchedulerTimer.h +++ b/tests/framework/instruments/SchedulerTimer.h @@ -38,13 +38,23 @@ namespace framework class SchedulerTimer : public Instrument { public: + /** Construct a Scheduler timer. + * + * @param[in] scale_factor Measurement scale factor. + */ + SchedulerTimer(ScaleFactor scale_factor); + + /** Prevent instances of this class from being copy constructed */ SchedulerTimer(const SchedulerTimer &) = delete; + /** Prevent instances of this class from being copied */ SchedulerTimer &operator=(const SchedulerTimer &) = delete; - SchedulerTimer(ScaleFactor scale_factor); + std::string id() const override; void start() override; void stop() override; Instrument::MeasurementsMap measurements() const override; + + /** Kernel information */ struct kernel_info { Instrument::MeasurementsMap measurements{}; /**< Time it took the kernel to run */ diff --git a/tests/framework/instruments/WallClockTimer.h b/tests/framework/instruments/WallClockTimer.h index 468f4d3a8f..c9829aea12 100644 --- a/tests/framework/instruments/WallClockTimer.h +++ b/tests/framework/instruments/WallClockTimer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -38,6 +38,10 @@ namespace framework class WallClockTimer : public Instrument { public: + /** Construct a Wall clock timer. + * + * @param[in] scale_factor Measurement scale factor. + */ WallClockTimer(ScaleFactor scale_factor) { switch(scale_factor) diff --git a/tests/framework/instruments/hwc.hpp b/tests/framework/instruments/hwc.hpp index 3607ef574e..8c48e0ca45 100644 --- a/tests/framework/instruments/hwc.hpp +++ b/tests/framework/instruments/hwc.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -37,6 +37,8 @@ #include <sys/mman.h> #include <unistd.h> +#ifndef DOXYGEN_SKIP_THIS + #if defined(ANDROID) || defined(__ANDROID__) /* We use _IOR_BAD/_IOW_BAD rather than _IOR/_IOW otherwise fails to compile with NDK-BUILD because of _IOC_TYPECHECK is defined, not because the paramter is invalid */ #define MALI_IOR(a, b, c) _IOR_BAD(a, b, c) @@ -387,4 +389,7 @@ static inline int mali_ioctl(int fd, T &arg) return 0; } } // namespace mali_userspace + +#endif /* DOXYGEN_SKIP_THIS */ + #endif /* ARM_COMPUTE_TEST_HWC */ diff --git a/tests/framework/instruments/hwc_names.hpp b/tests/framework/instruments/hwc_names.hpp index ffc19b56e5..cbcb0e788e 100644 --- a/tests/framework/instruments/hwc_names.hpp +++ b/tests/framework/instruments/hwc_names.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -24,6 +24,8 @@ #ifndef ARM_COMPUTE_TEST_HWC_NAMES #define ARM_COMPUTE_TEST_HWC_NAMES +#ifndef DOXYGEN_SKIP_THIS + namespace mali_userspace { enum MaliCounterBlockName @@ -3056,4 +3058,7 @@ enum NUM_PRODUCTS = sizeof(products) / sizeof(products[0]) }; } // namespace mali_userspace + +#endif /* DOXYGEN_SKIP_THIS */ + #endif /* ARM_COMPUTE_TEST_HWC_NAMES */ diff --git a/tests/framework/printers/Printer.h b/tests/framework/printers/Printer.h index cb0aa1e4c2..cbe22fb2a6 100644 --- a/tests/framework/printers/Printer.h +++ b/tests/framework/printers/Printer.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -55,11 +55,16 @@ public: */ Printer(std::ostream &stream); + /** Prevent instances of this class from being copy constructed */ Printer(const Printer &) = delete; + /** Prevent instances of this class from being copied */ Printer &operator=(const Printer &) = delete; - Printer(Printer &&) = default; + /** Allow instances of this class to be move constructed */ + Printer(Printer &&) = default; + /** Allow instances of this class to be moved */ Printer &operator=(Printer &&) = default; + /** Default destructor. */ virtual ~Printer() = default; /** Print given string. diff --git a/tests/networks/AlexNetNetwork.h b/tests/networks/AlexNetNetwork.h index 819111f897..a30b7f8f75 100644 --- a/tests/networks/AlexNetNetwork.h +++ b/tests/networks/AlexNetNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -54,6 +54,13 @@ template <typename ITensorType, class AlexNetNetwork { public: + /** Initialize the network. + * + * @param[in] data_type Data type. + * @param[in] fixed_point_position Fixed point position (for quantized data types). + * @param[in] batches Number of batches. + * @param[in] reshaped_weights Whether the weights need reshaping or not. Default: false. + */ void init(DataType data_type, int fixed_point_position, int batches, bool reshaped_weights = false) { _data_type = data_type; @@ -185,6 +192,7 @@ public: } } + /** Build the network */ void build() { input.allocator()->init(TensorInfo(TensorShape(227U, 227U, 3U, _batches), 1, _data_type, _fixed_point_position)); @@ -270,6 +278,7 @@ public: smx.configure(&fc8_out, &output); } + /** Allocate the network */ void allocate() { input.allocator()->allocate(); diff --git a/tests/networks/LeNet5Network.h b/tests/networks/LeNet5Network.h index a46489f88c..9cfd59284c 100644 --- a/tests/networks/LeNet5Network.h +++ b/tests/networks/LeNet5Network.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -50,6 +50,10 @@ template <typename TensorType, class LeNet5Network { public: + /** Initialize the network. + * + * @param[in] batches Number of batches. + */ void init(int batches) { _batches = batches; @@ -94,6 +98,7 @@ public: smx.configure(&fc2_out, &output); } + /** Allocate the network */ void allocate() { // Allocate tensors diff --git a/tests/networks/MobileNetNetwork.h b/tests/networks/MobileNetNetwork.h index 8c3cb1fb2d..ec054b237e 100644 --- a/tests/networks/MobileNetNetwork.h +++ b/tests/networks/MobileNetNetwork.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -53,6 +53,10 @@ template <typename TensorType, class MobileNetNetwork { public: + /** Initialize the network. + * + * @param[in] batches Number of batches. + */ void init(int batches) { _batches = batches; @@ -105,6 +109,7 @@ public: reshape.configure(&conv_out[14], &output); } + /** Allocate the network. */ void allocate() { input.allocator()->allocate(); diff --git a/tests/networks/MobileNetV1Network.h b/tests/networks/MobileNetV1Network.h index 0957c6b555..aea5c113e8 100644 --- a/tests/networks/MobileNetV1Network.h +++ b/tests/networks/MobileNetV1Network.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -55,6 +55,11 @@ template <typename TensorType, class MobileNetV1Network { public: + /** Initialize the network. + * + * @param[in] input_spatial_size Size of the spatial input. + * @param[in] batches Number of batches. + */ void init(unsigned int input_spatial_size, int batches) { _batches = batches; @@ -117,6 +122,7 @@ public: smx.configure(&reshape_out, &output); } + /** Allocate the network. */ void allocate() { input.allocator()->allocate(); diff --git a/tests/validation/FixedPoint.h b/tests/validation/FixedPoint.h index 9691e2a037..81c4f53724 100644 --- a/tests/validation/FixedPoint.h +++ b/tests/validation/FixedPoint.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 ARM Limited. + * Copyright (c) 2017-2018 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -54,15 +54,26 @@ namespace traits // Promote types // *INDENT-OFF* // clang-format off +/** Promote a type */ template <typename T> struct promote { }; -template <> struct promote<uint8_t> { using type = uint16_t; }; -template <> struct promote<int8_t> { using type = int16_t; }; -template <> struct promote<uint16_t> { using type = uint32_t; }; -template <> struct promote<int16_t> { using type = int32_t; }; -template <> struct promote<uint32_t> { using type = uint64_t; }; -template <> struct promote<int32_t> { using type = int64_t; }; -template <> struct promote<uint64_t> { using type = uint64_t; }; -template <> struct promote<int64_t> { using type = int64_t; }; +/** Promote uint8_t to uint16_t */ +template <> struct promote<uint8_t> { using type = uint16_t; /**< Promoted type */ }; +/** Promote int8_t to int16_t */ +template <> struct promote<int8_t> { using type = int16_t; /**< Promoted type */ }; +/** Promote uint16_t to uint32_t */ +template <> struct promote<uint16_t> { using type = uint32_t; /**< Promoted type */ }; +/** Promote int16_t to int32_t */ +template <> struct promote<int16_t> { using type = int32_t; /**< Promoted type */ }; +/** Promote uint32_t to uint64_t */ +template <> struct promote<uint32_t> { using type = uint64_t; /**< Promoted type */ }; +/** Promote int32_t to int64_t */ +template <> struct promote<int32_t> { using type = int64_t; /**< Promoted type */ }; +/** Promote float to float */ +template <> struct promote<float> { using type = float; /**< Promoted type */ }; +/** Promote half to half */ +template <> struct promote<half> { using type = half; /**< Promoted type */ }; + +/** Get promoted type */ template <typename T> using promote_t = typename promote<T>::type; // clang-format on @@ -281,6 +292,7 @@ constexpr int clz(T value) return __builtin_clz(value) - (32 - std::numeric_limits<unsigned_T>::digits); } +/** Constant expressions */ template <typename T> struct constant_expr { @@ -362,6 +374,7 @@ struct constant_expr return static_cast<T>(std::min<U>(std::max<U>(val, static_cast<U>(std::numeric_limits<T>::min())), static_cast<U>(std::numeric_limits<T>::max()))); } }; +/** Functions */ struct functions { /** Output stream operator diff --git a/tests/validation/Helpers.h b/tests/validation/Helpers.h index b192f317b4..b5597090c6 100644 --- a/tests/validation/Helpers.h +++ b/tests/validation/Helpers.h @@ -151,10 +151,10 @@ TensorShape calculate_depth_concatenate_shape(const std::vector<TensorShape> &in /** Parameters of Harris Corners algorithm. */ struct HarrisCornersParameters { - float threshold{ 0.f }; - float sensitivity{ 0.f }; - float min_dist{ 0.f }; - uint8_t constant_border_value{ 0 }; + float threshold{ 0.f }; /**< Threshold */ + float sensitivity{ 0.f }; /**< Sensitivity */ + float min_dist{ 0.f }; /**< Minimum distance */ + uint8_t constant_border_value{ 0 }; /**< Border value */ }; /** Generate parameters for Harris Corners algorithm. */ diff --git a/tests/validation/Validation.h b/tests/validation/Validation.h index b5f3a4a57a..26271c8bf3 100644 --- a/tests/validation/Validation.h +++ b/tests/validation/Validation.h @@ -69,7 +69,10 @@ public: { } - /** Implicit conversion to the underlying type. */ + /** Implicit conversion to the underlying type. + * + * @return the underlying type. + */ constexpr operator T() const { return _value; @@ -102,7 +105,10 @@ public: { } - /** Implicit conversion to the underlying type. */ + /** Implicit conversion to the underlying type. + * + * @return the underlying type. + */ constexpr operator value_type() const { return _value; @@ -241,27 +247,36 @@ template <typename T, typename U, typename V = AbsoluteTolerance<float>> void validate_keypoints(T target_first, T target_last, U reference_first, U reference_last, V tolerance = AbsoluteTolerance<float>(), float allowed_missing_percentage = 5.f, float allowed_mismatch_percentage = 5.f); +/** Compare values with a tolerance. */ template <typename T> struct compare_base { + /** Construct a comparison object. + * + * @param[in] target Target value. + * @param[in] reference Reference value. + * @param[in] tolerance Allowed tolerance. + */ compare_base(typename T::value_type target, typename T::value_type reference, T tolerance = T(0)) : _target{ target }, _reference{ reference }, _tolerance{ tolerance } { } - typename T::value_type _target{}; - typename T::value_type _reference{}; - T _tolerance{}; + typename T::value_type _target{}; /**< Target value */ + typename T::value_type _reference{}; /**< Reference value */ + T _tolerance{}; /**< Tolerance value */ }; template <typename T> struct compare; +/** Compare values with an absolute tolerance */ template <typename U> struct compare<AbsoluteTolerance<U>> : public compare_base<AbsoluteTolerance<U>> { using compare_base<AbsoluteTolerance<U>>::compare_base; + /** Perform comparison */ operator bool() const { if(!support::cpp11::isfinite(this->_target) || !support::cpp11::isfinite(this->_reference)) @@ -281,11 +296,13 @@ struct compare<AbsoluteTolerance<U>> : public compare_base<AbsoluteTolerance<U>> } }; +/** Compare values with a relative tolerance */ template <typename U> struct compare<RelativeTolerance<U>> : public compare_base<RelativeTolerance<U>> { using compare_base<RelativeTolerance<U>>::compare_base; + /** Perform comparison */ operator bool() const { if(!support::cpp11::isfinite(this->_target) || !support::cpp11::isfinite(this->_reference)) |