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 data blocks of the size of singleCo * singleDo * singleM at a time and writes the data blocks to the result matrix Output.

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 partitioning. singleDo indicates the size of Dout within a single core after multi-core partitioning. singleM indicates the size of M within a single core after multi-core partitioning. 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 supported data types of the result matrix Output are half and bfloat16_t.

enPartialSum

Input

Reserved parameter.

Returns

None

Restrictions

  • The IterateAll API can process only single-batch data. In multi-batch computing scenarios, the IterateAll API needs to be called cyclically for multiple batches 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();
}