SetFixPipeConfig

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

Atlas inference product AI Core

x

Atlas inference product Vector Core

x

Atlas training product

x

Function Usage

Sets the tensor quantization parameters in the real-time quantization during DataCopy (CO1 -> GM or CO1 -> A1).

Prototype

1
2
3
4
template <typename T>
__aicore__ inline void SetFixPipeConfig(const LocalTensor<T>& reluPre, const LocalTensor<T>& quantPre, bool isUnitFlag = false)
template <typename T, bool setRelu = false>
__aicore__ inline void SetFixPipeConfig(const LocalTensor<T>& preData, bool isUnitFlag = false)

Parameters

Table 1 Template parameters

Parameter

Description

T

Operand data type.

setRelu

For one tensor, when setRelu is set to true, reluPre needs to be set. Otherwise, quantPre needs to be set. setRelu can only be set to false.

Table 2 Parameters

Parameter

Input/Output

Description

reluPre

Input

Source operand—the tensor involved in the ReLU operation. Its type is LocalTensor, and the supported TPosition is C2PIPE2GM.

reluPre is reserved for future use. You can pass an empty LocalTensor.

quantPre

Input

Source operand—the quantization tensor involved in the quantization operation. Its type is LocalTensor, and the supported TPosition is C2PIPE2GM.

isUnitFlag

Input

Whether to enable UnitFlag. The default value is false.

  • false: Disabled
  • true: Enabled

preData

Input

Used to set a tensor. A switch can be used to control whether the tensor is a ReLU tensor or quantization tensor. The supported TPosition is C2PIPE2GM. Only the quantization tensor is supported.

Restrictions

quantPre and reluPre must be tensors on the Fixpipe Buffer.

Returns

None

Examples

For details about the complete example, see Complete Example.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
__aicore__inline void SetFPC(const LocalTensor <int32_t>& reluPreTensor, const LocalTensor <int32_t>& quantPreTensor)
{
 
    AscendC::LocalTensor<uint64_t> workA1 = inQueueDeqA1.AllocTensor<uint64_t>();
    uint16_t deqSize = 128; // Size of the dequantization tensor
    AscendC::DataCopy(workA1, deqGlobal, deqSize); // deqGlobal is the GM address of quantization coefficients.
    AscendC::LocalTensor<uint64_t> deqFB = inQueueDeqFB.AllocTensor<uint64_t>(); // Dequantization tensor address on the Fix.
    uint16_t fbufBurstLen = deqSize / 128;  // l1->fix, burst_len unit is 128Bytes
    AscendC::DataCopyParams dataCopyParams(1, fbufBurstLen, 0, 0);
    AscendC::DataCopy(deqFB, workA1, dataCopyParams); // Move the data to C2PIPE2GM through DataCopy.
    AscendC::SetFixPipeConfig(deqFB); // Set the quantization tensor.
    AscendC::PipeBarrier<PIPE_FIX>();
}