storage #
vtl.storage
Storage backends used by VTL tensors. CPU storage is the default general-purpose path; optional CUDA, Vulkan, and VCL implementations are selected through V compile-time defines and are not interchangeable in availability or maturity.
Most applications should use vtl.Tensor[T] and its creation/manipulation functions instead of constructing storage directly. The backend modules expose lower-level allocation and access primitives for library and backend work.
CPU storage constructors from arrays copy their input; clone creates an independent buffer, while offset refers to a range in the existing storage. At tensor level, view, slice, and stride-only transforms can share backing storage when no layout conversion is needed; copy explicitly allocates independent data. Treat mutations through a view as mutations of shared data, and check whether an operation materializes a new layout before relying on zero-copy behavior. This is a CPU tensor contract, not a promise that each accelerator backend implements identical aliasing.
CPU is the default backend. CUDA and VCL expose backend-specific storage behind compile flags; Vulkan has an implemented conditional backend and a no-backend fallback. These accelerator paths have different allocation, synchronization, transfer, and lifetime constraints and remain experimental. See device memory notes before using them.
Constants #
const vector_minimum_capacity = 2
vector_minimum_capacity is a public constant used by this module.
const vector_growth_factor = 2
vector_growth_factor is a public constant used by this module.
const vector_shrink_threshold = 1.0 / 4.0
vector_shrink_threshold is a public constant used by this module.
fn from_array #
fn from_array[T](arr []T) &CpuStorage[T]
from_array exposes this operation as part of the public API.
fn storage #
fn storage[T](len int, cap int, init T) &CpuStorage[T]
storage exposes this operation as part of the public API.
fn (CpuStorage[T]) get #
fn (s &CpuStorage[T]) get[T](i int) T
get exposes this operation as part of the public API.
fn (CpuStorage[T]) set #
fn (mut s CpuStorage[T]) set[T](i int, val T)
set exposes this operation as part of the public API.
fn (CpuStorage[T]) fill #
fn (mut s CpuStorage[T]) fill[T](val T)
fill fills an entire storage with a given value
fn (CpuStorage[T]) clone #
fn (s &CpuStorage[T]) clone[T]() &CpuStorage[T]
clone exposes this operation as part of the public API.
fn (CpuStorage[T]) like #
fn (s &CpuStorage[T]) like[T]() &CpuStorage[T]
like exposes this operation as part of the public API.
fn (CpuStorage[T]) like_with_len #
fn (s &CpuStorage[T]) like_with_len[T](len int) &CpuStorage[T]
like_with_len exposes this operation as part of the public API.
fn (CpuStorage[T]) offset #
fn (s &CpuStorage[T]) offset[T](start int) &CpuStorage[T]
offset exposes this operation as part of the public API.
fn (CpuStorage[T]) to_array #
fn (s &CpuStorage[T]) to_array[T]() []T
to_array exposes this operation as part of the public API.
fn (CpuStorage[T]) cuda #
fn (cpu &CpuStorage[T]) cuda(params CudaParams) !&CpuStorage[T]
cuda returns an error when CUDA is not enabled at compile time
fn (CpuStorage[T]) vulkan #
fn (cpu &CpuStorage[T]) vulkan(params VulkanParams) !&CpuStorage[T]
vulkan exposes this operation as part of the public API.
struct CpuStorage #
struct CpuStorage[T] {
pub mut:
data []T
}
CpuStorage defines a public data structure for this module.
struct CudaParams #
struct CudaParams {
device_id int
stream voidptr = unsafe { nil }
}
CudaParams defines a public data structure for this module.
struct VulkanParams #
struct VulkanParams {}
VulkanParams defines a public data structure for this module.