Ir.IndexingSymbols and projections used to lower tensor indexing.
val sexp_of_symbol : symbol -> Sexplib0.Sexp.tval symbol_of_sexp : Sexplib0.Sexp.t -> symbolval hash_fold_symbol :
Ppx_hash_lib.Std.Hash.state ->
symbol ->
Ppx_hash_lib.Std.Hash.stateval hash_symbol : symbol -> Ppx_hash_lib.Std.Hash.hash_valueval symbol : Base.int -> symbolval is_symbol : symbol -> Base.boolval symbol_val : symbol -> Base.int Base.optionmodule Variants_of_symbol : sig ... endmodule Symbol : sig ... endval get_symbol : Base.unit -> symboldiscarding_symbols f runs f and then rewinds the symbol counter to where it was: for dry runs whose minted symbols are all discarded (a schedule probe), so they shift no later minted name. Sound only when no symbol f mints outlives it.
val symbol_ident : symbol -> Base.stringval sexp_of_environment :
('a -> Sexplib0.Sexp.t) ->
'a environment ->
Sexplib0.Sexp.tval environment_of_sexp :
(Sexplib0.Sexp.t -> 'a) ->
Sexplib0.Sexp.t ->
'a environmenttype static_symbol = private {static_symbol : symbol;mutable static_range : Base.int Base.option;mutable used_as_extent : Base.bool;mutable used_as_slice : Base.bool;}Private (gh-ocannl-1624): read and matched freely, built by make_static_symbol or get_static_symbol, and written only through the setters below. The roles (used_as_extent, used_as_slice) are shape-inference state of a caller-retained symbol: after its birth a role is written only by commit_role, which takes shape_writer. The declared range is not inference state; set_static_range writes it.
val compare_static_symbol : static_symbol -> static_symbol -> Base.intval equal_static_symbol : static_symbol -> static_symbol -> Base.boolval sexp_of_static_symbol : static_symbol -> Sexplib0.Sexp.tval static_symbol_of_sexp : Sexplib0.Sexp.t -> static_symbolval hash_fold_static_symbol :
Ppx_hash_lib.Std.Hash.state ->
static_symbol ->
Ppx_hash_lib.Std.Hash.stateval hash_static_symbol : static_symbol -> Ppx_hash_lib.Std.Hash.hash_valueval make_static_symbol :
?static_range:Base.int ->
?used_as:[ `Extent | `Slice ] ->
symbol ->
static_symbolA static symbol over symbol, holding the role used_as from birth (default: none). A role given at birth is not a write to a symbol anything else holds yet, so it needs no writer -- hand-built IR uses it for a symbolic extent no shape inference claimed.
val set_static_range : static_symbol -> Base.int Base.option -> Base.unitRe-declares the symbol's range. The analysis caches key on it, so a changed range misses.
val sexp_of_bindings :
('a -> Sexplib0.Sexp.t) ->
'a bindings ->
Sexplib0.Sexp.tval bound_symbols : 'a bindings -> static_symbol Base.listtype ('r, 'idcs, 'p1, 'p2) variadic = | Result of 'r| Param_idx of Base.int Base.ref
* (Base.int -> 'r, Base.int -> 'idcs, 'p1, 'p2) variadic| Param_1 of 'p1 Base.option Base.ref * ('p1 -> 'r, 'idcs, 'p1, 'p2) variadic| Param_2 of 'p2 Base.option Base.ref * ('p2 -> 'r, 'idcs, 'p1, 'p2) variadic| Param_2f : ('p2f ->
'p2)
* 'p2f Base.option Base.ref
* ('p2 -> 'r, 'idcs, 'p1, 'p2) variadic -> ('r, 'idcs, 'p1, 'p2) variadictype unit_bindings = (Base.unit -> Base.unit) bindingsval sexp_of_unit_bindings : unit_bindings -> Sexplib0.Sexp.ttype lowered_bindings = (static_symbol, Base.int Base.ref) Base.List.Assoc.tval sexp_of_lowered_bindings : lowered_bindings -> Sexplib0.Sexp.tval apply : ('r, 'idcs, 'p1, 'p2) variadic -> 'rval lowered_bindings :
'a bindings ->
('b, 'a, 'p1, 'p2) variadic ->
lowered_bindingsval find_exn : lowered_bindings -> static_symbol -> Base.int Base.refval get_static_symbol :
?static_range:Base.int ->
(Base.int -> 'a) bindings ->
static_symbol * 'a bindingsA launch parameter's cell as backend linking mints it: UNASSIGNED (gh-ocannl-940), holding a value outside every legal one, which validate_bound_value refuses naming the parameter. A caller assigns it through find_exn bindings sym := v; a caller that means 0 writes 0.
Whether the cell holds a value someone assigned, rather than the one fresh_launch_param left there.
val validate_bound_value :
?width64:Base.bool ->
static_symbol ->
Base.int ->
Base.unitBind-time validation of one launch-parameter value: refuses an unassigned one (gh-ocannl-940), a negative one, one outside the declared range (below range for an index, up to range inclusive for a symbolic extent) and, unless width64, one past the int32 index width.
val validate_lowered_bindings :
?width64:Base.bool ->
lowered_bindings ->
Base.unitvalidate_bound_value over every parameter, reporting all the unassigned ones in one message first.
val set_launch_value :
?width64:Base.bool ->
caller:Base.string ->
lowered_bindings ->
static_symbol ->
Base.int ->
Base.unitset_launch_value ~caller bs sym v validates v (validate_bound_value) and writes it into sym's cell of bs; a symbol bs does not bind is refused, naming caller.
val resolve_launch_values :
caller:Base.string ->
hint:Base.string ->
ranged:(static_symbol -> Base.string Base.option) ->
(static_symbol * Base.int) Base.list ->
static_symbol Base.list ->
lowered_bindingsThe launch values of a routine that a library entry point compiles and runs on the caller's behalf (gh-ocannl-1629): a fresh cell per symbol, the caller's values written into it (a symbol it does not bind, or given twice, is refused; the values themselves are validated by the run, once lowering has committed the role -- index or extent -- each is validated against), then every parameter left unassigned set to 0 -- unless ranged names its kind (a batch-slice index, a ranged static index, a symbolic extent), which is refused instead, naming each one and its kind and ending with hint: 0 is its first slice or empty extent, the silent default gh-ocannl-940 refuses. Hand the result to copy_launch_values once the routine is linked.
val copy_launch_values : from:lowered_bindings -> lowered_bindings -> Base.unitcopy_launch_values ~from bs writes into each cell of bs the value from holds for the same symbol; every symbol of bs must be bound by from.
val compare_affine_index : affine_index -> affine_index -> Base.intval equal_affine_index : affine_index -> affine_index -> Base.boolval sexp_of_affine_index : affine_index -> Sexplib0.Sexp.ttype axis_index = | Fixed_idx of Base.int| Iterator of symbol| Affine of affine_index| Sub_axis| Concat of symbol Base.listval compare_axis_index : axis_index -> axis_index -> Base.intval equal_axis_index : axis_index -> axis_index -> Base.boolval sexp_of_axis_index : axis_index -> Sexplib0.Sexp.tval axis_index_of_sexp : Sexplib0.Sexp.t -> axis_indexval affine :
symbols:(Base.int * symbol) Base.list ->
offset:Base.int ->
axis_indexCoalesce repeated symbols, remove zero terms, and use Fixed_idx or Iterator whenever possible. The private payload prevents bypassing this normalization.
val axis_index_mentions_symbol : symbol -> axis_index -> Base.boolval axis_index_mentions_any : symbol Base.list -> axis_index -> Base.booltype str_osym_map =
(Base.string, symbol Base.option, Base.String.comparator_witness) Base.Map.tval sexp_of_projections_debug : projections_debug -> Sexplib0.Sexp.tval projections_debug_of_sexp : Sexplib0.Sexp.t -> projections_debugtype component = (Base.int * symbol) Base.listval sexp_of_component : component -> Sexplib0.Sexp.tval component_of_sexp : Sexplib0.Sexp.t -> componenttype projections = {components : component Base.array;lhs_dims : Base.int Base.array;rhs_dims : Base.int Base.array Base.array;project_lhs : axis_index Base.array;project_rhs : axis_index Base.array Base.array;extent_syms : (symbol Base.option * static_symbol) Base.list;debug_info : projections_debug;}val compare_projections : projections -> projections -> Base.intval equal_projections : projections -> projections -> Base.boolval sexp_of_projections : projections -> Sexplib0.Sexp.tval projections_of_sexp : Sexplib0.Sexp.t -> projectionsval all_iterators : projections -> symbol Base.listval iterator_sizes : projections -> Base.int Base.Map.M(Symbol).tval affine_injective :
symbol_range:(symbol -> Base.int) ->
axis_index Base.array ->
Base.boolval prod_project_for :
projections ->
dims:Base.int Base.array ->
axis_index Base.arrayval reflect_projection :
dims:Base.int Base.array ->
projection:axis_index Base.array ->
axis_indextype variable_ref = private {ref_label : Base.string;mutable solved_dim : Base.int Base.option;mutable solved_sym : static_symbol Base.option;}Private (gh-ocannl-1573): read and matched freely, written only through the setters below. A solution is reached once: at most one of solved_dim, solved_sym is ever set, and a set field keeps its value. Shape inference is the only writer: the setters take shape_writer, which Shape holds, and its capture references wrap them with the session's accounting (gh-ocannl-1624). The cell is shared, so an Assignments.Embed_dim built before inference observes the solution it later reaches.
val sexp_of_variable_ref : variable_ref -> Sexplib0.Sexp.tval equal_variable_ref : variable_ref -> variable_ref -> Base.boolval variable_ref : Base.string -> variable_refA fresh, unsolved reference with the given label.
The capability to write shape-inference state held by this module's records: solve a variable_ref, commit a static symbol's role (gh-ocannl-1624). A process has at most one: the first claim_shape_writer returns it and every later one raises. In a program linking the tensor frontend, Shape claims it as it initializes, so the setters taking it are Shape's alone -- a write through them could not skip the session's accounting (liveness of a rewound reference, the open set, the mutation serial).
val claim_shape_writer : Base.unit -> shape_writerReturns the process's shape_writer; raises Utils.User_error when it was already claimed.
val set_solved_dim : shape_writer -> variable_ref -> Base.int -> Base.unitRecords a concrete solution. Setting the value it already holds is a no-op; a different value, or a reference already solved to a symbol, raises.
val set_solved_sym : shape_writer -> variable_ref -> static_symbol -> Base.unitRecords a symbolic-extent solution, guarded like set_solved_dim.
A reference's solution at a checkpoint, bound to that reference (gh-ocannl-903).
val snapshot_variable_ref : variable_ref -> variable_ref_snapshotval restore_variable_ref : shape_writer -> variable_ref_snapshot -> Base.unitPuts the recorded solution back on its reference -- unsolving it if it was unsolved: a rewind's write, so it takes the writer.
val variable_ref_snapshot_changed : variable_ref_snapshot -> Base.boolWhether the reference's solution differs from the recorded one: a diagnostic.
val commit_role :
shape_writer ->
static_symbol ->
[ `Extent | `Slice ] ->
Base.unitSets the symbol's role flag. Committing the role it holds is a no-op; the other role raises (a binding cannot be validated both inclusively and strictly). Shape calls it only from a successful finish_inference, for the claims Row.claim_symbol_role counted.
module Doc_helpers : sig ... end