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!
If you'd like to share more information, please report an issue on GitHub
π What went wrong?