SetPadValue(ISASI)

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

x

Atlas inference product AI Core

x

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Sets the value used for padding in a DataCopyPad operation. The following paths are supported:

  • GM -> VECIN/GM -> VECOUT

Prototype

1
2
template <typename T, TPosition pos = TPosition::MAX>
__aicore__ inline void SetPadValue(T paddingValue)

Parameters

Table 1 Template parameters

Parameter

Input/Output

Description

T

Input

Data type of the padding value, which is the same as the type of the data moved by DataCopyPad.

pos

Input

Specifies the logical destination address to which DataCopyPad moves data from GM. The default value is TPosition::MAX, which is equivalent to TPosition::VECIN or TPosition::VECOUT.

The following values are supported:

  • TPosition::VECIN, TPosition::VECOUT, and TPosition::MAX
Table 2 Parameters

Parameter

Input/Output

Description

paddingValue

Input

Value filled by DataCopyPad. Its data type is the same as the type of the data transferred by DataCopyPad.

Returns

None

Restrictions

None

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
uint32_t m_n1 = 32;
uint32_t m_n2 = 31;
uint32_t m_n2Align = n2 % 32 == 0 ? n2 : (n2 / 32 + 1) * 32;

AscendC::LocalTensor<float> srcLocal = m_queInSrc.AllocTensor<float>();
AscendC::DataCopyExtParams dataCopyExtParams;
AscendC::DataCopyPadExtParams<float> padParams;

dataCopyExtParams.blockCount = m_n1; // Represents the number of blocks to be copied. Each block corresponds to one copy operation, so this parameter directly controls how many times the copy will be performed.
dataCopyExtParams.blockLen = m_n2 * sizeof(float); // Determines how many 32-byte blocks are copied in one operation.
dataCopyExtParams.srcStride = 0;
dataCopyExtParams.dstStride = 0;

padParams.isPad = true;
padParams.leftPadding = 0;
padParams.rightPadding = 1;

AscendC::SetPadValue((float)37); // Set the pad value to 37.
AscendC::DataCopyPad(srcLocal, m_srcGlobal, dataCopyExtParams, padParams);
Input (srcGm, shape = [32, 31]): [[1, 1, 1, ..., 1], [1, 1, 1, ..., 1], ... , [1, 1, 1, ..., 1]]
Output (dstGm, shape = [32, 32]): [[1, 1, 1, ..., 1, 37], [1, 1, 1, ..., 1, 37], ..., [1, 1, 1, ..., 1, 37]]
1
2
3
4
5
6
// For data types that do not support direct assignment or initialization using immediate values, here is an example with bfloat16_t as the input type:
AscendC::SetPadValue(m_srcGlobal.GetValue(0));
AscendC::DataCopyPad(srcLocal, m_srcGlobal, dataCopyExtParams, padParams);

Input (srcGm, shape = [32, 31]): [[1, 2, 3, ..., 31], [1, 2, 3, ..., 31], ... , [1, 2, 3, ..., 31]]
Output (dstGm, shape = [32, 32]): [[1, 2, 3, ..., 31, 1], [1, 2, 3, ..., 31, 1], ... , [1, 2, 3, ..., 31, 1]]