liblarod  @VERSION_STR@
Data Fields
larodTensorPitches Struct Reference

A type containing information about a tensor's pitches. More...

#include <larod.h>

Data Fields

size_t len
 Length of pitches array.

Detailed Description

A type containing information about a tensor's pitches.

As part of larodTensor this is used to define pitches of a tensor. For most layouts pitches should be interpreted as the byte size of the elements plus any padding added because of some alignment requirement in each dimension; i.e. as many bytes as one has to traverse to reach the next element of the neighboring left dimension. This is calculated going from right to left. Note that the first element, pitches[0], corresponds to the total byte size of the tensor's data. This interpretation is modified when LAROD_TENSOR_LAYOUT_420SP is used. For more info, see larodTensorLayout, and example 3 below.

This general definition permits alignment requirements in all dimensions. Often, one only deals with alignment in the width dimension and refers to "row pitch" as the pitch in that specific dimension.

Example 1: Consider a tensor with layout LAROD_TENSOR_LAYOUT_NCHW, data type float32, dims (1, 3, 250, 250) and an alignment requirement of 32 bytes in the 4th dimension. Starting from the right-most dimension, the 4th pitch is then equal to the byte size of one row: ceil(250 * sizeof(float32) / 32) * 32 = 32 * 32 = 1024. The 4th pitch would then correspond to the "row pitch" for this given larodTensorLayout. The rest of the pitches are calculated as (1 * 3 * 250 * 1024, 3 * 250 * 1024, 250 * 1024, 1024).

Example 2: A tensor with layout LAROD_TENSOR_LAYOUT_NHWC, dims (1, 224, 300, 3), uint8 as data type, and alignment requirements of 32 and 4 bytes in the 3rd and 4th dimensions respectively, gives the pitches (1 * 224 * 1216, 224 * 1216, 1216, 4), since ceil(3 * sizeof(uint8) / 4) * 4 = 4 and ceil(300

Example 3: As an example of LAROD_TENSOR_LAYOUT_420SP consider an image with data type uint8, pixel height of 224, pixel width of 300, an alignment requirement on the width of 32 bytes, and an alignment requirement on the plane separated data part of 32 bytes. The last element, pitches[2], describing the total size of a row, would be 320, since ceil(300 * sizeof(uint8) / 32) * 32 = 320. The second element, pitches[1], describing the total size of the separated data plane would be given by ceil(224 * 320 / 32) * 32 = 224 * 320 = 71680. Finally the first element of pitches would be given by the sum of the two parts of the data, the separated part, and the interleaved part, possibly with additional padding on the end. In this case it would simply be 224 * 320 + 224 * 320 / 2 = 107520.

If len is set to 0 for an input or output tensor when running a job, there will be no sanity check that it matches what the model expects. If len is specified, it must be equal to the len of its dimensions if that is also specified; otherwise one gets an error when creating requests.

The documentation for this struct was generated from the following file: