General Description and Restrictions
Header Files to Be Included
Header file directory of Ascend C APIs:
- Basic APIs: ${INSTALL_DIR}/include/ascendc/basic_api/interface
- High-level APIs: (Note that if the APIs contained in the following header file directories are not declared in the documentation, they are called indirectly, and developers do not need to pay attention to them.)
- ${INSTALL_DIR}/include/ascendc/highlevel_api/lib
- ${INSTALL_DIR}/include/tiling
Replace ${INSTALL_DIR} with the CANN component directory. For example, if the installation is performed by the root user, the default file storage path is /usr/local/Ascend/cann.
For your convenience, both basic and high-level Ascend C APIs can be called by including the kernel_operator.h file. Unless otherwise specified, including this header file meets the API calling requirements. If there are special notes in the API documentation, follow the specific instructions provided.
1 | #include "kernel_operator.h" |
Mapping Between Logical Locations and Physical Storage
TPosition |
Physical Memory |
|---|---|
GM |
Global Memory |
VECIN |
Unified Buffer |
VECCALC |
Unified Buffer |
VECOUT |
Unified Buffer |
A1 |
L1 Buffer |
A2 |
L0A Buffer |
B1 |
L1 Buffer |
B2 |
L0B Buffer |
C1 |
|
C2 |
|
CO1 |
L0C Buffer |
CO2 |
|
TSCM |
L1 Buffer |
SPM |
|
C2PIPE2GM |
General Address Alignment Restrictions
Memory Unit |
Alignment Requirement |
|---|---|
Global Memory |
No alignment requirement. |
Unified Buffer |
32-byte aligned. |
L1 Buffer |
32-byte aligned. |
L0A Buffer/L0B Buffer |
512-byte aligned. |
L0C Buffer |
64-byte aligned. |
BiasTable Buffer |
64-byte aligned. |
Fixpipe Buffer |
64-byte aligned. |
General Address Overlapping Restrictions
To save memory space when using high-dimensional tensor sharding compute APIs of basic APIs, you can define a tensor shared by the source and destination operands (by address overlapping). Pay attention to the following restrictions when using this:
- In a single iteration, the source operand must completely overlap the destination operand. Partial overlapping is not supported.
- Among multiple iterations, the destination operand of a previous iteration cannot overlap the source operand of a subsequent iteration. For example, the destination operand of the Nth iteration is the source operand of the (N+1)th iteration (as shown in the following figure). In this case, the N th iteration may overwrite the value of the source operand, resulting in an unexpected result. In particular, for some two-operand compute APIs (Add, Sub, Mul, Max, Min, AddRelu, and SubRelu), when the data type is half, int32_t, or float, the destination operand of a previous iteration can overlap the source operand of a subsequent iteration. This is only applicable when the destination operand overlaps the second source operand, and src1RepStride or dstRepStride must be 0.

The general restrictions on address overlapping described in this section apply to common cases. If there are additional restrictions in the API reference, the restrictions in the specific API prevail.
If an API does not describe address overlapping restrictions, address overlapping is not supported for high-dimensional tensor sharding computation. In this case, the computation result may not meet expectations.