You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* The long-term goal is to provide several "low-level" backends, aiming to seek inspiration from projects such as [TinyGrad](https://github.com/tinygrad/tinygrad), [TVM](https://github.com/apache/tvm), [Luminal](https://github.com/jafioti/luminal).
9
+
* The long-term goal is to provide several "low-level" backends, aiming to seek inspiration from projects such as [tinygrad](https://github.com/tinygrad/tinygrad), [TVM](https://github.com/apache/tvm), [Luminal](https://github.com/jafioti/luminal).
10
10
* OCANNL starts with a high-level representation, but can compile everything down to `for` loops.
11
11
* The library users can compile any amount of code into a routine (i.e. a compilation unit). The user decides explicitly what the scope of a compilation unit is, by putting together the corresponding code. Depending on the use case:
12
12
* the whole training update step can be a single routine,
13
13
* or the step can be composed of a gradient update routine (a forward pass and a backprop pass) and a params update routine (e.g. SGD with momentum, ADAM, etc.),
14
14
* or the user can compile parts of a model separately, manually composing the corresponding forward pass code and the backprop code.
15
15
* Tensor axes are split into kinds: batch, input and output. Tensor dimensions have optional labels.
16
-
* The labels ensure a more precise semantics for dimension matching.
17
-
* In the future we might introduce axis labels as an alternative to positional axis selection, it would be a separate naming mechanism.
18
-
* OCANNL has full support for the `einsum` notation, integrated with shape inference. Supports static indexing, with a built-in operation to take a slice of the batch axes, integrated with shape inference. Extensible to more static indexing patterns as needs arise.
16
+
* The labels ensure a more precise semantics for dimension matching, alternative name: dimension units. It's **not** an axis selection mechanism.
17
+
* OCANNL has full support for a significantly extended `einsum` notation, integrated with shape inference. Supports static indexing, with a built-in operation to take a slice of the batch axes, integrated with shape inference. Extensible to more static indexing patterns as needs arise.
19
18
* OCANNL does not have dynamic indexing (using the last axis of one tensor as indices into another tensor). If it's needed, it can be added (we had a prototype once, removed to reduce complexity). Then it would also be integrated with shape inference.
20
-
* OCANNL has a suite of tutorials doubling as tests with inline expectations.
21
19
* OCANNL offers two main levels of abstraction.
22
-
*Differentiable computations, centered around the [`%op`](lib/ppx_op.ml) syntax extension.
20
+
*Tensor expressions as differentiable computations, centered around the [`%op`](lib/ppx_op.ml) syntax extension.
23
21
*`%op` stands for "operation", it's meant to express tensors: `Tensor.t`, and tensor functions.
24
22
* Plain computations, centered around the [`%cd`](lib/ppx_cd.ml) syntax extension. It integrates the `arrayjit` backend library with shape inference.
25
23
*`%cd` stands for "code", it's meant to express assignment computations: `Assignments.comp`.
26
-
*The support for mixed-precision computations is upcoming.
24
+
*Fully supports mixed-precision computations, with bidirectional precision inference.
27
25
* E.g. higher-precision network components, or gradients at a higher precision than values.
28
-
* Currently (v0.3), you can select the precision, and individual computation nodes track their precision, but mixing precisions might break things.
29
26
* Should be easily extensible.
30
27
* Model surgery should be starightforward (not sure if we are there yet).
31
-
* It's a feature, not a bug!
32
-
* To scale a tensor by a number, always use pointwise-multiplication, e.g. `2*.m` or `m*.2`.
33
-
* Matrix-multiplying a tensor `m` by a constant number, e.g. `m*2`, broadcasts the number to the shape of the input axes of the tensor. This results in an output-axes-only tensor (multi-axis-vector) that is the scaled sum over the input axes of the tensor `m`.
34
-
* Matrix-multiplying a constant number by a tensor `m`, e.g. `2*m`, broadcasts the number to the shape of the output axes of the tensor. This results in a tensor whose inputs are of the same shape as the inputs of `m`, and the output shape is 1D (scalar), that is the scaled sum over the output axes of the tensor `m`.
35
-
* The matrix-multiply operation behaves pointwise along the batch axes.
36
28
37
29
## Usage
38
30
@@ -43,11 +35,11 @@ The CUDA backend requires at least CUDA version 12.8. The Metal backend requires
4. Read the syntax extensions documentation [docs/syntax_extensions.md](docs/syntax_extensions.md).
49
-
5. Read the introductory part of the shape inference documentation [docs/shape_inference.md](docs/shape_inference.md).
50
-
6. Read the NN building blocks file [lib/nn_blocks.ml](lib/nn_blocks.ml).
41
+
5. Read the NN building blocks file [lib/nn_blocks.ml](lib/nn_blocks.ml).
42
+
6. Read the introductory part of the shape inference documentation [docs/shape_inference.md](docs/shape_inference.md).
51
43
7. Skim the configuration documentation [ocannl_config.example](ocannl_config.example).
52
44
8. Improve your understanding by reading or skimming: [lib/shape.mli](lib/shape.mli), [lib/tensor.mli](lib/tensor.mli), [lib/operation.ml](lib/operation.ml), [arrayjit/lib/backend_intf.ml](arrayjit/lib/backend_intf.ml), [lib/train.ml](lib/train.ml).
0 commit comments