Module Ir.Tnode

module Lazy = Utils.Lazy
module Nd = Ndarray
val _get_local_debug_runtime : unit -> (module Minidebug_runtime.Debug_runtime)
type memory_mode =
  1. | Effectively_constant
    (*

    A constant, or a subset of Virtual.

    *)
  2. | Virtual
    (*

    The tensor node's computations are inlined on a per-scalar basis.

    *)
  3. | Never_virtual
    (*

    One of: Local, On_device, Materialized.

    *)
  4. | Local
    (*

    The full tensor node is cached for the duration of a computation but not persisted across calls to compiled functions. It is not available for merging across devices.

    *)
  5. | Device_only
    (*

    One of: Local, On_device.

    *)
  6. | On_device
    (*

    The tensor node is stored on the devices that compute with it and persisted across function calls. It is available for merging across devices (for devices that support merging / P2P). CPU-side access (printing, persistence, inspection) is on-demand via context-mediated device-to-host transfers; no host copy is stored on the node.

    *)
  7. | Materialized
    (*

    An as-yet-unresolved request for a persisted (non-virtual, non-local) node; resolves to On_device.

    *)
val memory_mode_of_sexp : Sexplib0.Sexp.t -> memory_mode
val sexp_of_memory_mode : memory_mode -> Sexplib0.Sexp.t
val compare_memory_mode : memory_mode -> memory_mode -> Base.int
val equal_memory_mode : memory_mode -> memory_mode -> Base.bool
type delayed_prec =
  1. | Default of Ops.prec
  2. | Inferred of Ops.prec Lazy.t
  3. | Specified of Ops.prec
val delayed_prec_of_sexp : Sexplib0.Sexp.t -> delayed_prec
val sexp_of_delayed_prec : delayed_prec -> Sexplib0.Sexp.t
val equal_delayed_prec : delayed_prec -> delayed_prec -> Base.bool
type t = {
  1. prec : Ops.prec Lazy.t;
  2. dims : Base.int Base.array Lazy.t;
  3. padding : (Ops.axis_padding Base.array * Base.float Base.option) Base.option Lazy.t;
    (*

    If the tensor node is pre-padded, this is the pair of (left padding, right padding) per axis and the padding/neutral value. The inner float option is None when the tensor is used by operations with different neutral elements, requiring margin resets before each operation.

    *)
  4. size_in_bytes : Base.int Lazy.t;
  5. id : Base.int;
  6. label : Base.string Base.list;
    (*

    Display information. It is better if the last element of the list is the most narrow or alphanumeric, e.g. an identifier.

    *)
  7. mutable delayed_prec_unsafe : delayed_prec;
    (*

    Participates in the computation of prec.

    *)
  8. mutable memory_mode : (memory_mode * Base.int) Base.option;
  9. mutable alias_of : (t * Indexing.static_symbol) Base.option;
    (*

    When Some (parent, batch_idx), this node is a zero-copy slice-alias *view* of parent: it owns no buffer of its own, and every read/write of it is redirected (during lowering) to parent with batch_idx prepended as the leading index. Set by Assignments.lower for alias-eligible Fetch.Slices; orthogonal to memory_mode. The strong reference to parent also keeps it reachable for as long as the alias is.

    *)
  10. mutable slice_of : (t * Indexing.static_symbol) Base.option;
    (*

    When Some (parent, batch_idx), this node is an \@| sub-tensor slice of parent. Set *eagerly at construction* (independent of alias eligibility), so it is a superset of alias_of: every confirmed alias is a slice, but an ineligible slice (precision- converting, padded, virtual parent) is still a slice that falls back to a materializing copy. Used to reject direct host access (read/write the parent instead) -- including the window before lowering decides eligibility, where alias_of is still None.

    *)
  11. mutable backend_info : Base.Sexp.t;
  12. mutable code_name : Base.string Base.option;
}
val sexp_of_t : t -> Sexplib0.Sexp.t
val compare : t -> t -> Base.int
val num_elems : t -> Base__Int.t
val dims_without_padding : t -> Base.int Base.array
val get_padding : t -> (Ops.axis_padding Base.array * Base.float Base.option) Base.option
val id : t -> Base.String.t
val label : t -> Base.String.t
val is_alphanum_ : Base.String.t -> Base.bool
val collapse_consecutive : Base.String.t list -> Base.String.t Base.List.t
val get_debug_name : ?code_name:Base.String.t -> id:Base__Int.t -> label:Base.String.t Base.List.t -> unit -> Base.String.t
val debug_name : t -> Base.String.t
val debug_memory_mode : (memory_mode * Base.Int.t) option -> Base.String.t
val log_debug_info : from_log_level:int -> t -> unit
val default_to_most_local : t -> Base__Int.t -> unit

Defaults to the most local memory mode compatible with the current setting.

val is_virtual_force : t -> Base.int -> bool
val is_materialized_force : t -> Base__Int.t -> bool
val is_alias : t -> bool

A slice-alias view (see alias_of). Such a node owns no buffer of its own; its accesses are redirected to its parent during lowering.

val alias_of : t -> (t * Indexing.static_symbol) Base.option
val set_alias_of : t -> parent:t -> batch_idx:Indexing.static_symbol -> unit

Marks tn as a zero-copy slice-alias view of parent with leading index batch_idx. Idempotent when re-marked with the same parent.

val is_slice : t -> bool

Whether tn is an \@| sub-tensor slice (see slice_of) -- set eagerly at construction, independent of alias eligibility. A superset of is_alias.

val slice_of : t -> (t * Indexing.static_symbol) Base.option
val set_slice_of : t -> parent:t -> batch_idx:Indexing.static_symbol -> unit

Marks tn as an \@| slice of parent eagerly at construction (before alias eligibility is known). Idempotent.

val is_in_context_force : t -> Base.int -> Base.bool
val known_not_materialized : t -> bool
val known_constant : t -> bool
val known_non_virtual : t -> bool
val known_virtual : t -> bool
val mode_is_unspecified : t -> bool
val update_memory_mode : t -> memory_mode -> Base.int -> unit
val update_prec : ?only_if:(Ops.prec -> bool) -> t -> Ops.prec -> unit
val update_infer_prec : ?only_if:(Ops.prec -> bool) -> t -> Ops.prec Lazy.t -> unit
val get_specified_prec : t -> Ops.prec option
include sig ... end
type comparator_witness
val comparator : (t, comparator_witness) Base__Comparator.comparator
val equal : t -> t -> Base.bool
val hash : t -> Base__Ppx_hash_lib.Std.Hash.hash_value
val hash_fold_t : Base__.Ppx_hash_lib.Std.Hash.state -> t -> Base__.Ppx_hash_lib.Std.Hash.state
val hash_t : t -> Base__Ppx_hash_lib.Std.Hash.hash_value
module Comp : sig ... end
type t_set = Base.Set.M(Comp).t
val sexp_of_t_set : (t, 'a) Base.Set.t -> Sexplib0.Sexp.t
type 'a t_map = (t, 'a, comparator_witness) Base.Map.t
val sexp_of_t_map : ('a -> Sexplib0.Sexp.t) -> (t, 'a, 'b) Base.Map.t -> Sexplib0.Sexp.t
val dims_to_string : ?with_axis_numbers:bool -> t -> Base.String.t
val no_grad_ident_label : t -> bool * Base.String.t option
val styled_ident : repeating_nograd_idents:(Base.String.t, 'a) Base.Hashtbl.t -> repeating_grad_idents:(Base.String.t, 'a) Base.Hashtbl.t -> [< `Heuristic_ocannl of [< `Dot_grad | `Under_grad ] | `Name_and_label | `Name_only ] -> t -> Base.String.t
val update_code_name : t -> Base.string -> unit
val get_style : ?arg_name:Base.string -> ?no_dots:bool -> unit -> [> `Heuristic_ocannl of [> `Dot_grad | `Under_grad ] | `Name_and_label | `Name_only ]
val header : t -> string
module Registry : sig ... end
val registry : Registry.t
val prec_of_dalayed : t -> Ops.prec
val create : delayed_prec -> id:Base.int -> label:Base.string Base.list -> unpadded_dims:Base__Int.t Base.Array.t Lazy.t -> padding: (Ops.axis_padding Base.array * Base.float Base.option) Base.option Lazy.t -> unit -> t
val create_from_padded : id:Base.int -> label:Base.string Base.list -> ndarray:Nd.t -> padding:(Ops.axis_padding Base.array * Base.float Base.option) Base.option -> unit -> t * Nd.t lazy_t
val create_with_reshape : id:Base__Int.t -> label:Base.String.t Base.List.t -> base_ndarray:Nd.t -> unpadded_dims:Base__Int.t Base.Array.t Lazy.t -> padding: (Ops.axis_padding Base.array * Base.float Base.option) Base.Option.t Lazy.t -> from_padded:bool -> unit -> t * Nd.t lazy_t
val initial_default_prec : Ops.prec
val find : id:Base.int -> Registry.data option

Accessors

Host-side value access (get_value, set_value, get_values, set_values, points_1d, points_2d) now lives in Context: it requires an explicit context and performs an on-demand device-to-host transfer. There is no host copy stored on the tensor node.

val print_accessible_headers : ?pred:(Registry.data -> bool) -> unit -> Base.unit
val log_accessible_headers : ?pred:(Registry.data -> bool) -> unit -> unit