Skip to main content

Module value_range

Module value_range 

Source
Expand description

Proven value ranges: the interval every integer tensor of a program holds over every run that meets the program’s preconditions — every gather’s index inside its table, every attention attending at least one position.

The analysis interprets the program’s tensor ops over intervals, in program order:

  • a fill holds its own least and greatest value;
  • a named row index holds every row its ops admit — the rows of the table a gather or a row write names, the positions of the cache an attention reads — since it is data the host writes at every step;
  • a gather reads its table’s range, whichever row its index names, so a step’s range holds for every token and position the host writes;
  • a table a row write updates holds its fill’s range joined with every row ever written into it. The walk repeats until no interval widens, so a cache carried from step to step is closed over its writes;
  • an integer op the analysis does not model writes a value bounded by nothing, the whole of i64 — never by the zero its declaration starts it at.

Float tensors are not ranged here.

program_ranges carries the intervals through a scheduled SpatialProgram: from each tensor’s declared range — which the whole-program front end sets from the intervals above — through every stage, to the interval each buffer’s pages hold, each tensor holds, each node of each integer body computes and each stage keeps in its accumulator and folds. A fabric sizes its memories and its datapath by them.

Structs§

ProgramRanges
The proven intervals of a scheduled program, each None where nothing is ever held: a buffer no stage fills, a stage with no arithmetic of its own.
StageRanges
One stage’s arithmetic.

Constants§

UNBOUNDED
Every value an i64 holds — the bound of a value no modeled op computes.

Functions§

fill_range
The interval of an integer fill over len elements.
program_ranges
The intervals of p’s integer storage and arithmetic over every run whose tensors hold their declared ranges.
signed_bits
The signed two’s-complement width that holds every value of iv.
value_ranges
The proven interval of every integer tensor rp declares or computes, by name. float names the program’s float tensors, which are not ranged.

Type Aliases§

Interval
[lo, hi], inclusive.