TorchLean API

NN.Examples.DeepDives.IRAxisOps

IR axis operations #

IR axis-ops runtime tutorial.

This tutorial constructs and evaluates three IR operations with an explicit axis:

Each operation accepts any in-bounds tensor dimension. The implementation may move that dimension to an innermost position while evaluating an optimized kernel, but its public semantics preserves the original shape and dimension numbering. Forward graph execution reports unsupported backend cases explicitly.

Run:

lake exe torchlean ir_axis_ops --execution eager

Command-line help for the IR axis-ops tutorial.

Instances For

    Tensor Shapes #

    These shapes illustrate an axis that is neither first nor last.

    @[reducible, inline]
    Instances For

      Small IR Graphs #

      LayerNorm over axis 1 of a rank-three tensor, the interesting case because the normalized axis is neither the first nor the last.

      Instances For

        Concatenation along axis 1, joining a [2, 3, 4] and a [2, 5, 4] tensor into [2, 8, 4].

        Instances For

          Runner Helpers #

          Print a compact preview of a tensor.

          Instances For
            def NN.Examples.DeepDives.IRAxisOps.printEvaluation {α : Type} {σ : Spec.Shape} [TorchLean.Storage α] [Context α] [ToString α] (tag : String) (g : IR.Graph) (payload : IR.Payload α) (x : TorchLean.Tensor α σ) (outputId : Fin g.nodes.size) :

            Evaluate an example graph through the runtime API and print its selected output.

            Instances For

              Run every axis-op example at scalar type α.

              Generic in α so the tutorial can be run under native Float or under the bit-level IEEE model with no change to the graphs.

              Instances For

                Runtime-selected entrypoint body for the axis-ops tutorial.

                Instances For

                  Entry point; --arithmetic picks the scalar type the whole tutorial runs at.

                  Instances For