Module Prog.E
Programs written as values.
An expression is a node whose operands are expressions, typed by the dtype Prog.dtype gives its node. Each constructor's type states its kind's domain where a type can: float kinds take floats, comparisons give bool, and two operands of one kind share a dtype. Where it cannot, the constructor checks its operands' dtypes as Prog.v does, raising Invalid_argument where Prog.v refuses the node. An expression used twice is one value, which a let shares. Prog.of_exprs lowers expressions into a program.
type ('v, 's) tThe type for expressions of dtype ('v, 's) Nx_array.Dtype.t.
type anyThe type for expressions of any dtype.
val dtype : ('v, 's) t -> ('v, 's) Nx_array.Dtype.tdtype e is e's dtype.
Nodes
val input : int -> ('v, 's) Nx_array.Dtype.t -> ('v, 's) tinput k dt is In k, operand k of dtype dt.
Raises Invalid_argument if k is negative.
val coord : int -> (int64, Nx_array.Dtype.int64_elt) tcoord i is Coord i.
Raises Invalid_argument unless i is an axis below Nx_array.Layout.max_rank.
val const : ('v, 's) Nx_array.Dtype.t -> 'v -> ('v, 's) tval op1 : op1 -> ('w, 'r) Nx_array.Dtype.t -> ('v, 's) t -> ('w, 'r) top1 k dt x is Op1 (k, dt, x).
compare k x y is Op2 (Compare k, x, y).
op3 k c x y is Op3 (k, c, x, y).
Kinds
Each function makes the node of the kind it names: sqrt x is op1 (Unary Sqrt) (dtype x) x, rem x y is binary Mod x y, less x y is compare Less x y, cast dt x is op1 Cast dt x and where c x y is op3 Where c x y; but cast dt x is x itself where dt is dtype x, a cast that computes nothing.
val threefry :
(int64, Nx_array.Dtype.uint64_elt) t ->
(int64, Nx_array.Dtype.uint64_elt) t ->
(int64, Nx_array.Dtype.uint64_elt) tval equal : ('v, 's) t -> ('v, 's) t -> (bool, Nx_array.Dtype.bool_elt) tval not_equal : ('v, 's) t -> ('v, 's) t -> (bool, Nx_array.Dtype.bool_elt) tval less : ('v, 's) t -> ('v, 's) t -> (bool, Nx_array.Dtype.bool_elt) tval less_equal : ('v, 's) t -> ('v, 's) t -> (bool, Nx_array.Dtype.bool_elt) tval cast : ('w, 'r) Nx_array.Dtype.t -> ('v, 's) t -> ('w, 'r) tval bitcast : ('w, 'r) Nx_array.Dtype.t -> ('v, 's) t -> ('w, 'r) tOperators
For a local open, E.( … ), where they shadow Stdlib's.
x / y is idiv x y on integers and fdiv x y on other dtypes.
x && y is logand x y, at the precedence of Stdlib.( && ), below the comparisons.
x || y is logor x y, at the precedence of Stdlib.( || ).
val (=) : ('v, 's) t -> ('v, 's) t -> (bool, Nx_array.Dtype.bool_elt) tx = y is equal x y.
val (<>) : ('v, 's) t -> ('v, 's) t -> (bool, Nx_array.Dtype.bool_elt) tx <> y is not_equal x y.
val (<) : ('v, 's) t -> ('v, 's) t -> (bool, Nx_array.Dtype.bool_elt) tx < y is less x y.
val (<=) : ('v, 's) t -> ('v, 's) t -> (bool, Nx_array.Dtype.bool_elt) tx <= y is less_equal x y.
val (>) : ('v, 's) t -> ('v, 's) t -> (bool, Nx_array.Dtype.bool_elt) tx > y is less y x.
val (>=) : ('v, 's) t -> ('v, 's) t -> (bool, Nx_array.Dtype.bool_elt) tx >= y is less_equal y x.