materialize
Materializes this tensor view into a standalone tensor using the default strategy.
This method creates a new tensor that contains a copy of all data from the view, making it independent of the parent tensor. The default strategy uses immediate copying (CopyMaterializationStrategy) which provides predictable performance and memory usage characteristics.
Usage Examples
val parentTensor = tensorOf(shape = Shape(4, 4)) { /* initialization */}
val view = parentTensor.sliceView { range(1, 3) }
val materialized = view.materialize() // Independent copy of the view dataMaterialization Benefits
Independence: Result tensor has no dependency on parent tensor
Performance: Direct memory access without coordinate transformation
Compatibility: Works with all tensor operations and external libraries
Memory Management: Allows parent tensor to be garbage collected
Return
a new Tensor containing a materialized copy of this view's data
Parameters
the data type constraint extending DType
the actual value type that will be stored and accessed
Throws
if the view cannot be materialized
Materializes this tensor view using a specific materialization strategy.
This method allows explicit control over the materialization process by selecting a specific strategy. Different strategies provide different trade-offs between memory usage, performance, and access patterns.
Available Strategies
CopyMaterializationStrategy: Immediate copying with full memory allocation
LazyMaterializationStrategy: Deferred copying with sparse element caching
Usage Examples
val view = parentTensor.sliceView { /* slicing definition */}
// Use lazy materialization for sparse access patterns
val lazy = view.materialize(LazyMaterializationStrategy())
// Use copy materialization for frequent access
val copy = view.materialize(CopyMaterializationStrategy())Return
a new Tensor created using the specified materialization strategy
Parameters
the data type constraint extending DType
the actual value type that will be stored and accessed
the MaterializationStrategy to use for materialization
Throws
if the strategy cannot materialize this view