reshape
darkforest-core
module: tensor
since v0.1.0-alpha
Signature
rust
pub fn reshape<T: Element, D: Device>(t: &Tensor<T, D>, new_shape: &[usize]) -> Result<Tensor<T, D>, OpError>
Overview
Reshapes tensor shape. Returns zero-copy view if contiguous, or new copy if non-contiguous.
Invariants & Design Principles
- Invariant: Adheres strictly to Dark Forest 64-byte alignment and strided memory invariants.
- Invariant: Verified via unit tests, Miri memory model, and PyTorch cross-checks.
Usage Example
rust
// Example calling reshape
let _res = darkforest_core::tensor::reshape();