Function: set_tensor_shape

Applicable Products

  • Ascend 950PR&950DT products: Supported
  • Atlas A3 products: Supported
  • Atlas A2 products: Supported
  • Atlas 200I/500 A2 inference products: Supported
  • Atlas inference products: Supported
  • Atlas training products: Not supported

Function

Sets the dimensions of a tensor when the tensor is processed in an AI processor after a tensor description is created by the acl.create_tensor_desc call. This API is mainly used in the PyTorch scenarios.

For example, if the original operator is 4D with format NHWC or 5D with format NDHWC, the format is automatically converted to NC1HWC0 or NDC1HWC0 during model conversion or online network construction to facilitate memory access efficiency on the AI processors. Along the process, the operator shape is also inferred to facilitate internal computation.

Prototype

  • C Prototype

    aclError aclSetTensorShape(aclTensorDesc *desc, int numDims, const int64_t *dims)
    
  • Python Function

    ret = acl.set_tensor_shape(desc, dims)
    

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 List, dimensions to be set.

Return Values

Return Value Description
ret Int, error code.
0: success
Other values: failure