Documentation
caisar.nir lib
Nir
. Node
Module
Nodes descriptionsA node is composed of
a unique id
of type int a node description of type descr
descr
describes several operations. When an operation shares the same name as an ONNX operation, it follows the standard defined in the ONNX IR v8 and ONNX Opset v13 standards, described here: https://onnx.ai/onnx/operators/index.html.
Nodes only require their inputs: it is assumed that a node only returns one value.
val pp_ty :
Ppx_deriving_runtime .Format.formatter ->
ty ->
Ppx_deriving_runtime .unit
val show_ty : ty -> Ppx_deriving_runtime .string
type descr =
| Constant of {
data : Gentensor.t ;
}
A constant tensor, used to store non-varying parameters during inference.
| Add of {
input1 : t ;
input2 : t ;
}
| Sub of {
input1 : t ;
input2 : t ;
}
| Mul of {
input1 : t ;
input2 : t ;
}
| Div of {
input1 : t ;
input2 : t ;
}
| Matmul of {
input1 : t ;
input2 : t ;
}
| Gemm of {
inputA : t ;
inputB : t ;
inputC : t Base .option ;
alpha : Base .float;
beta : Base .float;
transA : Base .int;
transB : Base .int;
}
| LogSoftmax
| ReLu of {
input : t ;
}
| Transpose of {
input : t ;
Called "data" in ONNX documentation : https://onnx.ai/onnx/operators/onnx__Transpose.html .
perm : Base .int Base .list ;
}
| Squeeze of {
data : t ;
axes : t Base .option ;
}
| MaxPool
| Conv
| Reshape of {
input : t ;
shape : t ;
}
| Flatten of {
input : t ;
axis : Base .int;
}
| Identity of {
input : t ;
}
| Input of {
shape : Shape.t ;
}
| RW_Linearized_ReLu
| Concat of {
inputs : t Base .list ;
axis : Base .int;
}
| Gather of {
input : t ;
indices : t ;
axis : Base .int;
}
| ReduceSum of {
input : t ;
axes : t Base .option ;
keepdims : Base .int;
noop_with_empty_axes : Base .int;
}
| GatherND of {
data : t ;
indices : t ;
batch_dims : Base .int;
}
| RandomNormal of {
dtype : Base .int;
mean : Base .float;
scale : Base .float;
seed : Base .float;
shape : Base .int Base .array ;
}
| Abs of {
input : t ;
}
| Log of {
input : t ;
}
and t = private {
id : Base .int;
descr : descr ;
shape : Shape.t ;
ty : ty ;
Describes the shape of the result of the node computation.
}
val pp_descr :
Ppx_deriving_runtime .Format.formatter ->
descr ->
Ppx_deriving_runtime .unit
val show_descr : descr -> Ppx_deriving_runtime .string
val pp :
Ppx_deriving_runtime .Format.formatter ->
t ->
Ppx_deriving_runtime .unit
val show : t -> Ppx_deriving_runtime .string
val equal : t -> t -> Base .bool
include Base .Hashtbl.Key.S with type t := t
val compare : t Base__Ppx_compare_lib .compare
val sexp_of_t : t -> Sexplib0 .Sexp.t
include Base .Comparator.S with type t := t
create descr
returns a value of type node with proper indexing and the shape according to the ONNX semantic.
val gather_int : ?encode :Base .bool -> t -> Base .int -> t
val map : (t -> t ) -> t -> t
map f n
replace the direct inputs i
of n by f i
val map_rec : (t -> t ) -> t -> t
map_rec f n
replace top-bottom the nodes i
accessible from n
by f i
replace_input f n
replace the input in n
by f ()
val preds : t -> t Base .list
Direct predecessors of a t
val iter_rec : (t -> Base .unit) -> t -> Base .unit
Iterate on the predecessors of a t and itself. Repect topological order.
val mul_float : t -> Base .float -> t
val div_float : ?encode :Base .bool -> t -> Base .float -> t
val concat_0 : t Base .list -> t