IR axis operations #
Evaluate axis operations with the IR semantics.
This tutorial constructs and evaluates three IR operations with an explicit axis:
softmax axis(PyTorch:torch.softmax(x, dim=axis))concat axis(PyTorch:torch.cat(xs, dim=axis))layernorm axisPyTorch:F.layer_norm(x, normalized_shape=x.shape[axis:])
The axis is part of each operation's meaning. The evaluator checks graph and input shapes, then
computes the selected output with the IR semantics, in Lean tensor operations. This example does not
dispatch to LibTorch or select a GPU device; --arithmetic chooses the scalar implementation.
Run:
scripts/lake.sh exe torchlean ir_axis_ops --arithmetic ieee
Command-line help for the IR axis-ops tutorial.
Instances For
Small IR Graphs #
Softmax along a chosen axis of the example's [2, 3, 4] input.
Instances For
LayerNorm over the suffix starting at axis. The default normalizes [3, 4] together, rather
than just the final dimension.
Instances For
Join [2, 3, 4] and [2, 5, 4] along axis one. Other axis choices demonstrate shape rejection:
the remaining dimensions must agree and the declared output must match the inferred shape.
Instances For
Runner Helpers #
Print a compact preview of a tensor.
Instances For
Evaluate an example graph with Lean tensor operations 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.