Data Formats

A data format describes the business semantics of the axes of a multidimensional tensor, indicating the physical layout format of data, such as 1D, 2D, 3D, 4D, and 5D. It is typically required in CNN (Convolutional Neural Networks) APIs to specify the exact format.

For the full range of data formats supported by aclTensor, see "Data Types and Their Operation APIs > aclFormat" in Runtime API.

For an introduction to the data format layout principles, see "Concept Principles and Terminology > Neural Networks and Operators > Data Layout Format" in Ascend C Operator Development Guide.

Instructions

Currently, most operator APIs support the ND data format. For example, the aclnnAdd interface indicates that the supported data format is ND (i.e., the rule of low-dimension-first contiguous layout for multi-dimensional tensors). For aclnnConvolution, which is a CNN-type API, the input aclTensor is required to be set with a format that carries business semantics, rather than the ND format. Such operators need to understand the business semantics within the tensor during computation to perform the corresponding calculations. For instance, in 2D convolution, it is necessary to know the correspondence between the Batch dimension, Channel dimension, Height dimension, Width dimension, and the tensor dimensions.

NOTE:

  • In the parameter description of two-phase APIs, the original data format "ACL_FORMAT_XXXX_" is abbreviated as "_XXXX_" for simplicity.
  • Dimensions in a data format: N (Batch) indicates the batch size, H (Height) indicates the feature map height, W (Width) indicates the feature map width, C (Channels) indicates the feature map channels, D (Depth) indicates the feature map depth, and L (Length) indicates the feature map length.

Common Data Formats

When creating an aclTensor using the aclCreateTensor interface, you need to set the data format according to the API service requirements. The currently supported data formats are: