SetValue

Product Support

Product

Supported

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference product's AI Core

Atlas inference product's Vector Core

Atlas training products

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

Table 1 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:

1
2
// PrimT is used to extract the basic data type from T. If T is of the basic data type, the data type is directly returned. If T is of the TensorTrait type, the LiteType basic data type in TensorTrait is extracted.
using PrimType = PrimT<T>;

Returns

None

Restrictions

None