@@ -12,7 +12,7 @@ shape of this array, its data format, and the way it is organized in memory.
1212 typedef struct mli_tensor {
1313 mli_data_container data;
1414 uint32_t shape[MLI_MAX_RANK];
15- uint32_t mem_stride[MLI_MAX_RANK];
15+ int32_t mem_stride[MLI_MAX_RANK];
1616 uint32_t rank;
1717 mli_element_type el_type;
1818 mli_element_params el_params;
@@ -86,7 +86,7 @@ and ``mli_data_container`` is defined as follows:
8686..
8787
8888
89- Table :ref: `mli_tnsr_struc ` describes the fields in the mli_tensor structure.
89+ The table :ref: `mli_tnsr_struc ` describes the fields in the mli_tensor structure.
9090
9191.. _mli_tnsr_struc :
9292.. table:: mli_tensor Structure Field Descriptions
@@ -109,23 +109,40 @@ Table :ref:`mli_tnsr_struc` describes the fields in the mli_tensor structure.
109109 | | | scalar tensors (tensors with a single element), this field is not a |
110110 | | | pointer, but it contains the data itself. |
111111 +-------------------+------------------------+-----------------------------------------------------------------------------+
112- | ``data.capacity `` | ``unit32_t `` | Size in bytes of the allocated memory that the data field points to. In |
112+ | ``data.capacity `` | ``uint32_t `` | Size in bytes of the allocated memory that the data field points to. In |
113113 | | | case there is no buffer attached (``rank == 0 ``), the capacity is set to 0. |
114114 +-------------------+------------------------+-----------------------------------------------------------------------------+
115- | ``shape `` | ``unit32_t [] `` | Array with tensor dimensions. Dimensions are stored in order starting from |
115+ | ``shape `` | ``uint32_t [] `` | Array with tensor dimensions. Dimensions are stored in order starting from |
116116 | | | the one with the largest stride between the data portions. |
117117 | | | For example, for tensor T of size (channels, height width) stored in HWC |
118118 | | | layout, shape[0] = height, shape[1] = width, shape[2] = channels. Shape[3] |
119119 | | | is unused. The size of the array is defined by ``MLI_MAX_RANK* ``. |
120120 +-------------------+------------------------+-----------------------------------------------------------------------------+
121- | ``mem_stride `` | ``unit32_t[] `` | Array with the distance (in elements) to the next element in the same |
122- | | | dimension. To compute the size in bytes, the number of elements needs to be |
121+ | ``mem_stride `` | ``int32_t[] `` | Array with the distance (in elements) to the next element in the same |
122+ | | | dimension. Positive values are supported only. |
123+ | | | To compute the size in bytes, the number of elements needs to be |
123124 | | | multiplied by the bytes per element. For example, for a matrix |
124125 | | | A(rows,columns), ``mem_stride[1] `` contains the distance to the next |
125126 | | | element (=1 in this example), and ``mem_stride[0] `` contains the distance |
126127 | | | from one row to the next (=columns in this example). The size of the array |
127128 | | | is defined by ``MLI_MAX_RANK* ``.If the mem_stride is set to 0, it is |
128129 | | | computed from the shape. |
130+ | | | |
131+ | | | Manually-set values of ``mem_stride `` array must decrease gradually and |
132+ | | | must not be less than if they would be computed from the shape. For |
133+ | | | example, for a tensor of shape :math: `[Height, Width, Channels)`: |
134+ | | | |
135+ | | | - ``mem_stride[0] >= 1 x Channels x Width `` |
136+ | | | AND ``mem_stride[0] >= mem_stride[1] `` |
137+ | | | |
138+ | | | - ``mem_stride[1] >= 1*Channels `` AND ``mem_stride[1] >= mem_stride[2] `` |
139+ | | | |
140+ | | | - ``mem_stride[2] >= 1 `` |
141+ | | | |
142+ | | | In case the mem_stride is computed from the shape, the kernel does not |
143+ | | | update this field in the tensor struct. The only exception is the |
144+ | | | ``mli_move `` function, which can write the ``mem_stride `` field of the |
145+ | | | ``dst `` tensor. |
129146 +-------------------+------------------------+-----------------------------------------------------------------------------+
130147 | ``rank `` | ``uint32_t `` | Number of dimensions of this tensor (Must be less or equal to |
131148 | | | ``MLI_MAX_RANK* ``) |
@@ -169,12 +186,12 @@ channels in the tensor ``(array_size = shape[dim])``.
169186 | | | - ``sa.dim >= 0 ``: Pointer to an array of zero points relating to |
170187 | | | configured dimension (``sa.dim ``). |
171188 +------------------------+------------------------+-----------------------------------------------------------------------------+
172- | ``sa.scale `` | ``mli_data_container `` | 16-bit signed scale factors. |
189+ | ``sa.scale `` | ``mli_data_container `` | 16-bit signed scale factors. Only positive scale factors are supported. |
173190 | | | |
174- | | | - ``sa.dim < 0 ``: Single value for all data in tensor |
191+ | | | - If ``sa.dim < 0 ``: `` sa.scale `` is a single value for all data in tensor |
175192 | | | |
176- | | | - ``sa.dim >= 0 ``: Pointer to an array of scale factors related to |
177- | | | configured dimension (``sa.dim ``). |
193+ | | | - If ``sa.dim >= 0 ``: `` sa.scale `` is a pointer to an array of |
194+ | | | scale factors related to configured dimension (``sa.dim ``). |
178195 +------------------------+------------------------+-----------------------------------------------------------------------------+
179196 | ``sa.dim `` | ``int32_t `` | Tensor dimension to which the arrays of quantization parameters apply |
180197 +------------------------+------------------------+-----------------------------------------------------------------------------+
0 commit comments