package caisar
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=05024c094f68b82873f2c99c89d4f196049ac63b7d1d4f68ae1a1e3b08de7342
sha512=a26c724a19fca7c22a000367d1cd79c1e0474f373bf7265449928e55275ac44103190536dc8c76f5ac00a2a1897c3bd2ee06bb6f22140165079b72a27011e6df
doc/caisar.nir/Nir/Node/index.html
Module Nir.NodeSource
Nodes descriptions
A node is composed of
- a unique
idof 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.
type descr = | Constant of {data : Gentensor.t;
}(*A constant tensor, used to store non-varying parameters during inference.
*)| Add of {}| Sub of {}| Mul of {}| Div of {}| Sum of {input : t;
}| Matmul of {}| QLinearMatMul of {inputA : t;inputA_scale : t;inputA_zero_point : t;inputB : t;inputB_scale : t;inputB_zero_point : t;y_scale : t;y_zero_point : t;
}| Gemm of {inputA : t;inputB : t;inputC : t Base.option;alpha : Base.float;beta : Base.float;transA : Base.int;transB : Base.int;
}| QGemm of {inputA : t;inputA_scale : t;inputA_zero_point : t;inputB : t;inputB_scale : t;inputB_zero_point : t;inputC : t Base.option;y_scale : t Base.option;y_zero_point : t Base.option;alpha : Base.float;transA : Base.int;transB : Base.int;
}(*Not an ONNX operator of the default domain. Documentation at:
- https://xadupre.github.io/draft/inference/operators/onnx_commicrosoft_QGemm.html
- https://github.com/microsoft/onnxruntime/blob/main/docs/ContribOperators.md#commicrosoftqgemm
| LogSoftmax| Sigmoid of {input : t;
}| ReLu of {input : t;
}| Softmax of {}| 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 {}| Flatten of {}| Identity of {input : t;
}| Input of {shape : Shape.t;
}| RW_Linearized_ReLu| Concat of {}| Gather of {}| ReduceSum of {input : t;axes : t Base.option;keepdims : Base.int;noop_with_empty_axes : Base.int;
}| GatherND of {}| 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;
}| Exp of {input : t;
}| Sign of {input : t;
}| ArgMax of {}| Pow of {}| QuantizeLinear of {x : t;y_scale : t;y_zero_point : t Base.option;axis : Base.int;
}| DequantizeLinear of {x : t;x_scale : t;x_zero_point : t Base.option;axis : Base.int;
}
create descr returns a value of type node with proper indexing and the shape according to the ONNX semantic.
reducesum_int n sums all elements of the node n.
reducesum_with_ignored_indices n idx sums all elements of the node n, except elements of indices in idx.
gather_int n i gathers the ith element of the node n.
gather_ints n l gathers the ith element of the node n for each element i of l.
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 ()
Iterate on the predecessors of a t and itself. Repect topological order.
transpose_op perm n transposes node n shape by following perm. For instance, if perm = 0;2;1 and n is of shape 1;2;3, the output shape will be of shape 1;3;2. perm is assumed to be of the same shape as n.
add_one_dimension n is a node that is a copy of n but adds one dimension at the front of its shape. So a tensor [[a,b],[c,d]] of shape (2,2) would be rewritten into tensor [[[a,b],[c,d]]] of shape (1,2,2).
add_one_dimension_back n is a node that is a copy of n but adds one dimension at the back of its shape. So a tensor [[a,b],[c,d]] of shape (2,2) would be rewritten into tensor [[[a],[b]],[[c],[d]]] of shape (2,2,1).
sum_list shp ns is a node corresponding to the sum of the nodes in ns. If ns is empty, this returns a tensor of shape shp filled with 0s. By default, shp is a single float.
val partial_dot_product :
?shp:Shape.t ->
t Base.array ->
t Base.array ->
Base.int ->
Base.int ->
tpartial_dot_product shp arr1 arr2 first last where arr1 = [\|n11, n12, ..., n1k1\|] and arr2 = [\|n21, n22, ..., n2k2\|] is a node corresponding to (n1first * n2first) + (n1first + 1 * n2first + 1) + ... + (n1last - 1 * n2last - 1) if this exists. It is assumed that arr1 and arr2 contain tensors with same shape. Edge cases include:
- if
last > length n1orlast > length n2, then fails - if
last >= first, then returns a tensor where all values are initialized to 0. The shape of this tensor is determined using the following order:
- if
length arr1 <> 0then use the shape ofarr1.(0) - if
length arr2 <> 0then use the shape ofarr2.(0) - if
shp <> None, then useshp - otherwise, fails
transpose perm id is the position of the component at position id when the permutation perm is applied as the result of a tensor transposition. For instance, if id = [\|10; 20; 30\|] and \|perm = [2;0;1]\|, then transpose perm id will equal [\|30; 10; 20\|]. The empty permutation is represented by [] and is interpreted as [r-1; r-2; ...; 1; 0] (following <https://onnx.ai/onnx/operators/onnx__Transpose.html#transpose-23>); otherwise it is assumed that perm is a permutation of [0; 1; ...; r-1].
untranspose is the reverse of transpose so that untranspose perm @@ transpose perm id equals id.
flatten shp axis id computes the position of the component at position id when the flattening on axis is performed over shape shp. Following the definition of Flatten <https://onnx.ai/onnx/operators/onnx__Flatten.html#flatten-23>, axis can be negative in which case it computes from the end. For instance, if the shape is 10 * 10 * 10 * 10 * 10 (rank 5), axis = 3, and id = [\|1; 2; 3; 4; 5\|], then the result will be [\|123; 45\|] (computed as [\| 3 + (10 * ( 2 + 10 * 1)); 5 + 10 * 4) \|]).
unflatten is the reverse of flatten so that unflatten sh axis @@ flatten sh axis id equals id (for correct inputs id).