MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / RawTensor

Class RawTensor

tests/RawTensor.h:38–127  ·  view source on GitHub ↗

Subclass of SimpleTensor using uint8_t as value type. * * Access operations (except for operator[]) will be based on the data type to * copy the right number of elements. */

Source from the content-addressed store, hash-verified

36 * copy the right number of elements.
37 */
38class RawTensor : public SimpleTensor<uint8_t>
39{
40public:
41 /** Create an uninitialised tensor of the given @p shape and @p format.
42 *
43 * @param[in] shape Shape of the new raw tensor.
44 * @param[in] format Format of the new raw tensor.
45 */
46 RawTensor(TensorShape shape, Format format);
47
48 /** Create an uninitialised tensor of the given @p shape and @p data type.
49 *
50 * @param[in] shape Shape of the new raw tensor.
51 * @param[in] data_type Data type of the new raw tensor.
52 * @param[in] num_channels (Optional) Number of channels (default = 1).
53 */
54 RawTensor(TensorShape shape, DataType data_type, int num_channels = 1);
55
56 /** Conversion constructor from SimpleTensor.
57 *
58 * The passed SimpleTensor will be destroyed after it has been converted to
59 * a RawTensor.
60 *
61 * @param[in,out] tensor SimpleTensor to be converted to a RawTensor.
62 */
63 template <typename T>
64 RawTensor(SimpleTensor<T> &&tensor)
65 {
66 _buffer = std::unique_ptr<uint8_t[]>(reinterpret_cast<uint8_t *>(tensor._buffer.release()));
67 _shape = std::move(tensor._shape);
68 _format = tensor._format;
69 _data_type = tensor._data_type;
70 _num_channels = tensor._num_channels;
71 _data_layout = tensor._data_layout;
72 }
73
74 /** Conversion operator to SimpleTensor.
75 *
76 * The current RawTensor must not be used after the conversion.
77 *
78 * @return SimpleTensor of the given type.
79 */
80 template <typename T>
81 operator SimpleTensor<T>()
82 {
83 SimpleTensor<T> cast;
84 cast._buffer = std::unique_ptr<T[]>(reinterpret_cast<T *>(_buffer.release()));
85 cast._shape = std::move(_shape);
86 cast._format = _format;
87 cast._data_type = _data_type;
88 cast._num_channels = _num_channels;
89 cast._data_layout = _data_layout;
90
91 return cast;
92 }
93
94 /** Create a deep copy of the given @p tensor.
95 *

Callers 1

getMethod · 0.70

Calls 1

releaseMethod · 0.45

Tested by

no test coverage detected