Function: set_tensor_shape_range

C Prototype

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

Python Function

ret = acl.set_tensor_shape_range(desc, dims_range)

Function Usage

Sets the shape range of each dimension of a tensor after a tensor description is created by the acl.create_tensor_desc call.

Use case: 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's shape size is fixed at 16, the second dimension's shape size ranges from 1 to 128, the third dimension's shape size is fixed at 20, and the fourth dimension's shape size ranges from 1 to 10.

Input Description

desc: int, pointer address of the tensor description data.

Call acl.create_tensor_desc to create data of the aclTensorDesc type in advance.

dims_range: list. A two-dimensional list is used to indicate the value range of each dimension.

Return Value

ret: int, error code.

Restrictions

None