package caisar
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=58ba1e38721795b306c860b56aaeba971be586cd55fb96e3ec8af72dd005101b
sha512=f1b3b9899660745598cebe7ecb52a39e9e16dcb7352381ea75a80d2afa988437130c00bf66355991421d4cb3dc06b02c185f7d4bdcc1c86dfcde8084bd01a654
doc/caisar.nir/Nir/Node/index.html
Module Nir.Node
Source
Nodes descriptions
A 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.
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 {
}
| 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
| 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 {
}
| 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;
}
| 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.
gather_int n i
gathers the i
th element of the node n
.
gather_ints n l
gathers the i
th 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.
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 ->
t
partial_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 n1
orlast > 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 <> 0
then use the shape ofarr1.(0)
- if
length arr2 <> 0
then 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
).