SetValue
Product Support
Product |
Supported |
|---|---|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
Function
Sets the value of the corresponding offset position of the GlobalTensor.
- Due to different hardware implementation, this operation is different from the general CPU scalar value assignment operation. During the value assignment operation using SetValue, the DCache in each AI Core is overwritten first rather than being written to the global memory immediately. The subsequent write operations are performed in the unit of cache line (64 bytes). Before using this API, you must understand the DCache structure and cache consistency principles (see DataCacheCleanAndInvalid). Otherwise, this API may be misused. Exercise caution when using it.
- After SetValue is called, the DCache inside each AI Core is modified first. If the data needs to be written to the global memory immediately, call DataCacheCleanAndInvalid after calling this API to ensure cache coherence between the DCache and the global memory.
- When multiple cores operate the global memory address, the addresses operated by different cores must have at least the offset of the cache line size (the element offset can be set using the offset parameter and converted into an address). Otherwise, multi-core data will be randomly overwritten. In addition, the addresses must be aligned to 64 bytes. For details, see Example.
Prototype
1 | __aicore__ inline void SetValue(const uint64_t offset, PrimType value) |
Parameters
Parameter |
Input/Output |
Description |
||
|---|---|---|---|---|
offset |
Input |
Number of elements to offset. |
||
value |
Input |
Value to set, which is of the PrimType type. PrimType is defined as follows:
|
Returns
None
Restrictions
None
Parent topic: GlobalTensor