Iterate
Applicability
Product |
Supported |
|---|---|
√ |
|
√ |
|
x |
|
x |
|
x |
|
x |
Function
Each time the Iterate API is called, a result matrix of baseM x baseN is computed and written to the L0C Buffer. The API maintains the iteration progress internally, and after each call, it will offset the start address of the matrix. If the input data is not aligned and has a tail block, the computation result of the tail block is output in the last iteration. This API must be used in conjunction with the GetTensorC API. After this API is called, the GetTensorC API is called to write the data in the L0C Buffer to the destination address.
Prototype
1 2 | template <bool sync = true> __aicore__ inline bool Iterate(bool enPartialSum = false) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
enPartialSum |
Input |
Reserved parameter, which is imperceptible to users. |
Returns
false: All data on the configured SingleShape has been computed.
true: Data is still in iterative computation.
Restrictions
- The Iterate API must be called after the initialization API and the input/output configuration API are called to complete the convolution backpropagation computation. The calling sequence is as follows:
1 2 3 4 5 6
Init(...); ... // Input and output configuration while (Iterate()) { GetTensorC(); } End();
- In the scenario of multi-round cyclic computation, the data size set by SetSingleShape for a single core is computed in a single cycle. After each single-core computation is complete, ctx.isFirstIter_ of the Conv3DBackpropInput object must be set to true to ensure that the single-core computation in the next cycle can be correctly performed.
Example
1 2 3 4 5 | while (gradInput_.Iterate()) { gradInput_.GetTensorC(gradInputGm_[offsetC_]); } // After the SingleShape computation is complete, set ctx.isFirstIter_ to true to ensure that the next SingleShape is correctly computed. gradInput_.ctx.isFirstIter_ = true; |