docsapi referencedarkforest-core-tensor-flatten
API Referencecrate: darkforest-coresince v0.1.0-alpha

flatten

Flattens a range of contiguous dimensions into a single axis.

flatten

darkforest-core module: tensor since v0.1.0-alpha

Signature

rust
pub fn flatten<T: Element, D: Device>(t: &Tensor<T, D>, start_dim: usize, end_dim: isize) -> Tensor<T, D>

Overview

Flattens a range of contiguous dimensions into a single axis.

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 flatten
let _res = darkforest_core::tensor::flatten();

Related Components