MmapTensorSource

A handle to a memory-mapped file region that can provide tensor views.

This class manages the lifecycle of a memory-mapped file and provides methods to create tensor views into specific regions of the mapped data.

Usage:

val mmap = MmapTensorSource.fromFile(file)
val tensor1 = mmap.tensorAt<FP32>(offset1, shape1)
val tensor2 = mmap.tensorAt<FP32>(offset2, shape2)
// tensors share the same underlying memory-mapped region
mmap.close() // release when done

Parameters

mappedBuffer

the memory-mapped buffer for the entire file or region

Constructors

Link copied to clipboard
constructor(mappedBuffer: MappedByteBuffer)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
fun <T : DType> floatTensorAt(byteOffset: Long, shape: Shape): MmapFloatTensorData<T>

Creates a tensor data view at the specified byte offset.

Link copied to clipboard

Check if the mapped memory is resident in physical memory.

Link copied to clipboard

Force the mapped memory to be loaded into physical memory. This can improve first-access performance but uses more memory.