From cde1e8adeacea5c33a1682ef7b05a0ef643463b8 Mon Sep 17 00:00:00 2001 From: Moritz Pflanzer Date: Fri, 8 Sep 2017 09:53:14 +0100 Subject: COMPMID-415: Add tests for ConvolutionLayer reshaped weights Change-Id: I6c1209a2afafccba2cbdbcda16aceb3ae0cc7b4b Reviewed-on: http://mpd-gerrit.cambridge.arm.com/87000 Tested-by: Kaizen Reviewed-by: Gian Marco Iodice --- tests/RawTensor.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'tests/RawTensor.h') diff --git a/tests/RawTensor.h b/tests/RawTensor.h index fd0ab2b9fd..116275d617 100644 --- a/tests/RawTensor.h +++ b/tests/RawTensor.h @@ -55,6 +55,44 @@ public: */ RawTensor(TensorShape shape, DataType data_type, int num_channels = 1, int fixed_point_position = 0); + /** Conversion constructor from SimpleTensor. + * + * The passed SimpleTensor will be destroyed after it has been converted to + * a RawTensor. + * + * @param[in,out] tensor SimpleTensor to be converted to a RawTensor. + */ + template + RawTensor(SimpleTensor &&tensor) + { + _buffer = std::unique_ptr(reinterpret_cast(tensor._buffer.release())); + _shape = std::move(tensor._shape); + _format = tensor._format; + _data_type = tensor._data_type; + _num_channels = tensor._num_channels; + _fixed_point_position = tensor._fixed_point_position; + } + + /** Conversion operator to SimpleTensor. + * + * The current RawTensor must not be used after the conversion. + * + * @return SimpleTensor of the given type. + */ + template + operator SimpleTensor() + { + SimpleTensor cast; + cast._buffer = std::unique_ptr(reinterpret_cast(_buffer.release())); + cast._shape = std::move(_shape); + cast._format = _format; + cast._data_type = _data_type; + cast._num_channels = _num_channels; + cast._fixed_point_position = _fixed_point_position; + + return cast; + } + /** Create a deep copy of the given @p tensor. * * @param[in] tensor To be copied tensor. -- cgit v1.2.1