hbDNNTensorProperties

typedef struct { hbDNNTensorShape validShape; hbDNNTensorShape alignedShape; int32_t tensorLayout; int32_t tensorType; hbDNNQuantiShift shift; hbDNNQuantiScale scale; hbDNNQuantiType quantiType; int32_t quantizeAxis; int32_t alignedByteSize; int32_t stride[HB_DNN_TENSOR_MAX_DIMENSIONS]; } hbDNNTensorProperties;

Tensor information.

  • Member
Member NameDescription
validShape

Shape of the valid content of the tensor.

alignedShape

Shape of the aligned content of the tensor.

tensorLayout

Tensor layout form.

tensorType

Tensor type.

shift

Shift of quantization.

scale

Scale of quantization.

quantiType

Quantization type.

quantizeAxis

Index of the quantization axis, effective only when quantified by per-axis.

alignedByteSize

Memory size of the aligned content of the tensor.

stride

Step size of each dimension of validShape, measured in Bytes.

Note

If some dimensions in the validShape field are -1, it means that the validShape of the model is a dynamic input in this dimension, and you need to fill it in according to the actual input before creating a task.

The tensorLayout is compatible with J5, which is deprecated in J6.

The alignedShape is compatible with J5, which is not recommended for J6, using stride is recommended for aligning sizes.

The quantizeAxis represents the dimension of the quantization axis index and is only effective during per-axis quantization. When the data is quantized with per-tensor, quantizeAxis is negative.

The tensor information obtained through the interface is required by the model, you can modify the corresponding tensor information according to the actual input, at present, you are only allowed to modify the information of stride and tensorType, and must meet the requirements.

stride:

  1. If you prepare your input based on stride, you do not need to modify the stride.

  2. If you prepare your input based on validShape, you need to modify the value of stride to be the step size of the jumps in each dimension of validShape, and the inference library will internally padding the data.

  3. If some dimensions of the stride obtained from the model are -1, it means that the stride of the model is a dynamic input in this dimension, and you need to fill it in according to the actual input before creating a task. For the constraints of filling in, please refer to the Dynamic Input Introduction section.

tensorType:

When inferring the model with NV12 input, you can modify the tensorType of the tensor to HB_DNN_IMG_TYPE_NV12 or HB_DNN_IMG_TYPE_NV12_SEPARATE based on the actual situation.

The alignedByteSize represents the size of the memory space occupied in the tensor, which can generally be used to apply for input and output memory.