IterateAll

Applicability

Product

Supported

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

x

Atlas inference product's AI Core

x

Atlas inference product's Vector Core

x

Atlas training products

x

Function

By setting the start address of the result matrix Output on the GM, this API computes a data block at a time, and write it into the result matrix Output. The size of the data block is singleCo × singleDo × singleM.

This API provides the convolution computation capability within a single core. singleCo indicates the size of the output channels within a single core after multi-core tiling. singleDo indicates the size of Dout within a single core after multi-core tiling. singleM indicates the size of M within a single core after multi-core tiling. The sizes of singleCo, singleDo, and singleM are set by calling SetSingleOutputShape.

Prototype

1
__aicore__ inline void IterateAll(const AscendC::GlobalTensor<OutputT>& output, bool enPartialSum = false)

Parameters

Parameter

Input/Output

Description

output

Input

Output address on the GM. The type is GlobalTensor. The result matrix Output supports the following data types: are half and bfloat16_t.

enPartialSum

Input

Reserved parameter.

Returns

None

Restrictions

  • The IterateAll API can process only single-batch data. In multi-batch computation scenarios, the IterateAll API needs to be called in a loop for each batch to complete the computation.
    1
    2
    3
    4
    5
    for (uint64_t batchIter = 0; batchIter < singleCoreBatch; ++batchIter) {
        conv3dApi.SetInput(inputGm[batchIter * inputOneBatchSize]);
        conv3dApi.IterateAll(outputGm[batchIter * outputOneBatchSize]);
        conv3dApi.End();
    }
    
  • The IterateAll API must be called after the initialization API and the input/output configuration API are called to complete the Conv3D computation. The calling sequence is as follows:
    1
    2
    3
    4
    Init(...);
    ... // Input and output configuration
    IterateAll(...);
    End();
    

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
TPipe pipe;
conv3dApi.Init(&tiling);
conv3dApi.SetWeight(weightGm);
if (biasFlag) {
    conv3dApi.SetBias(biasGm);
}
conv3dApi.SetInputStartPosition(diIdxStart, mIdxStart);
conv3dApi.SetSingleOutputShape(singleCoreCout, singleCoreDout, singleCoreM);
for (uint64_t batchIter = 0; batchIter < singleCoreBatch; ++batchIter) {
    conv3dApi.SetInput(inputGm[batchIter * inputOneBatchSize]);
    conv3dApi.IterateAll(outputGm[batchIter * outputOneBatchSize]);
    conv3dApi.End();
}