pub struct InputShape {
pub batch: Dim,
pub channels: Dim,
pub height: Dim,
pub width: Dim,
}Expand description
Input shape specification for an ONNX model.
Represents [batch, channels, height, width] with support for dynamic dimensions.
Fields§
§batch: DimBatch dimension
channels: DimChannel dimension
height: DimHeight dimension
width: DimWidth dimension
Implementations§
Source§impl InputShape
impl InputShape
Sourcepub fn new(batch: Dim, channels: Dim, height: Dim, width: Dim) -> InputShape
pub fn new(batch: Dim, channels: Dim, height: Dim, width: Dim) -> InputShape
Creates a new input shape from individual dimensions.
Sourcepub fn from_array(shape: [i64; 4]) -> InputShape
pub fn from_array(shape: [i64; 4]) -> InputShape
Creates an input shape from an array of i64 values. Values <= 0 are treated as dynamic dimensions.
Sourcepub fn fixed(batch: i64, channels: i64, height: i64, width: i64) -> InputShape
pub fn fixed(batch: i64, channels: i64, height: i64, width: i64) -> InputShape
Creates a fully fixed input shape.
Sourcepub fn dynamic_batch(channels: i64, height: i64, width: i64) -> InputShape
pub fn dynamic_batch(channels: i64, height: i64, width: i64) -> InputShape
Creates a shape with dynamic batch and fixed spatial dimensions.
Common pattern: [-1, 3, H, W]
Sourcepub fn dynamic_spatial(batch: i64, channels: i64) -> InputShape
pub fn dynamic_spatial(batch: i64, channels: i64) -> InputShape
Creates a shape with fixed batch/channels and dynamic spatial dimensions.
Common pattern: [1, 3, -1, -1]
Sourcepub fn fully_dynamic() -> InputShape
pub fn fully_dynamic() -> InputShape
Creates a fully dynamic shape: [-1, -1, -1, -1]
Sourcepub fn spatial_size_or(&self, default_h: u32, default_w: u32) -> (u32, u32)
pub fn spatial_size_or(&self, default_h: u32, default_w: u32) -> (u32, u32)
Returns the spatial dimensions as (height, width) with defaults for dynamic dims.
Sourcepub fn has_fixed_spatial(&self) -> bool
pub fn has_fixed_spatial(&self) -> bool
Returns whether the spatial dimensions (height, width) are fixed.
Sourcepub fn has_dynamic(&self) -> bool
pub fn has_dynamic(&self) -> bool
Returns whether any dimension is dynamic.
Sourcepub fn from_onnx_dims(dims: &[i64]) -> Option<InputShape>
pub fn from_onnx_dims(dims: &[i64]) -> Option<InputShape>
Parses input shape from ONNX model input dimensions.
Handles various dimension representations:
- Positive values: fixed dimensions
- Negative values or 0: dynamic dimensions
§Arguments
dims- Dimensions from ONNX model (typically 4 elements: [batch, channels, height, width])
§Returns
Some(InputShape)if dims has exactly 4 elementsNoneif dims has wrong number of elements
Trait Implementations§
Source§impl Clone for InputShape
impl Clone for InputShape
Source§fn clone(&self) -> InputShape
fn clone(&self) -> InputShape
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for InputShape
impl Debug for InputShape
Source§impl Default for InputShape
impl Default for InputShape
Source§fn default() -> InputShape
fn default() -> InputShape
Source§impl Display for InputShape
impl Display for InputShape
Source§impl PartialEq for InputShape
impl PartialEq for InputShape
impl Eq for InputShape
impl StructuralPartialEq for InputShape
Auto Trait Implementations§
impl Freeze for InputShape
impl RefUnwindSafe for InputShape
impl Send for InputShape
impl Sync for InputShape
impl Unpin for InputShape
impl UnwindSafe for InputShape
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<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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more