Function: set_tensor_shape_range

Applicability

Product

Supported (√/x)

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas training products

Atlas inference products

Atlas 200I/500 A2 inference products

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.

Prototype

  • C Prototype
    1
    aclError aclSetTensorShapeRange(aclTensorDesc* desc, size_t dimsCount, int64_t dimsRange[][ACL_TENSOR_SHAPE_RANGE_NUM])
    
  • Python Function
    1
    ret = acl.set_tensor_shape_range(desc, dims_range)
    

Parameter Description

Parameter

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 Description

Return Value

Description

ret

Int, error code.