package arrayjit

  1. Overview
  2. Docs

N-dimensional arrays: a precision-handling wrapper for Bigarray.Genarray and its utilities.

module Debug_runtime = Utils.Debug_runtime
val _get_local_debug_runtime : unit -> (module Minidebug_runtime.Debug_runtime)

*** Handling of precisions ***

type ('ocaml, 'elt_t) bigarray = ('ocaml, 'elt_t, Bigarray.c_layout) A.t
val big_ptr_to_string : ('a, 'b, 'c) Bigarray_compat.Genarray.t -> Base.String.t
val sexp_of_bigarray : ('a, 'b) bigarray -> Base.Sexp.t
type byte_nd = (Base.char, Ops.uint8_elt) bigarray
type single_nd = (Base.float, Ops.float32_elt) bigarray
type double_nd = (Base.float, Ops.float64_elt) bigarray
val sexp_of_byte_nd : byte_nd -> Base.Sexp.t
val sexp_of_half_nd : half_nd -> Base.Sexp.t
val sexp_of_single_nd : single_nd -> Base.Sexp.t
val sexp_of_double_nd : double_nd -> Base.Sexp.t
type t =
  1. | Byte_nd of byte_nd
  2. | Half_nd of half_nd
  3. | Single_nd of single_nd
  4. | Double_nd of double_nd
val sexp_of_t : t -> Sexplib0.Sexp.t
val as_array : ('ocaml, 'elt_t) Ops.precision -> ('ocaml0, 'elt_t0) bigarray -> t
val precision_to_bigarray_kind : ('ocaml, 'elt_t) Ops.precision -> ('ocaml0, 'elt_t0) Bigarray.kind
val precision_string : t -> string
val get_prec : t -> Ops.prec
type 'r map_with_prec = {
  1. f : 'ocaml 'elt_t. ('ocaml, 'elt_t) Ops.precision -> ('ocaml, 'elt_t) bigarray -> 'r;
}
val map_with_prec : 'a map_with_prec -> t -> 'b
val create_bigarray_of_prec : ('ocaml, 'elt_t) Ops.precision -> int array -> ('ocaml0, 'elt_t0) bigarray
val init_bigarray_of_prec : ('ocaml, 'elt_t) Ops.precision -> int array -> f:(Base.int Base.array -> 'ocaml0) -> ('ocaml1, 'elt_t0) bigarray
val indices_to_offset : dims:int Base.Array.t -> idcs:int Base.Array.t -> int
val create_bigarray : ('ocaml, 'elt_t) Ops.precision -> dims:int Base.Array.t -> Ops.init_op -> ('ocaml0, 'elt_t0) bigarray

*** Accessing ***

type 'r map_as_bigarray = {
  1. f : 'ocaml 'elt_t. ('ocaml, 'elt_t) bigarray -> 'r;
}
val map : 'a map_as_bigarray -> t -> 'b
type 'r map2_as_bigarray = {
  1. f2 : 'ocaml 'elt_t. ('ocaml, 'elt_t) bigarray -> ('ocaml, 'elt_t) bigarray -> 'r;
}
val map2 : 'a map2_as_bigarray -> t -> t -> 'b
val dims : t -> int array
val get_voidptr : t -> unit Ctypes_static.ptr
val set_from_float : t -> int array -> Base.float -> unit
val fill_from_float : t -> Base.float -> unit
val set_bigarray : ('a, 'b, 'c) A.t -> f:(int Base.Array.t -> 'd) -> unit
val reset_bigarray : Ops.init_op -> ('o, 'b) Ops.precision -> ('o0, 'b0) bigarray -> unit
val reset : Ops.init_op -> t -> unit
val fold_bigarray : ('a, 'b, 'c) A.t -> init:'d -> f:('e -> int Base.Array.t -> 'f -> 'g) -> 'h
val fold_as_float : init:'a -> f:('b -> int Base.Array.t -> Base.float -> 'b) -> t -> 'c
val size_in_bytes : t -> int
val get_as_float : t -> int array -> Base.Float.t
val retrieve_2d_points : ?from_axis:int -> xdim:int -> ydim:int -> t -> (Base.Float.t * Base.Float.t) Base.Array.t
val retrieve_1d_points : ?from_axis:int -> xdim:int -> t -> Base.Float.t Base.Array.t
val retrieve_flat_values : t -> Base.Float.t Base.Array.t
val c_ptr_to_string : t -> Base.String.t

*** Creating ***

val create_array : debug:'a -> Ops.prec -> dims:int Base.Array.t -> Ops.init_op -> t
val empty_array : Ops.prec -> debug:'a -> t

*** Printing ***

val int_dims_to_string : ?with_axis_numbers:bool -> Base.Int.t Base.Array.t -> Base.String.t

Dimensions to string, "x"-separated, e.g. 1x2x3 for batch dims 1, input dims 3, output dims 2. Outputs "-" for empty dimensions.

val log_debug_info : from_log_level:int -> t -> unit

Logs information about the array on the default ppx_minidebug runtime, if from_log_level > Utlis.settings.with_log_level.

val concise_float : prec:int -> float -> Base.String.t
val render_array : ?brief:Base.bool -> ?prefix:Base.String.t -> ?entries_per_axis:int -> ?labels:Base.String.t Base.Array.t -> indices:int Base.Array.t -> t -> PrintBox.t

Prints 0-based indices entries out of arr, where a number between -5 and -1 in an axis means to print out the axis, and a non-negative number means to print out only the indexed dimension of the axis. Prints up to entries_per_axis or entries_per_axis+1 entries per axis, possibly with ellipsis in the middle. labels provides the axis labels for all axes (use "" or "_" for no label). The last label corresponds to axis -1 etc. The printed out axes are arranged as:

  • -1: a horizontal segment in an inner rectangle (i.e. column numbers of the inner rectangle),
  • -2: a sequence of segments in a line of text (i.e. column numbers of an outer rectangle),
  • -3: a vertical segment in an inner rectangle (i.e. row numbers of the inner rectangle),
  • -4: a vertical sequence of segments (i.e. column numbers of an outer rectangle),
  • -5: a sequence of screens of text (i.e. stack numbers of outer rectangles).
val pp_array : Format.formatter -> ?prefix:Base.String.t -> ?entries_per_axis:int -> ?labels:Base.String.t Base.Array.t -> indices:int Base.Array.t -> t -> unit
val pp_array_inline : Format.formatter -> num_batch_axes:int -> num_output_axes:int -> num_input_axes:int -> ?axes_spec:string -> t -> unit

Prints the whole array in an inline syntax.

val save : file_name:string -> t -> unit
val restore : file_name:string -> t -> unit
OCaml

Innovation. Community. Security.