Function: set_tensor_shape_range
Applicability
|
Product |
Supported |
|---|---|
|
Atlas 350 Accelerator Card |
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
|
|
√ |
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
1aclError aclSetTensorShapeRange(aclTensorDesc* desc, size_t dimsCount, int64_t dimsRange[][ACL_TENSOR_SHAPE_RANGE_NUM])
- Python Function
1ret = acl.set_tensor_shape_range(desc, dims_range)
Parameters
|
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. |