Skip to main content

SymDim

Enum SymDim 

Source
pub enum SymDim {
    Fixed(usize),
    Symbolic(String),
    Dynamic,
}
Expand description

A dimension that can be concrete, symbolic, or fully dynamic.

This is the runtime-level counterpart to the IR’s Dim enum, but designed for use with actual tensor operations and shape validation.

Variants§

§

Fixed(usize)

Known at compile time: 768, 50257, etc.

§

Symbolic(String)

Named symbolic dimension: “Batch”, “SeqLen”, “HiddenDim” Resolved to a concrete value at runtime via ShapeEnv.

§

Dynamic

Fully dynamic — matches any concrete value. Used when a dimension is truly unknown until runtime.

Implementations§

Source§

impl SymDim

Source

pub fn fixed(n: usize) -> Self

Create a fixed dimension.

Source

pub fn symbolic(name: impl Into<String>) -> Self

Create a named symbolic dimension.

Source

pub fn dynamic() -> Self

Create a dynamic (wildcard) dimension.

Source

pub fn is_fixed(&self) -> bool

Is this a concrete (fixed) dimension?

Source

pub fn is_symbolic(&self) -> bool

Is this a symbolic (named) dimension?

Source

pub fn is_dynamic(&self) -> bool

Is this fully dynamic?

Source

pub fn resolve(&self, env: &ShapeEnv) -> Option<usize>

Try to resolve this dimension to a concrete value.

  • Fixed: returns the value directly
  • Symbolic: looks up the name in the environment
  • Dynamic: returns None (cannot resolve without a concrete value)
Source

pub fn matches(&self, value: usize, env: &ShapeEnv) -> bool

Check if a concrete value matches this dimension pattern.

  • Fixed(n): value must equal n
  • Symbolic: checks env if bound, otherwise matches any value
  • Dynamic: matches any value
Source

pub fn unify(&self, value: usize, env: &mut ShapeEnv) -> bool

Try to unify this dimension with a concrete value, potentially binding a symbolic name in the environment.

Returns true if unification succeeds.

Trait Implementations§

Source§

impl Clone for SymDim

Source§

fn clone(&self) -> SymDim

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SymDim

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for SymDim

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<&str> for SymDim

Source§

fn from(s: &str) -> Self

Converts to this type from the input type.
Source§

impl From<usize> for SymDim

Source§

fn from(n: usize) -> Self

Converts to this type from the input type.
Source§

impl Hash for SymDim

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for SymDim

Source§

fn eq(&self, other: &SymDim) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for SymDim

Source§

impl StructuralPartialEq for SymDim

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.