aclSetTensorShapeRange

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Function Usage

Sets the size range of each dimension of a tensor after a tensor description is created by the aclCreateTensorDesc call.

Application scenario: For a dynamic-shape operator, a dynamic dimension is represented by –1. However, the value range of each dynamic dimension is different and needs to be set explicitly. For example, if the tensor shape is [16, –1, 20, –1], the corresponding shape range can be [[16, 16], [1, 128], [20, 20], [1, 10]]. This indicates that the first dimension is fixed at 16, the second dimension is sized 1–128, the third dimension is fixed at 20, and the fourth dimension is sized 1–10.

Prototype

1
aclError aclSetTensorShapeRange(aclTensorDesc* desc, size_t dimsCount, int64_t dimsRange[][ACL_TENSOR_SHAPE_RANGE_NUM])

Parameters

Parameter

Input/Output

Description

desc

Output

Pointer to data of the aclTensorDesc type.

Call aclCreateTensorDesc to create data of the aclTensorDesc type in advance.

dimsCount

Input

Number of dimensions of the tensor.

dimsRange

Input

A 2D array for the size range of each dimension.

A dimension represented by a value other than –1 is a fixed dimension. The maximum size and minimum size of the dimension are the same. A dimension represented by –1 is a dynamic dimension. The corresponding array specifies the minimum size and maximum size of the dimension, respectively.

#define ACL_TENSOR_SHAPE_RANGE_NUM 2

Returns

0 on success; else, failure. For details, see aclError.