pub struct ShapeGuard { /* private fields */ }Expand description
Validates concrete tensor shapes against symbolic patterns.
Useful for checking model inputs at runtime, ensuring shapes are compatible before attempting operations that would fail.
§Examples
ⓘ
let guard = ShapeGuard::new("input")
.expect(SymbolicShape::from(vec![
SymDim::symbolic("Batch"),
SymDim::fixed(784),
]));
// This shape is valid (batch=32, features=784)
guard.validate(&Shape::new(vec![32, 784]), &env)?;
// This would error (wrong feature dim)
guard.validate(&Shape::new(vec![32, 100]), &env); // Error!Implementations§
Source§impl ShapeGuard
impl ShapeGuard
Sourcepub fn new(name: impl Into<String>, pattern: SymbolicShape) -> Self
pub fn new(name: impl Into<String>, pattern: SymbolicShape) -> Self
Create a shape guard with a name and expected pattern.
Trait Implementations§
Source§impl Clone for ShapeGuard
impl Clone for ShapeGuard
Source§fn clone(&self) -> ShapeGuard
fn clone(&self) -> ShapeGuard
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ShapeGuard
impl RefUnwindSafe for ShapeGuard
impl Send for ShapeGuard
impl Sync for ShapeGuard
impl Unpin for ShapeGuard
impl UnsafeUnpin for ShapeGuard
impl UnwindSafe for ShapeGuard
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
Mutably borrows from an owned value. Read more