#[non_exhaustive]pub struct TensorRef {
pub name: Ident,
pub dtype: DataType,
pub shape: Arc<[u32]>,
}Expand description
A named, typed, shaped buffer argument passed into a Cat-A op.
Construct with TensorRef::new or the convenience helpers
(u32_1d, f32_1d, u32_2d, f32_2d). Downstream ops consume
TensorRefs instead of raw &str buffer names so type + shape
checks happen at build() time.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.name: IdentName the buffer is registered under. Matches BufferDecl::name.
dtype: DataTypeElement dtype. Enforced against each op’s expected dtype set.
shape: Arc<[u32]>Logical shape in elements (not bytes). An empty vec is a scalar; a 2-element vec is a matrix; etc. Used for shape-mismatch detection at build-time.
Implementations§
Source§impl TensorRef
impl TensorRef
Sourcepub fn new(name: impl Into<Ident>, dtype: DataType, shape: Vec<u32>) -> Self
pub fn new(name: impl Into<Ident>, dtype: DataType, shape: Vec<u32>) -> Self
Construct an explicit TensorRef. Callers prefer the shape
helpers below unless their shape is computed.
Sourcepub fn u32_1d(name: impl Into<Ident>, len: u32) -> Self
pub fn u32_1d(name: impl Into<Ident>, len: u32) -> Self
U32 1-D tensor convenience constructor.
Sourcepub fn f32_1d(name: impl Into<Ident>, len: u32) -> Self
pub fn f32_1d(name: impl Into<Ident>, len: u32) -> Self
F32 1-D tensor convenience constructor.
Sourcepub fn u32_2d(name: impl Into<Ident>, rows: u32, cols: u32) -> Self
pub fn u32_2d(name: impl Into<Ident>, rows: u32, cols: u32) -> Self
U32 2-D tensor convenience constructor (rows × cols).
Sourcepub fn f16_1d(name: impl Into<Ident>, len: u32) -> Self
pub fn f16_1d(name: impl Into<Ident>, len: u32) -> Self
F16 1-D tensor convenience constructor.
Sourcepub fn f16_2d(name: impl Into<Ident>, rows: u32, cols: u32) -> Self
pub fn f16_2d(name: impl Into<Ident>, rows: u32, cols: u32) -> Self
F16 2-D tensor convenience constructor (rows × cols).
Sourcepub fn f32_2d(name: impl Into<Ident>, rows: u32, cols: u32) -> Self
pub fn f32_2d(name: impl Into<Ident>, rows: u32, cols: u32) -> Self
F32 2-D tensor convenience constructor (rows × cols).
Sourcepub fn element_count(&self) -> Option<u32>
pub fn element_count(&self) -> Option<u32>
Total element count. Returns None on overflow so builders
can surface a structured error rather than silent wraparound.
Trait Implementations§
impl Eq for TensorRef
impl StructuralPartialEq for TensorRef
Auto Trait Implementations§
impl Freeze for TensorRef
impl RefUnwindSafe for TensorRef
impl Send for TensorRef
impl Sync for TensorRef
impl Unpin for TensorRef
impl UnsafeUnpin for TensorRef
impl UnwindSafe for TensorRef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more