Public Tensor Constructors #
This module owns the TorchLean.Tensor construction surface: literals, flat-index generation,
and bounded-index constructors. The constant constructors full, zeros, and ones live with the
specification-layer constructors so that spec code can use them too. Import NN.Tensor for the
complete public tensor API.
NN.Spec.Core.FloatInstances supplies FloatLib's configured binary scalar types and their
TorchLean contexts, so the same constructors accept both native and configured precisions.
Lift an integer literal into a rank-zero tensor.
The expected tensor type fixes both the scalar representation and the empty
shape, so users can write 1 : Tensor α [] without an explicit constructor.
Lift a decimal or scientific literal into a rank-zero tensor.
This is representation-polymorphic: any executable or proof-oriented scalar
type with OfScientific receives the same ordinary literal syntax.
Construct a tensor by running one action per row-major coordinate, in increasing flat order.
The result retains the requested shape. A failed action stops construction according to the supplied monad.
Instances For
Run one action per leading slice and stack its result, preserving the common trailing shape.
Instances For
Effectful right-to-left scan, with one output per input entry.
The terminal accumulator is excluded. Effects run from the last input to the first; an error stops the scan according to the supplied monad.
Instances For
Take a fixed-width tensor window, padding entries past the end.
offset and length determine the result without exposing bounded-index construction. This is the
general in-memory constructor used by token, byte, and minibatch window helpers.