Uses R's bigmemory or base file I/O for storage and provides a torch tensor
interface for seamless integration. This enables storing tensors larger than
available RAM by using disk space.
Value
A DiskTensor object.
Note
R6 doesn't support [ overloading directly; use $get() instead.
Methods
flush()
Flush changes to disk
Methods
DiskTensor$new()
Usage
DiskTensor$new(shape, dtype, path, cleanup = TRUE)
Arguments
shape
Integer vector. Shape of the tensor.
dtype
torch.dtype. Data type.
path
Character. File path.
cleanup
Logical. Auto-cleanup on GC.
DiskTensor$get()
Arguments
indices
List of indices or slices.
DiskTensor$set()
Usage
DiskTensor$set(indices, value)
Arguments
indices
List of indices.
value
Tensor. Value to write.
DiskTensor$flush()
Returns
Invisible flush to disk
DiskTensor$nbytes()
Returns
Integer. Size in bytes.
DiskTensor$clone()
The objects of this class are cloneable with this method.
Usage
DiskTensor$clone(deep = FALSE)
Arguments
deep
Whether to make a deep clone.
Examples
if (FALSE) { # \dontrun{
# Create a disk-backed tensor
dt <- disk_tensor$new(c(1000L, 128L), torch_float(), "/tmp/my_tensor.mmap")
# Write data (automatically persists to disk)
dt[1:100, ..] <- torch_randn(100L, 128L)
# Read data
x <- dt[1:50, ..]$tensor
# Flush changes to disk
dt$flush()
} # }