CopyMaterializationStrategy
A materialization strategy that immediately copies all data from a tensor view into a new, standalone tensor with contiguous memory layout.
This strategy provides immediate materialization by iterating through all elements in the view and copying them to a new tensor with the view's shape. The resulting tensor is completely independent of the parent tensor and can be used even after the parent tensor is garbage collected.
Characteristics
Immediate Execution: Materialization happens synchronously when called
Memory Independent: Result tensor has no dependencies on parent tensor
Contiguous Layout: Output data is stored in standard row-major order
Type Preservation: Maintains the same data type and value type as the view
Trade-offs
Benefits:
Predictable memory usage and performance
No ongoing computational overhead for element access
Enables garbage collection of parent tensors
Compatible with all downstream operations
Costs:
Immediate memory allocation for full tensor size
Computational cost of copying all elements
Temporary memory pressure during materialization
Usage Scenarios
This strategy is optimal when:
The materialized tensor will be accessed frequently
Memory usage is predictable and acceptable
The parent tensor can be released after materialization
Compatibility with external libraries is required
Parameters
the data type constraint extending DType
the actual value type that will be stored and accessed