SetFmatrix

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

x

Atlas A2 training product/Atlas A2 inference product

x

Atlas 200I/500 A2 inference product

Atlas inference product AI Core

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Sets the attribute description of a feature map when Load3Dv1/Load3Dv2 is called. If the template parameter isSetFMatrix of Load3Dv1 or Load3Dv2 is set to false, the description of the feature map attributes (including l1H, l1W, and padList. For details, see Table 3 and Table 4) transferred by Load3Dv1 or Load3Dv2 does not take effect. Developers need to use this API to set the parameters.

Prototype

1
__aicore__ inline void SetFmatrix(uint16_t l1H, uint16_t l1W, const uint8_t padList[4], const FmatrixMode& fmatrixMode)

Parameters

Table 1 Parameters

Parameter

Input/Output

Description

l1H

Input

Height of the source operand. Value range: l1H ∈ [1, 32767].

l1W

Input

Width of the source operand. Value range: l1W ∈ [1, 32767].

padList

Input

Padding list [padding_left, padding_right, padding_top, padding_bottom]. The value range of each element is [0,255]. Default value: {0, 0, 0, 0}.

fmatrixMode

Input

Whether the LoadData instruction obtains information from the left or right register. The FmatrixMode type is defined as follows. Currently, only FMATRIX_LEFT is supported. Both the left and right matrices use this configuration.

1
2
3
4
enum class FmatrixMode : uint8_t {
    FMATRIX_LEFT = 0,
    FMATRIX_RIGHT = 1,
}; 

Restrictions

  • This API must be used together with Load3Dv1 or Load3Dv2 and must be called prior to the Load3Dv1 or Load3Dv2.
  • For details about the operand address alignment requirements, see General Address Alignment Restrictions.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
uint16_t channelSize = 32;
uint16_t H = 4, W = 4;
uint8_t Kh = 2, Kw = 2;
uint16_t Cout = 16;
uint16_t C0, C1;
uint8_t dilationH = 2, dilationW = 2;

uint8_t padList[PAD_SIZE] = {0, 0, 0, 0};
AscendC::SetFmatrix(H, W, padList, FmatrixMode::FMATRIX_LEFT); // Enable the FM memory layout mode and obtain information from the left register.
AscendC::SetLoadDataPaddingValue(0);
AscendC::SetLoadDataRepeat({0, 1, 0});
AscendC::SetLoadDataBoundary((uint32_t)0);
static constexpr AscendC::IsResetLoad3dConfig LOAD3D_CONFIG = {false,false};
AscendC::LoadData<fmap_T, LOAD3D_CONFIG>(featureMapA2, featureMapA1,
    { padList, H, W, channelSize, k, howoRound, 0, 0, 1, 1, Kw, Kh, dilationW, dilationH, false, false, 0 });
AscendC::LoadData(weightB2, weightB1, { 0, weRepeat, 1, 0, 0, false, 0 });