Skip to main content

Module lens

Module lens 

Source
Expand description

Tensor<T> as a typed lens over [TensorDyn].

TensorDyn is the main type — the one every FFI surface (C, Python, and any future binding) calls Tensor. Rust code that needs the element type known at compile time opens a lens onto it with [TensorDyn::as_typed]/[TensorDyn::as_typed_mut] instead of matching a constructor; Tensor<T> itself owns no storage of its own to lose — it borrows the handle’s.

Rust-only. The lens exists because Rust can express “this handle’s element type is f32” as a static fact; C and Python have no such concept and always operate on the erased TensorDyn directly. Both backends implement as_typed/ as_typed_mut – static_lens below for the enum-of-Tensor<T> backend, dynamic_lens for the opaque-handle one – with different validity arguments for the same cast; see each module’s docs.

Traits§

Element
An element type a Tensor<T> lens may be opened for.