TorchLean API

NN.Widgets.Core.Tensor

Tensor #

Tensor inspection widgets for the Lean infoview.

Import NN.Widgets or NN.Widgets.Core.Tensor to inspect values through ProofWidgets' #html command. Previews read bounded prefixes and leading slices; the statistics panel scans the whole tensor. Rendering a value does not prove a property of it.

Main definitions #

Element renderer for #tensor_view. The default uses ToString; specialized instances can add tooltips, units, or compact formatting.

Instances
    @[instance_reducible]

    Default element renderer for #tensor_view, using ToString.

    Read only the requested prefix, without converting the full backing buffer.

    Instances For

      Render a 1D tensor as a clipped single-row table.

      Instances For

        Render a 2D tensor as a clipped grid table.

        Instances For

          First maxElems entries of a tensor in row-major order, with a marker when there are more.

          Truncating matters here: a widget that tried to print a full tensor would hang the editor on anything of realistic size.

          Instances For
            def NN.Widgets.tensorHtml {α : Type} [TorchLean.Storage α] [ToString α] [TensorElemView α] {s : Spec.Shape} (t : TorchLean.Tensor α s) (maxRows maxCols : ℕ := 16) (maxElems : ℕ := 64) :

            Render a tensor as HTML.

            Vectors and matrices use clipped tables. Higher-rank tensors show bounded leading slices, with a flat preview when the recursion depth is exhausted.

            Instances For

              Runtime Wrappers #

              def NN.Widgets.packedTensorHtml {α : Type} [TorchLean.Storage α] [ToString α] [TensorElemView α] (v : Spec.SomeTensor α) (maxRows maxCols : ℕ := 16) (maxElems : ℕ := 64) :

              Render a Spec.SomeTensor with the same UI as tensorHtml.

              Instances For

                Stats #

                #tensor_stats_view t computes extrema, mean, and norms using the scalar's Context operations. Unlike the clipped previews, it materializes and scans every entry.

                Numeric summary panel: shape, size, extrema, mean, and the three usual norms.

                Instances For

                  Render extrema, mean, and norms, scanning every entry with the scalar's arithmetic.

                  Instances For

                    Commands #