Struct DynamicTensorShape
Represents the shape of an input tensor, or the predicted shape of a tensor before Sentis executes.
Inherited Members
Namespace: Unity.Sentis
Assembly: Unity.Sentis.dll
Syntax
[Serializable]
public struct DynamicTensorShape
Constructors
DynamicTensorShape(int)
Initializes and returns an instance of DynamicTensorShape
with rank 1.
Dimensions with non-negative values are static and values of -1 are dynamic.
Declaration
public DynamicTensorShape(int d0)
Parameters
Type | Name | Description |
---|---|---|
int | d0 | The dimension of axis 0. |
DynamicTensorShape(int, int)
Initializes and returns an instance of DynamicTensorShape
with rank 2.
Dimensions with non-negative values are static and values of -1 are dynamic.
Declaration
public DynamicTensorShape(int d0, int d1)
Parameters
Type | Name | Description |
---|---|---|
int | d0 | The dimension of axis 0. |
int | d1 | The dimension of axis 1. |
DynamicTensorShape(int, int, int)
Initializes and returns an instance of DynamicTensorShape
with rank 3.
Dimensions with non-negative values are static and values of -1 are dynamic.
Declaration
public DynamicTensorShape(int d0, int d1, int d2)
Parameters
Type | Name | Description |
---|---|---|
int | d0 | The dimension of axis 0. |
int | d1 | The dimension of axis 1. |
int | d2 | The dimension of axis 2. |
DynamicTensorShape(int, int, int, int)
Initializes and returns an instance of DynamicTensorShape
with rank 4.
Dimensions with non-negative values are static and values of -1 are dynamic.
Declaration
public DynamicTensorShape(int d0, int d1, int d2, int d3)
Parameters
Type | Name | Description |
---|---|---|
int | d0 | The dimension of axis 0. |
int | d1 | The dimension of axis 1. |
int | d2 | The dimension of axis 2. |
int | d3 | The dimension of axis 3. |
DynamicTensorShape(int, int, int, int, int)
Initializes and returns an instance of DynamicTensorShape
with rank 5.
Dimensions with non-negative values are static and values of -1 are dynamic.
Declaration
public DynamicTensorShape(int d0, int d1, int d2, int d3, int d4)
Parameters
Type | Name | Description |
---|---|---|
int | d0 | The dimension of axis 0. |
int | d1 | The dimension of axis 1. |
int | d2 | The dimension of axis 2. |
int | d3 | The dimension of axis 3. |
int | d4 | The dimension of axis 4. |
DynamicTensorShape(int, int, int, int, int, int)
Initializes and returns an instance of DynamicTensorShape
with rank 6.
Dimensions with non-negative values are static and values of -1 are dynamic.
Declaration
public DynamicTensorShape(int d0, int d1, int d2, int d3, int d4, int d5)
Parameters
Type | Name | Description |
---|---|---|
int | d0 | The dimension of axis 0. |
int | d1 | The dimension of axis 1. |
int | d2 | The dimension of axis 2. |
int | d3 | The dimension of axis 3. |
int | d4 | The dimension of axis 4. |
int | d5 | The dimension of axis 5. |
DynamicTensorShape(int, int, int, int, int, int, int)
Initializes and returns an instance of DynamicTensorShape
with rank 7.
Dimensions with non-negative values are static and values of -1 are dynamic.
Declaration
public DynamicTensorShape(int d0, int d1, int d2, int d3, int d4, int d5, int d6)
Parameters
Type | Name | Description |
---|---|---|
int | d0 | The dimension of axis 0. |
int | d1 | The dimension of axis 1. |
int | d2 | The dimension of axis 2. |
int | d3 | The dimension of axis 3. |
int | d4 | The dimension of axis 4. |
int | d5 | The dimension of axis 5. |
int | d6 | The dimension of axis 6. |
DynamicTensorShape(int, int, int, int, int, int, int, int)
Initializes and returns an instance of DynamicTensorShape
with rank 8.
Dimensions with non-negative values are static and values of -1 are dynamic.
Declaration
public DynamicTensorShape(int d0, int d1, int d2, int d3, int d4, int d5, int d6, int d7)
Parameters
Type | Name | Description |
---|---|---|
int | d0 | The dimension of axis 0. |
int | d1 | The dimension of axis 1. |
int | d2 | The dimension of axis 2. |
int | d3 | The dimension of axis 3. |
int | d4 | The dimension of axis 4. |
int | d5 | The dimension of axis 5. |
int | d6 | The dimension of axis 6. |
int | d7 | The dimension of axis 7. |
DynamicTensorShape(ReadOnlySpan<int>)
Initializes and returns an instance of DynamicTensorShape
with given dims.
Values of -1 are
Declaration
public DynamicTensorShape(ReadOnlySpan<int> shape)
Parameters
Type | Name | Description |
---|---|---|
ReadOnlySpan<int> | shape | The shape as a span. |
DynamicTensorShape(DynamicTensorShape)
Returns a copy of another DynamicTensorShape
.
Declaration
public DynamicTensorShape(DynamicTensorShape other)
Parameters
Type | Name | Description |
---|---|---|
DynamicTensorShape | other | The |
DynamicTensorShape(TensorShape)
Initializes and returns an instance of DynamicTensorShape
with a given TensorShape
, and dynamic dimensions. For example: DynamicTensorShape(new TensorShape(3, 4, 5, 6))
returns a dynamic tensor shape of (3, 4, 5, 6).
Declaration
public DynamicTensorShape(TensorShape other)
Parameters
Type | Name | Description |
---|---|---|
TensorShape | other | The |
Properties
isRankDynamic
Whether the shape has a dynamic rank.
Declaration
public bool isRankDynamic { get; }
Property Value
Type | Description |
---|---|
bool |
rank
The rank of a DynamicTensorShape
, For example, a tensor of shape (5) has a rank of 1. A tensor of shape (7, 3, 5) has a rank of 3.
This cannot be called if the shape has a dynamic rank. Call isRankDynamic
first.
Declaration
public int rank { get; }
Property Value
Type | Description |
---|---|
int |
Methods
DynamicOfRank(int)
Creates and returns a DynamicTensorShape
with given rank and all dimensions dynamic.
Declaration
public static DynamicTensorShape DynamicOfRank(int rank)
Parameters
Type | Name | Description |
---|---|---|
int | rank | The rank of the |
Returns
Type | Description |
---|---|
DynamicTensorShape | The created |
Equals(object)
Determines whether the specified object is equal to the current DynamicTensorShape
.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare. |
Returns
Type | Description |
---|---|
bool | Whether the object is equal to the current |
Overrides
Get(int)
Returns the dimension at a given axis as an integer.
If a dimension is dynamic it is represented with a -1.
Declaration
public int Get(int axis)
Parameters
Type | Name | Description |
---|---|---|
int | axis | The axis to get the dimension of. |
Returns
Type | Description |
---|---|
int | The integer dimension of an axis. |
GetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | The calculated hash code. |
Overrides
IsStatic()
Checks if the DynamicTensorShape
is static and can be converted to a TensorShape
.
Declaration
public bool IsStatic()
Returns
Type | Description |
---|---|
bool | Whether the |
Ones(int)
DynamicTensorShape with given rank and all dimensions 1.
Declaration
public static DynamicTensorShape Ones(int rank)
Parameters
Type | Name | Description |
---|---|---|
int | rank | The rank of the dynamic tensor shape. |
Returns
Type | Description |
---|---|
DynamicTensorShape | The dynamic tensor shape of ones. |
Set(int, int)
Sets the dimension at a given axis.
Declaration
public void Set(int axis, int dimension)
Parameters
Type | Name | Description |
---|---|---|
int | axis | The axis to set the dimension of. |
int | dimension | The dimension of the axis. Use -1 for a dynamic dimension. |
SetDynamic(int)
Sets the dimension to be dynamic at a given axis.
Declaration
public void SetDynamic(int axis)
Parameters
Type | Name | Description |
---|---|---|
int | axis | The axis to set the dimension of. |
ToIntArray()
Return the shape as an integer array, if the rank is dynamic this returns null.
If a dimension is dynamic it is represented with a -1 in the array.
Declaration
public int[] ToIntArray()
Returns
Type | Description |
---|---|
int[] | The shape as an integer array. |
ToString()
Returns a string that represents the DynamicTensorShape
.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The string representation of the |
Overrides
ToTensorShape()
Converts the DynamicTensorShape
to a TensorShape
. You should call IsStatic
before you call this method.
Declaration
public TensorShape ToTensorShape()
Returns
Type | Description |
---|---|
TensorShape | The converted |
Operators
operator ==(DynamicTensorShape, DynamicTensorShape)
Compares two DynamicTensorShape
objects. Returns true
if the two objects have the same rank, and all their dimensions are equal.
Declaration
public static bool operator ==(DynamicTensorShape a, DynamicTensorShape b)
Parameters
Type | Name | Description |
---|---|---|
DynamicTensorShape | a | The first |
DynamicTensorShape | b | The second |
Returns
Type | Description |
---|---|
bool | Whether the two |
operator !=(DynamicTensorShape, DynamicTensorShape)
Compares two DynamicTensorShape
objects. Returns true
if the two shapes have a different or dynamic rank, or at least one of their dimensions are not equal.
Declaration
public static bool operator !=(DynamicTensorShape a, DynamicTensorShape b)
Parameters
Type | Name | Description |
---|---|---|
DynamicTensorShape | a | The first |
DynamicTensorShape | b | The second |
Returns
Type | Description |
---|---|
bool | Whether the two |