This document is relevant for: Trn2, Trn3
nki.isa.scalar_store#
- nki.isa.scalar_store(dst: NkiTensor, value: NkiScalar) None[source]#
Store a scalar value to a 1x1 tensor in memory.
Like
nki.isa.scalar_load(), this acceptsnl.int64as well asnl.int32, and a 64-bit value is written back without truncation.dstmust have the same width asvalue. A 32-bit scalar cannot be stored into annl.int64tile, nor a 64-bit scalar into annl.int32one; store at the scalar’s own width and convert in memory if needed.Only the tracer frontend supports this, matching
nki.isa.scalar_load().valuemust be anNkiScalar. A Pythonintis not accepted: it stored nothing on the tracer, where the instruction needs a register, and only appeared to work undernki.simulate(). Usenki.isa.memset()to write a compile-time constant into a tile.- Parameters:
dst – A 1x1 tensor in SBUF or HBM with dtype
nl.int32ornl.int64, matching the width ofvalue.value – An
NkiScalarto store.
Example:
out_buf = nl.ndarray((1, 1), dtype=nl.int32, buffer=nl.sbuf) nisa.scalar_store(out_buf, result)
This document is relevant for: Trn2, Trn3