nki.isa.tensor_copy#
- nki.isa.tensor_copy(dst, src, engine=engine.unknown, name=None)[source]#
Create a copy of
srctile within NeuronCore on-chip SRAMs using Vector, Scalar or GpSimd Engine.The output tile has the same partition axis size and also the same number of elements per partition as the input tile
src.All three compute engines, Vector, Scalar and GpSimd Engine can perform tensor copy. However, their copy behavior is slightly different across engines:
Scalar Engine on NeuronCore-v2 performs copy by first casting the input tile to FP32 internally and then casting from FP32 to the output dtype (
dtype, or src.dtype ifdtypeis not specified). Therefore, users should be cautious with assigning this instruction to Scalar Engine when the input data type cannot be precisely cast to FP32 (e.g., INT32).Both GpSimd and Vector Engine can operate in two modes: (1) bit-accurate copy when input and output data types are the same or (2) intermediate FP32 cast when input and output data types differ, similar to Scalar Engine.
In addition, since GpSimd Engine cannot access PSUM in NeuronCore, Scalar or Vector Engine must be chosen when the input or output tile is in PSUM (see NeuronCore-v2 Compute Engines for details). By default, this API returns a tile in SBUF, unless the returned value is assigned to a pre-declared PSUM tile.
- Parameters:
dst – a tile with the same content and partition axis size as the
srctile.src – the source of copy, must be a tile in SBUF or PSUM.
engine – (optional) the engine to use for the operation: nki.isa.vector_engine, nki.isa.scalar_engine, nki.isa.gpsimd_engine or nki.isa.unknown_engine (default, compiler selects best engine based on engine workload).