Arrayjit.Tnode
module Lazy = Utils.Lazy
module Nd = Ndarray
A possible algorithm for deciding sharing within a single device:
If a tensor node is shared cross-stream, within-device copying is a NOOP as source and destination pointers are in that case identical.
val sharing_of_sexp : Sexplib0.Sexp.t -> sharing
val sexp_of_sharing : sharing -> Sexplib0.Sexp.t
type memory_type =
| Constant
The tensor node does not change after initialization.
*)| Nonconstant
One of: Changed_on_devices
, Volatile
.
| Changed_on_devices of sharing
The tensor node will only change on host via a to_host
call.
| Volatile
The tensor node will only change on any device via a from_host
call possibly followed by device_to_device
.
val memory_type_of_sexp : Sexplib0.Sexp.t -> memory_type
val sexp_of_memory_type : memory_type -> Sexplib0.Sexp.t
val compare_memory_type : memory_type -> memory_type -> Base.int
val equal_memory_type : memory_type -> memory_type -> Base.bool
type memory_mode =
| Effectively_constant
Either Hosted Constant
, or a subset of Virtual
.
| Virtual
The tensor node's computations are inlined on a per-scalar basis.
*)| Never_virtual
One of: Local
, On_device
, Hosted
.
| 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.
*)| Device_only
One of: Local
, On_device
.
| On_device of sharing
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), but not (directly) for visualization or storing to disk.
*)| Materialized
One of: On_device
, Hosted
.
| Hosted of memory_type
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
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
val sexp_of_prepare : prepare -> Sexplib0.Sexp.t
type t = {
array : Nd.t Base.option Lazy.t;
prec : Ops.prec Lazy.t;
dims : Base.int Base.array Lazy.t;
size_in_bytes : Base.int Lazy.t;
id : Base.int;
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.
*)mutable delayed_prec_unsafe : delayed_prec;
mutable memory_mode : (memory_mode * Base.int) Base.option;
mutable backend_info : Base.Sexp.t;
mutable code_name : Base.string Base.option;
mutable prepare_read : prepare Base.option;
mutable prepare_write : prepare Base.option;
mutable host_read_by_devices : Base.Hash_set.M(Base.Int).t;
The unique ids of devices that read the most recent modification of the host array.
*)}
val sexp_of_t : t -> Sexplib0.Sexp.t
val num_elems : t -> Base.int
val id : t -> Base.String.t
val label : t -> Base.String.t
val prepare_read :
is_done:(Base.unit -> Base.bool) ->
sync:(Base.unit -> Base.unit) ->
transfer:(Base.unit -> Base.unit) ->
t ->
unit
val prepare_write :
is_done:(Base.unit -> Base.bool) ->
sync:(Base.unit -> Base.unit) ->
t ->
unit
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 -> unit
The one exception to "most local" is that the sharing property is kept at Unset
.
val is_virtual_force : t -> Base.int -> bool
val is_hosted_force : t -> Base.int -> bool
val is_materialized_force : t -> Base.int -> bool
val is_in_context_force :
use_host_memory:'a Base.option ->
t ->
Base.int ->
Base.bool
val known_not_materialized : t -> bool
val known_constant : t -> bool
val known_volatile : t -> bool
val known_non_virtual : t -> bool
val known_not_param : t -> bool
val known_non_cross_stream : t -> bool
val potentially_cross_stream : t -> Base.bool
val mode_is_unspecified : t -> bool
val update_memory_mode : t -> memory_mode -> Base.int -> unit
update_memory_sharing tn sharing provenance
preserves the memory mode of tn
while updating the cross-stream sharing property, except that Hosted Nonconstant
is further specialized to Hosted (Changed_on_devices sharing)
.
val exceeds_fp16_cutoff : t -> Base.Float.t -> Base.bool
include sig ... end
val comparator : (t, comparator_witness) Base__Comparator.comparator
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
val sexp_of_t_set : (t, 'a) Base.Set.t -> Sexplib0.Sexp.t
val has : t -> bool
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 header : t -> string
module Registry : sig ... end
val registry : Registry.t
val create :
?default_prec:Ops.prec Lazy.t ->
id:Base__Int.t ->
label:Base.String.t Base.List.t ->
dims:Base.int Base.array Lazy.t ->
Ops.init_op ->
t
val find : id:Base.int -> Registry.data option
val do_read : t -> unit
val do_write : t -> unit
val points_1d :
?from_axis:Base__Int.t ->
xdim:int ->
t ->
Base.Float.t Base.Array.t
val points_2d :
?from_axis:Base__Int.t ->
xdim:int ->
ydim:int ->
t ->
(Base.Float.t * Base.Float.t) Base.Array.t
val set_value : t -> int array -> Base.float -> unit
val get_value : t -> int array -> Base.Float.t
val set_values : t -> Base.float Base.array -> unit
val get_values : t -> Base.Float.t Base.Array.t