Function: set_tensor_format

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product / Atlas A3 inference product

Atlas A2 training product / Atlas A2 inference product

Atlas training product

x

Atlas inference product

Atlas 200I/500 A2 inference product

Function Usage

Call acl.set_tensor_format to set the format of a tensor when the tensor is processed in an Ascend 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 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 the AI processor. Along the process, the operator shape is also inferred to facilitate internal computation.

Prototype

  • C Prototype
    1
    aclError aclSetTensorFormat(aclTensorDesc *desc, aclFormat format)
    
  • Python Function
    1
    ret = acl.set_tensor_format(desc, format)
    

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.

format

Int, format of the specified tensor description.

Returns

Return Value

Description

ret

Int, error code.