Ir.Indexingval symbol_of_sexp : Sexplib0.Sexp.t -> symbolval sexp_of_symbol : symbol -> Sexplib0.Sexp.tval 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 -> boolval symbol_val : symbol -> Base.int Stdlib.Option.tmodule Variants_of_symbol : sig ... endval get_symbol : unit -> symbolmodule CompareSymbol : sig ... endmodule Symbol : sig ... endval symbol_ident : symbol -> Base.String.tval environment_of_sexp :
'a. (Sexplib0.Sexp.t -> 'a) ->
Sexplib0.Sexp.t ->
'a environmentval sexp_of_environment :
'a. ('a -> Sexplib0.Sexp.t) ->
'a environment ->
Sexplib0.Sexp.tval empty_env : 'a environmenttype static_symbol = {static_symbol : symbol;mutable static_range : Base.int Base.option;mutable used_as_extent : Base.bool;The symbol is used as a symbolic dimension (gh-490): its bound value is a size in [0, static_range] (inclusive -- buffers are sized static_range), rather than an index in [0, static_range). Set by Row.get_sym_dim.
mutable used_as_slice : Base.bool;The symbol is used as a batch-slice index (@|): its bound value indexes an axis of size static_range, so the strict [0, static_range) validation must apply. Set by the Batch_slice shape logic; mutually exclusive with used_as_extent (a single binding cannot be validated both inclusively and strictly).
}val compare_static_symbol : static_symbol -> static_symbol -> Base.intval equal_static_symbol : static_symbol -> static_symbol -> Base.boolval static_symbol_of_sexp : Sexplib0.Sexp.t -> static_symbolval sexp_of_static_symbol : static_symbol -> Sexplib0.Sexp.tval 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 sexp_of_bindings :
'a. ('a -> Sexplib0.Sexp.t) ->
'a bindings ->
Sexplib0.Sexp.tval bound_symbols : 'a bindings -> static_symbol Base.List.ttype ('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) variadicHelps lowering the bindings.
type 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. ('r, 'idcs, 'p1, 'p2) variadic -> 'rapply run_variadic () applies the parameters in reverse order to how they appear in the run_variadic list.
val lowered_bindings :
'a bindings ->
('b, 'a, 'p1, 'p2) variadic ->
(static_symbol * Base.int Base.ref) Base.List.tval find_exn : lowered_bindings -> static_symbol -> Base.int Base.refval get_static_symbol :
?static_range:Base.int ->
(Base.int -> 'a) bindings ->
static_symbol * 'a bindingsval validate_bound_value :
?width64:Base.bool ->
static_symbol ->
Base.int ->
unitValidates a launch-parameter value against its declared range (minimum 0 is implicit) and, when width64 is false, against the int32 index width (docs/proposals/signed-index-precision.md: bind-time validation mirroring tinygrad's bind assert; one host compare per launch). The per-routine node-extent contract is NOT sound for launch parameters -- value-embedded parameters (step counters) take runtime values unrelated to any touched node's extent -- so narrowing an unbounded parameter requires declaring (and thereby bind-validating) a range.
val validate_lowered_bindings : ?width64:Base.bool -> lowered_bindings -> unitDimensions to string, "x"-separated, e.g. 1x2x3 for batch dims 1, input dims 3, output dims 2. Outputs "-" for empty dimensions.
type axis_index = | Fixed_idx of Base.intA fixed position along an axis
*)| Iterator of symbolA simple iterator symbol
*)| Affine of {symbols : (Base.int * symbol) Base.list;offset : Base.int;}An affine combination of symbols with coefficients and an offset. Represents:
Σ(coeff_i * symbol_i) + offset
For convolutions: symbols = [(stride, i1); (dilation, i2)] and offset = ~-padding. Note: for readability, we use Fixed_idx and Iterator as separate variants and require Affine to not be ambiguous: symbols should be longer than 1 or have a coefficient different from 1 and 0.
| Sub_axisThis axis belongs to an adjacent multi-axis index.
*)| Concat of symbol Base.listThis axis is formed by concatenating multiple axes, each represented by an iterator symbol. Concat indices are eliminated during lowering.
val compare_axis_index : axis_index -> axis_index -> Base.intval equal_axis_index : axis_index -> axis_index -> Base.boolval axis_index_of_sexp : Sexplib0.Sexp.t -> axis_indexval sexp_of_axis_index : axis_index -> Sexplib0.Sexp.ttype str_osym_map =
(Base.string, symbol Base.option, Base.String.comparator_witness) Base.Map.tval sexp_of_str_osym_map : str_osym_map -> Base.Sexp.tval projections_debug_of_sexp : Sexplib0.Sexp.t -> projections_debugval sexp_of_projections_debug : projections_debug -> Sexplib0.Sexp.ttype projections = {product_space : Base.int Base.list Base.array;The product space dimensions that an operation should parallelize (map-reduce) over. Singletons except for concatenation dimensions.
*)lhs_dims : Base.int Base.array;The dimensions of the LHS array.
*)rhs_dims : Base.int Base.array Base.array;The dimensions of the RHS arrays, needed for deriving projections from other projections.
*)product_iterators : symbol Base.list Base.array;The product space iterators (concatentation of the relevant batch, output, input axes) for iterating over the product_space axes, where same axes are at same array indices. These may be shared; lowering creates fresh symbols for loop indices. Singletons except for concatenation dimensions. A concatenation dimension is a connected component of symbols participating in concatenated axes.
project_lhs : axis_index Base.array;A projection that takes an product_space-bound index and produces an index into the result of an operation.
project_rhs : axis_index Base.array Base.array;project_rhs.(i) Produces an index into the i+1th argument of an operation.
extent_syms : (symbol * static_symbol) Base.list;gh-490 symbolic extents: maps a product iterator to the static symbol whose bound value is the axis's runtime extent. The corresponding product_space entry is the maximum extent (the symbol's declared range); lowering guards the loop body with iterator < value when the symbol is among the routine's bindings.
debug_info : projections_debug;}All the information relevant for code generation.
val compare_projections : projections -> projections -> Base.intval equal_projections : projections -> projections -> Base.boolval projections_of_sexp : Sexplib0.Sexp.t -> projectionsval sexp_of_projections : projections -> Sexplib0.Sexp.tval opt_symbol : int -> symbol optionval opt_iterator : symbol option -> axis_indexval coalesce_affine_terms :
(Base__Int.t * Symbol.t) Base.List.t ->
(Base__Int.t * Symbol.t) Base.List.tCoalesce an affine symbols list into canonical (coeff, symbol) terms: repeated symbols are summed and zero-coefficient terms dropped. Order is unspecified.
val affine_injective :
symbol_range:(Symbol.t -> Base__Int.t) ->
axis_index Base.array ->
Base.boolval identity_projections :
?debug_info:projections_debug ->
?derived_for:string ->
lhs_dims:Base.int Base.Array.t ->
unit ->
projectionsProjections for a pointwise unary operator. Provide only one of debug_info or derived_for.
val prod_dims : projections -> Base.int Base.arrayThe extents of the product-space components of p: one entry per component, in product_space order. A concatenation component's extent is the sum of its segment extents. Non-iterated (dimension-1) axes do not appear.
val prod_project_for :
projections ->
dims:Base.int Base.array ->
axis_index Base.arrayThe identity projection of a tensor laid out over the full product space of p (e.g. the (output x kernel) pair space of a windowed reduction): the tensor's axes are the product components, possibly interleaved with non-iterated (dimension-1) axes, which the product space omits. dims is the tensor's dimensions; each dimension-1 axis maps to Fixed_idx 0 and every other axis consumes the first not-yet-consumed product component of equal extent. Matching by extent rather than strictly by position tolerates a proxy-shape layout whose axis order deviates from the product order (e.g. a reduced-over row variable placed in the result's output row while the result keeps input axes): any pairing is correct as long as it is consistent, and this is a pure function of p and dims, so every access to the tensor uses the same pairing. A leftover on either side means the product-space proxy shape (gh-512) got out of sync with the derived projections, and raises rather than corrupting memory.
val reflect_projection :
dims:Base.int Base.array ->
projection:axis_index Base.array ->
axis_indextype variable_ref = {ref_label : Base.string;mutable solved_dim : Base.int Base.option;mutable solved_sym : static_symbol Base.option;The dimension is a symbolic extent (gh-490) rather than a concrete integer; where a concrete value is required (e.g. Embed_dim), it materializes at the symbol's declared range (the maximum extent). At most one of solved_dim, solved_sym is set.
}val sexp_of_variable_ref : variable_ref -> Sexplib0.Sexp.tval equal_variable_ref : variable_ref -> variable_ref -> Base.boolmodule Doc_helpers : sig ... end