MaterializationStrategy

Strategy interface for materializing tensor views into concrete tensors.

Materialization is the process of converting a tensor view (which references data from a parent tensor through coordinate transformations) into a standalone tensor with its own data storage. Different strategies provide different trade-offs between memory usage, computation time, and access patterns.

Strategy Patterns

  • Immediate Materialization: Creates a copy of the view data immediately

  • Lazy Materialization: Defers copying until the data is actually accessed

  • Reference Materialization: Maintains references while optimizing access

  • Batch Materialization: Optimizes for materializing multiple views together

Usage Context

Materialization strategies are particularly important for:

  • Performance optimization when views are accessed frequently

  • Memory management when parent tensors can be garbage collected

  • Computational efficiency when the view will be used in multiple operations

  • Interoperability when passing tensors between different computational backends

Parameters

T

the data type constraint extending DType

V

the actual value type that will be stored and accessed

Inheritors

Properties

Link copied to clipboard
abstract val name: String

Gets a human-readable name for this materialization strategy.

Functions

Link copied to clipboard
abstract fun canMaterialize(view: TensorView<T, V>): Boolean

Checks if this strategy can materialize the given view.

Link copied to clipboard
abstract fun estimateMemoryOverhead(view: TensorView<T, V>): Long

Estimates the memory overhead of materializing the given view.

Link copied to clipboard
abstract fun materialize(view: TensorView<T, V>): Tensor<T, V>

Materializes the given tensor view into a concrete tensor.