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 accepts nl.int64 as well as nl.int32, and a 64-bit value is written back without truncation.

dst must have the same width as value. A 32-bit scalar cannot be stored into an nl.int64 tile, nor a 64-bit scalar into an nl.int32 one; store at the scalar’s own width and convert in memory if needed.

Only the tracer frontend supports this, matching nki.isa.scalar_load().

value must be an NkiScalar. A Python int is not accepted: it stored nothing on the tracer, where the instruction needs a register, and only appeared to work under nki.simulate(). Use nki.isa.memset() to write a compile-time constant into a tile.

Parameters:
  • dst – A 1x1 tensor in SBUF or HBM with dtype nl.int32 or nl.int64, matching the width of value.

  • value – An NkiScalar to 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