TensorView
darkforest-core
module: tensor
since v0.1.0-alpha
Signature
rust
pub struct TensorView<'a, T: Element, D: Device> { base: &'a Tensor<T, D>, view_shape: Shape, view_strides: Strides, offset: usize }
Overview
A non-owning zero-copy view into an existing Tensor. Provides specialized slicing, broadcast, and permute operations without heap allocation.
Invariants & Design Principles
- Invariant: Borrows base storage immutably.
- Invariant: View operations do not trigger autograd tape recording unless evaluated.
Usage Example
rust
let view = t.view_slice(&[0..10, 0..10]);