package neural_nets_lib

  1. Overview
  2. Docs

Module Ocannl.RowSource

The row type, shape inference related types and constraint solving.

Sourcetype kind = [
  1. | `Batch
  2. | `Input
  3. | `Output
]
Sourceval equal_kind : kind -> kind -> Base.bool
Sourceval compare_kind : kind -> kind -> Base.int
Sourceval sexp_of_kind : kind -> Sexplib0.Sexp.t
Sourceval kind_of_sexp : Sexplib0.Sexp.t -> kind
Sourceval __kind_of_sexp__ : Sexplib0.Sexp.t -> kind
Sourceval batch : kind
Sourceval input : kind
Sourceval output : kind
Sourceval is_batch : kind -> Base.bool
Sourceval is_input : kind -> Base.bool
Sourceval is_output : kind -> Base.bool
Sourceval batch_val : kind -> Base.unit Base.option
Sourceval input_val : kind -> Base.unit Base.option
Sourceval output_val : kind -> Base.unit Base.option
Sourcemodule Variants_of_kind : sig ... end
Sourcetype dim_var
Sourceval equal_dim_var : dim_var -> dim_var -> Base.bool
Sourceval compare_dim_var : dim_var -> dim_var -> Base.int
Sourceval sexp_of_dim_var : dim_var -> Sexplib0.Sexp.t
Sourceval dim_var_of_sexp : Sexplib0.Sexp.t -> dim_var
Sourcetype dim_cmp
Sourcetype dim_var_set = (dim_var, dim_cmp) Base.Set.t
Sourceval equal_dim_var_set : dim_var_set -> dim_var_set -> Base.bool
Sourceval sexp_of_dim_var_set : dim_var_set -> Sexplib0.Sexp.t
Sourceval dim_var_set_of_sexp : Sexplib0.Sexp.t -> dim_var_set
Sourcetype 'a dim_map = (dim_var, 'a, dim_cmp) Base.Map.t
Sourceval equal_dim_map : ('a -> 'a -> Base.bool) -> 'a dim_map -> 'a dim_map -> Base.bool
Sourceval sexp_of_dim_map : ('a -> Sexplib0.Sexp.t) -> 'a dim_map -> Sexplib0.Sexp.t
Sourceval dim_map_of_sexp : (Sexplib0.Sexp.t -> 'a) -> Sexplib0.Sexp.t -> 'a dim_map
Sourceval get_var : ?label:Base.string -> Base.unit -> dim_var
Sourceval dim_var_set_empty : dim_var_set
Sourceval dim_map_empty : 'a dim_map
Sourcetype dim =
  1. | Var of dim_var
  2. | Dim of {
    1. d : Base.int;
    2. label : Base.string Base.option;
    3. proj_id : Base.int Base.option;
    }

A single axis in a shape.

Sourceval equal_dim : dim -> dim -> Base.bool
Sourceval compare_dim : dim -> dim -> Base.int
Sourceval sexp_of_dim : dim -> Sexplib0.Sexp.t
Sourceval dim_of_sexp : Sexplib0.Sexp.t -> dim
Sourceval var : dim_var -> dim
Sourceval dim : d:Base.int -> label:Base.string Base.option -> proj_id:Base.int Base.option -> dim
Sourceval is_var : dim -> Base.bool
Sourceval is_dim : dim -> Base.bool
Sourceval var_val : dim -> dim_var Base.option
Sourceval dim_val : dim -> ([ `d of Base.int ] * [ `label of Base.string Base.option ] * [ `proj_id of Base.int Base.option ]) Base.option
Sourcemodule Variants_of_dim : sig ... end
Sourceval get_dim : d:Base.int -> ?label:Base.string -> Base.unit -> dim
Sourceval dim_to_int_exn : dim -> Base.int
Sourceval dim_to_string : [> `Only_labels ] -> dim -> Base.string
Sourcetype row_id
Sourceval sexp_of_row_id : row_id -> Sexplib0.Sexp.t
Sourceval row_id_of_sexp : Sexplib0.Sexp.t -> row_id
Sourceval compare_row_id : row_id -> row_id -> Base.int
Sourceval equal_row_id : row_id -> row_id -> Base.bool
Sourcetype row_cmp
Sourceval row_id : sh_id:Base.int -> kind:kind -> row_id
Sourcetype row_var
Sourceval sexp_of_row_var : row_var -> Sexplib0.Sexp.t
Sourceval row_var_of_sexp : Sexplib0.Sexp.t -> row_var
Sourceval compare_row_var : row_var -> row_var -> Base.int
Sourceval equal_row_var : row_var -> row_var -> Base.bool
Sourceval get_row_var : Base.unit -> row_var
Sourcetype bcast =
  1. | Row_var of {
    1. v : row_var;
    2. beg_dims : dim Base.list;
    }
    (*

    The row can be inferred to have more axes.

    *)
  2. | Broadcastable
    (*

    The shape does not have more axes of this kind, but is "polymorphic".

    *)

A bcast specifies how axes of a single kind in a shape (i.e. the row) can adapt to other shapes.

Sourceval equal_bcast : bcast -> bcast -> Base.bool
Sourceval compare_bcast : bcast -> bcast -> Base.int
Sourceval sexp_of_bcast : bcast -> Sexplib0.Sexp.t
Sourceval bcast_of_sexp : Sexplib0.Sexp.t -> bcast
Sourceval row_var : v:row_var -> beg_dims:dim Base.list -> bcast
Sourceval broadcastable : bcast
Sourceval is_row_var : bcast -> Base.bool
Sourceval is_broadcastable : bcast -> Base.bool
Sourceval row_var_val : bcast -> ([ `v of row_var ] * [ `beg_dims of dim Base.list ]) Base.option
Sourceval broadcastable_val : bcast -> Base.unit Base.option
Sourcemodule Variants_of_bcast : sig ... end
Sourcetype t = {
  1. dims : dim Base.list;
  2. bcast : bcast;
  3. id : row_id;
}
include Ppx_compare_lib.Equal.S with type t := t
Sourceval equal : t -> t -> bool
include Ppx_hash_lib.Hashable.S with type t := t
Sourceval hash_fold_t : Base.Hash.state -> t -> Base.Hash.state
include Ppx_compare_lib.Comparable.S with type t := t
Sourceval compare : t -> t -> int
include Sexplib0.Sexpable.S with type t := t
Sourceval t_of_sexp : Sexplib0.Sexp.t -> t
Sourceval sexp_of_t : t -> Sexplib0.Sexp.t
Sourceval dims_label_assoc : t -> (Base.string * dim) Base.list
Sourcetype environment
Sourceval sexp_of_environment : environment -> Sexplib0.Sexp.t
Sourceval environment_of_sexp : Sexplib0.Sexp.t -> environment
Sourcetype error_trace = ..
Sourcetype error_trace +=
  1. | Row_mismatch of t Base.list
  2. | Dim_mismatch of dim Base.list
  3. | Index_mismatch of Arrayjit.Indexing.axis_index Base.list
Sourceval sexp_of_error_trace : error_trace -> Base.Sexp.t
Sourceexception Shape_error of Base.string * error_trace Base.list
Sourcetype dim_constraint =
  1. | Unconstrained_dim
  2. | At_least_dim of Base.int
Sourceval equal_dim_constraint : dim_constraint -> dim_constraint -> Base.bool
Sourceval compare_dim_constraint : dim_constraint -> dim_constraint -> Base.int
Sourceval sexp_of_dim_constraint : dim_constraint -> Sexplib0.Sexp.t
Sourceval dim_constraint_of_sexp : Sexplib0.Sexp.t -> dim_constraint
Sourceval unconstrained_dim : dim_constraint
Sourceval at_least_dim : Base.int -> dim_constraint
Sourceval is_unconstrained_dim : dim_constraint -> Base.bool
Sourceval is_at_least_dim : dim_constraint -> Base.bool
Sourceval unconstrained_dim_val : dim_constraint -> Base.unit Base.option
Sourceval at_least_dim_val : dim_constraint -> Base.int Base.option
Sourcetype row_constraint =
  1. | Unconstrained
  2. | Total_elems of {
    1. nominator : Base.int;
    2. divided_by : dim_var_set;
    }
    (*

    The row or remainder of a row, inclusive of the further row spec, has this many elements.

    *)
Sourceval equal_row_constraint : row_constraint -> row_constraint -> Base.bool
Sourceval compare_row_constraint : row_constraint -> row_constraint -> Base.int
Sourceval sexp_of_row_constraint : row_constraint -> Sexplib0.Sexp.t
Sourceval row_constraint_of_sexp : Sexplib0.Sexp.t -> row_constraint
Sourceval unconstrained : row_constraint
Sourceval total_elems : nominator:Base.int -> divided_by:dim_var_set -> row_constraint
Sourceval is_unconstrained : row_constraint -> Base.bool
Sourceval is_total_elems : row_constraint -> Base.bool
Sourceval unconstrained_val : row_constraint -> Base.unit Base.option
Sourceval total_elems_val : row_constraint -> ([ `nominator of Base.int ] * [ `divided_by of dim_var_set ]) Base.option
Sourcetype dim_entry =
  1. | Solved_dim of dim
  2. | Bounds_dim of {
    1. cur : dim_var Base.list;
    2. subr : dim_var Base.list;
    3. lub : dim Base.option;
    4. constr : dim_constraint;
    }

An entry implements inequalities cur >= v >= subr and/or an equality v = solved. cur and subr must be sorted using the @@deriving compare comparison.

Sourceval sexp_of_dim_entry : dim_entry -> Sexplib0.Sexp.t
Sourceval dim_entry_of_sexp : Sexplib0.Sexp.t -> dim_entry
Sourcetype row_entry =
  1. | Solved_row of t
  2. | Bounds_row of {
    1. cur : row_var Base.list;
    2. subr : row_var Base.list;
    3. lub : t Base.option;
    4. constr : row_constraint;
    }
Sourceval sexp_of_row_entry : row_entry -> Sexplib0.Sexp.t
Sourceval row_entry_of_sexp : Sexplib0.Sexp.t -> row_entry
Sourcetype constraint_ =
  1. | Dim_eq of {
    1. d1 : dim;
    2. d2 : dim;
    }
  2. | Row_eq of {
    1. r1 : t;
    2. r2 : t;
    }
  3. | Dim_ineq of {
    1. cur : dim;
    2. subr : dim;
    }
  4. | Row_ineq of {
    1. cur : t;
    2. subr : t;
    }
  5. | Dim_constr of {
    1. d : dim;
    2. constr : dim_constraint;
    }
  6. | Row_constr of {
    1. r : t;
    2. constr : row_constraint;
    }
  7. | Terminal_dim of dim
  8. | Terminal_row of t
Sourceval compare_constraint_ : constraint_ -> constraint_ -> Base.int
Sourceval equal_constraint_ : constraint_ -> constraint_ -> Base.bool
Sourceval sexp_of_constraint_ : constraint_ -> Sexplib0.Sexp.t
Sourceval constraint__of_sexp : Sexplib0.Sexp.t -> constraint_
Sourceval dim_eq : d1:dim -> d2:dim -> constraint_
Sourceval row_eq : r1:t -> r2:t -> constraint_
Sourceval dim_ineq : cur:dim -> subr:dim -> constraint_
Sourceval row_ineq : cur:t -> subr:t -> constraint_
Sourceval dim_constr : d:dim -> constr:dim_constraint -> constraint_
Sourceval row_constr : r:t -> constr:row_constraint -> constraint_
Sourceval terminal_dim : dim -> constraint_
Sourceval terminal_row : t -> constraint_
Sourceval is_dim_eq : constraint_ -> Base.bool
Sourceval is_row_eq : constraint_ -> Base.bool
Sourceval is_dim_ineq : constraint_ -> Base.bool
Sourceval is_row_ineq : constraint_ -> Base.bool
Sourceval is_dim_constr : constraint_ -> Base.bool
Sourceval is_row_constr : constraint_ -> Base.bool
Sourceval is_terminal_dim : constraint_ -> Base.bool
Sourceval is_terminal_row : constraint_ -> Base.bool
Sourceval dim_eq_val : constraint_ -> ([ `d1 of dim ] * [ `d2 of dim ]) Base.option
Sourceval row_eq_val : constraint_ -> ([ `r1 of t ] * [ `r2 of t ]) Base.option
Sourceval dim_ineq_val : constraint_ -> ([ `cur of dim ] * [ `subr of dim ]) Base.option
Sourceval row_ineq_val : constraint_ -> ([ `cur of t ] * [ `subr of t ]) Base.option
Sourceval dim_constr_val : constraint_ -> ([ `d of dim ] * [ `constr of dim_constraint ]) Base.option
Sourceval row_constr_val : constraint_ -> ([ `r of t ] * [ `constr of row_constraint ]) Base.option
Sourceval terminal_dim_val : constraint_ -> dim Base.option
Sourceval terminal_row_val : constraint_ -> t Base.option
Sourcemodule Variants_of_constraint_ : sig ... end
Sourcetype stage =
  1. | Stage1
  2. | Stage2
  3. | Stage3
  4. | Stage4
  5. | Stage5
  6. | Stage6
  7. | Stage7
Sourceval sexp_of_stage : stage -> Sexplib0.Sexp.t
Sourceval stage_of_sexp : Sexplib0.Sexp.t -> stage
Sourceval equal_stage : stage -> stage -> Base.bool
Sourceval compare_stage : stage -> stage -> Base.int
Sourceval subst_row : environment -> t -> t
Sourceval unify_row : stage:stage -> (t * t) -> environment -> constraint_ Base.list * environment
Sourceval empty_env : environment
Sourceval eliminate_variables : environment -> t -> constraint_ Base.list
Sourceval row_to_labels : environment -> t -> Base.string Base.array
Sourcetype proj
Sourceval compare_proj : proj -> proj -> Base.int
Sourceval equal_proj : proj -> proj -> Base.bool
Sourceval sexp_of_proj : proj -> Sexplib0.Sexp.t
Sourceval proj_of_sexp : Sexplib0.Sexp.t -> proj
Sourcetype proj_env
Sourceval sexp_of_proj_env : proj_env -> Sexplib0.Sexp.t
Sourceval proj_env_of_sexp : Sexplib0.Sexp.t -> proj_env
Sourceval fresh_row_proj : t -> t
Sourcetype proj_equation =
  1. | Proj_eq of proj * proj
    (*

    Two projections are the same, e.g. two axes share the same iterator.

    *)
  2. | Iterated of proj
    (*

    The projection needs to be an iterator even if an axis is not matched with another axis, e.g. for broadcasted-to axes of a tensor assigned a constant.

    *)
Sourceval compare_proj_equation : proj_equation -> proj_equation -> Base.int
Sourceval equal_proj_equation : proj_equation -> proj_equation -> Base.bool
Sourceval sexp_of_proj_equation : proj_equation -> Sexplib0.Sexp.t
Sourceval proj_equation_of_sexp : Sexplib0.Sexp.t -> proj_equation
Sourceval solve_proj_equations : proj_equation Base.list -> proj_env
Sourceval get_product_proj : proj_env -> dim -> (Base.int * Base.int) Base.option
Sourceval proj_to_iterator : proj_env -> Base.int -> Arrayjit.Indexing.symbol