Ir.Assignments
The code for operating on n-dimensional arrays.
module Lazy = Utils.Lazy
module Tn = Tnode
module Nd = Ndarray
type init_data =
| Reshape of Ndarray.t
| Keep_shape_no_padding of Ndarray.t
| Padded of {
data : Nd.t;
padding : Ops.axis_padding Base.array;
padded_value : Base.float;
}
val sexp_of_init_data : init_data -> Sexplib0.Sexp.t
val sexp_of_buffer : buffer -> Sexplib0.Sexp.t
type fetch_op =
| Constant of Base.float
| Constant_bits of Base.int64
Direct bit representation, primarily for uint4x32
*)| Constant_fill of Base.float Base.array
Fills in the numbers where the rightmost axis is contiguous. Primes shape inference to require the assigned tensor to have the same number of elements as the array, but in case of "leaky" shape inference, will loop over the values. This unrolls all assignments and should be used only for small arrays. Consider using Tnode.set_values
instead for larger arrays.
| Range_over_offsets
Fills in the offset number of each cell, i.e. how many cells away it is from the beginning, in the logical representation of the tensor node. (The actual in-memory positions in a buffer instantiating the node can differ.)
*)| Slice of {
batch_idx : Indexing.static_symbol;
sliced : Tn.t;
}
| Embed_symbol of Indexing.static_symbol
| Embed_self_id
Embeds the id of the array
field of the Fetch
constructor.
| Embed_dim of Indexing.variable_ref
Resets a array by performing the specified computation or data fetching.
val sexp_of_fetch_op : fetch_op -> Sexplib0.Sexp.t
val sexp_of_accum_rhs : accum_rhs -> Sexplib0.Sexp.t
type t =
| Noop
| Seq of t * t
| Block_comment of Base.string * t
Same as the given code, with a comment.
*)| Accum_op of {
initialize_neutral : Base.bool;
accum : Ops.binop;
lhs : Tn.t;
rhs : accum_rhs;
projections : Indexing.projections Lazy.t;
projections_debug : Base.string;
}
| Set_vec_unop of {
op : Ops.vec_unop;
lhs : Tn.t;
rhs : buffer;
projections : Indexing.projections Lazy.t;
projections_debug : Base.string;
}
| Fetch of {
}
val sexp_of_t : t -> Sexplib0.Sexp.t
Computations based on assignments. Note: the arrayjit
library makes use of, but does not produce nor verify the embedded_nodes
associated to some given asgns
.
val sexp_of_comp : comp -> Sexplib0.Sexp.t
val empty_comp : comp
val is_total :
initialize_neutral:Base.bool ->
projections:Indexing.projections ->
Base.bool
val can_skip_accumulation : projections:Indexing.projections -> bool
Returns materialized nodes in the sense of Tnode.is_in_context_force
. NOTE: it must be called after compilation; otherwise, it will disrupt memory mode inference.
In the second set, returns the nodes that are not read from after being written to. In the first set, returns the nodes that are ever read from.
val to_low_level : t -> Low_level.t
val is_noop : t -> bool
val to_doc :
?name:Base.String.t ->
?static_indices:Ir__Indexing.static_symbol Base.List.t ->
unit ->
t ->
PPrint.document
val to_string : t -> string
val get_name_exn : t -> Base.String.t
val lower :
Low_level.optimize_ctx ->
unoptim_ll_source:(PPrint.document -> Base.unit) Base.option ->
ll_source:(PPrint.document -> Base.unit) Base.option ->
cd_source:(PPrint.document -> unit) option ->
name:Base.String.t ->
Indexing.static_symbol Base.List.t ->
t ->
Low_level.optimized