TorchLean API

NN.Kernel.Scalar

Exact scalar encodings for custom computations #

Native floats use hardware arithmetic. Configured binary values use their complete interchange words; the device selects compatible native operations or software arithmetic from the format. Wide values are never narrowed through binary64. The packing law concerns Lean values, not the foreign transfer or arithmetic implementation.

def NN.Kernel.Arithmetic.ofOps {α : Type} [Add α] [Sub α] [Mul α] [Div α] [Neg α] [BEq α] [LT α] [LE α] [DecidableLT α] [DecidableLE α] :

Scalar operations in their original evaluation order, without algebraic reassociation.

Instances For

    Arithmetic representation selected by a scalar type, independently of the execution device.

    Instances For
      class NN.Kernel.Scalar (α : Type) :

      Complete unsigned encodings and their lossless reconstruction.

      Instances
        @[instance_reducible]
        @[instance_reducible]

        Byte width of one complete value, padded only to a whole number of bytes.

        Instances For

          Whether the custom GPU arithmetic implementation accepts this complete scalar format. This is a type/format capability check, not a claim that a GPU or enough memory is available.

          Instances For
            def NN.Kernel.Scalar.pack {α : Type} [TorchLean.Storage α] {shape : Spec.Shape} (scalar : Scalar α) (tensor : TorchLean.Tensor α shape) :

            Serialize complete scalar words in row-major little-endian order.

            Instances For
              def NN.Kernel.Scalar.unpack {α : Type} [TorchLean.Storage α] (scalar : Scalar α) (shape : Spec.Shape) (bytes : ByteArray) :

              Decode complete words only after checking the requested shape and byte extent.

              Instances For