ShapeInfo

Function

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.
    1
    __aicore__ inline int GetShapeSize(const ShapeInfo& shapeInfo)
    

Function Description

Table 1 ShapeInfo structure parameters

Parameter

Description

shapeDim

Current shape dimension.

shape

Current shape.

originalShapeDim

Original shape dimension.

originalShape

Original shape.

dataFormat

Data format. The DataFormat type is defined as follows:

1
2
3
4
5
6
7
enum class DataFormat : uint8_t {
    ND = 0,
    NZ,
    NCHW,
    NC1HWC0,
    NHWC,
};
Table 2 GetShapeSize parameter description

Parameter

Input/Output

Description

shapeInfo

Input

ShapeInfo type, shape information of the LocalTensor or GlobalTensor.