From 4a65b9855f71fff11a4c18d2fa4bccc74303e5c6 Mon Sep 17 00:00:00 2001 From: Michele Di Giorgio Date: Fri, 2 Mar 2018 11:21:38 +0000 Subject: COMPMID-991: Add data layout information to the test framework Change-Id: Iccf66f7476e697e8fdee5a7441cc06b936bbba09 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/122986 Reviewed-by: Michalis Spyrou Tested-by: Jenkins --- tests/SimpleTensor.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'tests/SimpleTensor.h') diff --git a/tests/SimpleTensor.h b/tests/SimpleTensor.h index f3155ffeab..f9e49bc85b 100644 --- a/tests/SimpleTensor.h +++ b/tests/SimpleTensor.h @@ -77,10 +77,13 @@ public: * @param[in] num_channels (Optional) Number of channels (default = 1). * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers (default = 0). * @param[in] quantization_info (Optional) Quantization info for asymmetric quantization (default = empty). + * @param[in] data_layout (Optional) Data layout of the tensor (default = NCHW). */ SimpleTensor(TensorShape shape, DataType data_type, - int num_channels = 1, - int fixed_point_position = 0, QuantizationInfo quantization_info = QuantizationInfo()); + int num_channels = 1, + int fixed_point_position = 0, + QuantizationInfo quantization_info = QuantizationInfo(), + DataLayout data_layout = DataLayout::NCHW); /** Create a deep copy of the given @p tensor. * @@ -122,6 +125,9 @@ public: /** 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. */ Format format() const override; @@ -181,6 +187,7 @@ protected: int _num_channels{ 0 }; int _fixed_point_position{ 0 }; QuantizationInfo _quantization_info{}; + DataLayout _data_layout{ DataLayout::UNKNOWN }; }; template @@ -196,13 +203,14 @@ SimpleTensor::SimpleTensor(TensorShape shape, Format format, int fixed_point_ } template -SimpleTensor::SimpleTensor(TensorShape shape, DataType data_type, int num_channels, int fixed_point_position, QuantizationInfo quantization_info) +SimpleTensor::SimpleTensor(TensorShape shape, DataType data_type, int num_channels, int fixed_point_position, QuantizationInfo quantization_info, DataLayout data_layout) : _buffer(nullptr), _shape(shape), _data_type(data_type), _num_channels(num_channels), _fixed_point_position(fixed_point_position), - _quantization_info(quantization_info) + _quantization_info(quantization_info), + _data_layout(data_layout) { _buffer = support::cpp14::make_unique(num_elements() * this->num_channels()); } @@ -278,6 +286,12 @@ Format SimpleTensor::format() const return _format; } +template +DataLayout SimpleTensor::data_layout() const +{ + return _data_layout; +} + template DataType SimpleTensor::data_type() const { -- cgit v1.2.1