ShapeInfo

Function Usage

Stores the shape information of LocalTensor or GlobalTensor.

Prototype

  • ShapeInfo structure
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    struct ShapeInfo {
    public:
        __aicore__ inline ShapeInfo();
        __aicore__ inline ShapeInfo(const uint8_t inputShapeDim, const uint32_t inputShape[],
            const uint8_t inputOriginalShapeDim, const uint32_t inputOriginalShape[], const DataFormat inputFormat);
        __aicore__ inline ShapeInfo(const uint8_t inputShapeDim, const uint32_t inputShape[], const DataFormat inputFormat);
        __aicore__ inline ShapeInfo(const uint8_t inputShapeDim, const uint32_t inputShape[]);
        uint8_t shapeDim;
        uint8_t originalShapeDim;
        uint32_t shape[K_MAX_DIM];
        uint32_t originalShape[K_MAX_DIM];
        DataFormat dataFormat;
    };
    
  • Obtains the product of all dimensions in a shape.

    __aicore__ inline int GetShapeSize(const ShapeInfo& shapeInfo)

Function Description

Table 1 ShapeInfo structure parameters

Parameter

Type

Description

shapeDim

uint8_t

Current shape dimension

shape

uint32_t

Current shape

originalShapeDim

uint8_t

Original shape dimension

originalShape

uint32_t

Original shape

dataFormat

DataFormat

Format
enum DataFormat {     NCHW = 0;     NHWC = 1; }
NCHW: Data is arranged by NCHW.
NHWC: Data is arranged by NHWC.
Table 2 GetShapeSize parameter description

Function Name

Input Parameter

Description

shapeInfo

Shape information of a tensor

Stores the shape information of LocalTensor or GlobalTensor.