PyTorch Round-Trip Driver #
This module assembles the state-dict round-trip examples.
It does not re-implement model math. Instead it wires together:
- PyTorch exporters (
MLP/Export,CNN/Export,Transformer/Export) - typed PyTorch JSON importers (
MLP/Import,CNN/Import,Transformer/Import) - native tensor operations for the MLP forward pass
- public executable
nnmodules for the CNN and Transformer forward passes
Run via the TorchLean example runner:
scripts/lake.sh exe torchlean pytorch_roundtrip --model mlp --action import
Choose mlp, cnn, or transformer for --model, and export or import for --action.
Design goals:
- keep paths/dimensions centralized (no duplicated constants across examples),
- keep the example output deterministic and readable,
- keep this example import-safe (no root-level
mainthat collides with other executables).
CLI model/action selection #
Paths and fixed example dimensions #
Small IO helpers #
Export actions #
Import actions #
Load the MLP JSON fixture and evaluate [0.5, 0.8] with native Float tensor operations.
Instances For
Load the CNN JSON fixture and evaluate the row-major input 1..64 on CPU with scalar Float.
Instances For
Load the encoder JSON fixture and evaluate the token [[1.5, 1.5]] on CPU with scalar Float.