TorchLean API

NN.Spec.Quantization

Tensor Quantization #

This module lifts the scalar affine quantizer from NN.Floats.Quantization pointwise over TorchLean's shape-indexed tensors. The numerical definition remains usable without importing the tensor library; only this adapter depends on NN.Spec.

Apply the affine quantizer independently at every coordinate of an arbitrary-rank tensor.

Instances For

    Reconstruct every code in an arbitrary-rank tensor on the quantizer's real grid.

    Instances For

      Pointwise condition saying that quantization does not clip any coordinate of x.

      Instances For

        Pointwise condition saying that every stored code belongs to the quantizer's code set.

        Instances For

          Every coordinate produced by tensor quantization lies in the declared code interval.

          theorem TorchLean.Floats.Quantization.AffineQuantizer.quantizeTensor_mono (q : AffineQuantizer) (rnd : ) [NeuralValidRnd rnd] {s : Spec.Shape} {x y : Spec.Tensor s} (hxy : Spec.Tensor.Forall (fun (ab : × ) => ab.1 ab.2) (Spec.zip x y)) :
          Spec.Tensor.Forall (fun (ab : × ) => ab.1 ab.2) (Spec.zip (q.quantizeTensor rnd x) (q.quantizeTensor rnd y))

          Pointwise order is preserved by tensor quantization.

          An in-range code tensor survives pointwise dequantization and requantization exactly.

          If no coordinate clips, every tensor reconstruction error is at most half a step.