TorchLean API

NN.IR.Interpreter

Heterogeneous graph interpretation #

An interpreter supplies a scalar family indexed by DType, its storage, available arithmetic, and explicit conversions. Values still contain ordinary TorchLean tensors. Shape erasure reuses Spec.SomeTensor; only the element-type index is added at the interchange boundary.

Ordinary numeric nodes reuse Graph.evalNodeRaw. Typed casts and registered custom operations are dispatched separately, with the result's scalar type fixed by the program's type assignment. Unsupported types and operations return errors. No cast is implemented by relabeling a tensor or converting through host Float. Layout operations reuse Graph.evalTransform and need only storage, not arithmetic. Pointwise operators reuse Graph.evalPointwise, which also needs only storage: a type with an arithmetic dictionary takes their meanings from Spec.PointwiseOp.meaning, and a type without one, such as an integer type, from the interpreter's own pointwise table.

structure NN.IR.Interpreter :

Scalar representations and operations supplied to the shared typed graph interpreter.

Instances For
    structure NN.IR.Interpreter.Value (interpreter : Interpreter) :

    A tensor with both its element descriptor and its shape preserved.

    Instances For
      def NN.IR.Interpreter.Value.shape {interpreter : Interpreter} (value : interpreter.Value) :

      Runtime shape retained by the shared tensor package.

      Instances For
        def NN.IR.Interpreter.Value.get {interpreter : Interpreter} (value : interpreter.Value) (dtype : DType) :
        Except String (Spec.SomeTensor (interpreter.Scalar dtype))

        Recover a tensor only after checking its element-type index.

        Instances For
          structure NN.IR.Interpreter.Payload (interpreter : Interpreter) :

          Typed constants, existing homogeneous parameter stores, and extension implementations.

          Instances For

            Convert a tensor element by element, accumulating FloatLib's conversion flags.

            Instances For
              def NN.IR.Interpreter.evalNode (interpreter : Interpreter) (program : Program) (payload : interpreter.Payload) (arguments values : Array interpreter.Value) (node : Node) :

              Evaluate one node using already computed values and a complete argument table.

              Instances For
                def NN.IR.Interpreter.run (interpreter : Interpreter) (program : Program) (payload : interpreter.Payload) (arguments : Array interpreter.Value) :

                Evaluate a typed program, returning every intermediate tensor and accumulated cast flags.

                Instances For
                  def NN.IR.Interpreter.eval (interpreter : Interpreter) (program : Program) (payload : interpreter.Payload) (arguments : Array interpreter.Value) :

                  Evaluate the designated results in return order, retaining conversion flags.

                  Instances For