Mojo struct
ShapeElement
A single dimension of a possibly-dynamic shape.
A shape element can be static or dynamic. If dynamic, it can be named or unnamed. Named dynamic shape elements must match across all inputs of a model.
Implemented traits
AnyType
,
CollectionElement
,
Copyable
,
EqualityComparable
,
Movable
Methods
__init__
__init__(inout self: Self, static: Int)
Create a static shape element with the given static dimension value.
Args:
- static (
Int
): The static size of the dimension.
__init__(inout self: Self, static: SIMD[int64, 1])
Create a static shape element with the given static dimension value.
Args:
- static (
SIMD[int64, 1]
): The static size of the dimension.
__init__(inout self: Self, unnamed: None)
Create an unnamed dynamic shape element.
Args:
- unnamed (
None
): None.
__init__(inout self: Self, unnamed: NoneType)
Create an unnamed dynamic shape element.
Args:
- unnamed (
NoneType
): None.
__init__(inout self: Self, owned name: String)
Create a dynamic shape element with the given name.
Args:
- name (
String
): The name of the dimension, which must be non-empty, consist only of alphanumeric characters and underscores, and must not begin with a digit.
__init__(inout self: Self, name: StringRef)
Create a dynamic shape element with the given name.
Args:
- name (
StringRef
): The name of the dimension, which must be non-empty, consist only of alphanumeric characters and underscores, and must not begin with a digit.
__init__(inout self: Self, name: StringLiteral)
Create a dynamic shape element with the given name.
Args:
- name (
StringLiteral
): The name of the dimension, which must be non-empty, consist only of alphanumeric characters and underscores, and must not begin with a digit.
__copyinit__
__copyinit__(inout self: Self, other: Self)
Create a copy of another ShapeElement.
Args:
- other (
Self
): The ShapeElement to copy from.
__moveinit__
__moveinit__(inout self: Self, owned other: Self)
Initialize from another owned ShapeElement.
Args:
- other (
Self
): The ShapeElement to copy from.
__eq__
__eq__(self: Self, other: Self) -> Bool
Determine if this shape element is equal to another.
Note that this is structural, not necessarily semantic -- two unnamed dynamic shape elements compare as equal, even though in a model such shape elements are not necessarily required to be equal.
Returns: True if shape elements are equal; False otherwise.
Args:
- other (
Self
): ShapeElement to compare to.
__ne__
__ne__(self: Self, other: Self) -> Bool
Determine if this shape element is unequal to another.
Note that this is structural, not necessarily semantic -- two unnamed dynamic shape elements compare as equal, even though in a model such shape elements are not necessarily required to be equal.
Returns: True if shape elements are unequal; False otherwise.
Args:
- other (
Self
): ShapeElement to compare to.
is_static
is_static(self: Self) -> Bool
Whether this shape element is static.
Returns: True if this shape element is static; False otherwise.
is_dynamic
is_dynamic(self: Self) -> Bool
Whether this shape element is a dynamic dimension.
Returns:
True if this shape element is a dynamic dimension; False otherwise.
is_unnamed_dynamic
is_unnamed_dynamic(self: Self) -> Bool
Whether this shape element is an unnamed dynamic dimension.
Returns:
True if this shape element is an unnamed dynamic dimension; False otherwise.
is_named_dynamic
is_named_dynamic(self: Self) -> Bool
Whether this shape element is a named dynamic dimension.
Returns:
True if this shape element is a named dynamic dimension; False otherwise.
static_value
static_value(self: Self) -> SIMD[int64, 1]
Return size of this static shape element.
Returns:
Size of this static shape element, or 0 if not a static shape element.
name
name(self: Self) -> String
Return name of this named dynamic shape element.
Returns:
Name of this named dynamic shape element, or empty string if not a named dynamic shape element.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!