Function: set_tensor_shape

Applicability

Product

Supported (√/x)

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas training products

x

Atlas inference products

Atlas 200I/500 A2 inference products

Function Usage

Sets the tensor dimensions for internal processing on Ascend AI Processor after a tensor description is created by the acl.create_tensor_desc call. This API applies to the PyTorch scenario.

For example, if the original operator shape 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 build to facilitate data access efficiency on Ascend AI Processor. Along the process, the operator shape is also inferred to facilitate internal computation.

Prototype

  • C Prototype
    1
    aclError aclSetTensorShape(aclTensorDesc *desc, int numDims, const int64_t *dims)
    
  • Python Function
    1
    ret = acl.set_tensor_shape(desc, dims)
    

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

List, dimensions to be set.

Return Value Description

Return Value

Description

ret

Int, error code.