TensorStorage

data class TensorStorage(val shape: Shape, val logicalType: LogicalDType, val encoding: TensorEncoding, val buffer: BufferHandle, val placement: Placement = Placement.CPU_HEAP, val byteOffset: Long = 0, val strides: LongArray? = null, val isContiguous: Boolean = true)(source)

Runtime descriptor for a tensor's backing memory.

TensorStorage is the main architectural type that replaces ad-hoc array passing between loaders, planners, and backends. It carries enough information to handle a tensor without inspecting its bytes:

Existing sk.ainet.lang.tensor.data.TensorData remains as a compatibility façade. New loaders, planners, and backends should target TensorStorage directly.

Constructors

Link copied to clipboard
constructor(shape: Shape, logicalType: LogicalDType, encoding: TensorEncoding, buffer: BufferHandle, placement: Placement = Placement.CPU_HEAP, byteOffset: Long = 0, strides: LongArray? = null, isContiguous: Boolean = true)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Number of logical elements in this tensor.

Link copied to clipboard
Link copied to clipboard

Whether this storage is an alias (view) into another buffer.

Link copied to clipboard
Link copied to clipboard

Whether this storage is backed by a memory-mapped file.

Link copied to clipboard

Whether this storage is mutable.

Link copied to clipboard

Logical size: number of elements x logical element size.

Link copied to clipboard
Link copied to clipboard

Ownership mode of the backing buffer.

Link copied to clipboard

Physical size: actual bytes consumed in the buffer for this tensor.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Create a new TensorStorage with an owned copy of this storage's data. The returned storage is independent of the original buffer.

Link copied to clipboard

Request a copy of this storage on the specified device. Currently only CPU is supported — GPU/NPU backends will override.

Link copied to clipboard

Ensure this storage resides on the host (CPU heap). If already on host, returns this. Otherwise copies to host.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Memory report for this single tensor, useful for diagnostics and regression testing.

Link copied to clipboard
fun repackTo(targetEncoding: TensorEncoding): TensorStorage

Re-encode this storage into a different physical encoding. Currently a stub — actual transcoding requires backend kernels.