Struct TensorIndex
Represents a set of indices corresponding to each axis of a tensor
Inherited Members
Namespace: Unity.Sentis
Assembly: Unity.Sentis.dll
Syntax
[Serializable]
public struct TensorIndex
Constructors
TensorIndex(int)
Creates a rank-1 tensor index (d0) Ex: (9)
Declaration
public TensorIndex(int d0)
Parameters
Type | Name | Description |
---|---|---|
int | d0 | Axis 0. |
TensorIndex(int, int)
Creates a rank-2 tensor index (d1, d0) Ex: (8,9)
Declaration
public TensorIndex(int d1, int d0)
Parameters
Type | Name | Description |
---|---|---|
int | d1 | Axis 1. |
int | d0 | Axis 0. |
TensorIndex(int, int, int)
Creates a rank-3 tensor index (d2, d1, d0) Ex: (7,8,9)
Declaration
public TensorIndex(int d2, int d1, int d0)
Parameters
Type | Name | Description |
---|---|---|
int | d2 | Axis 2. |
int | d1 | Axis 1. |
int | d0 | Axis 0. |
TensorIndex(int, int, int, int)
Creates a rank-4 tensor index (d3, d2, d1, d0) Ex: (6,7,8,9)
Declaration
public TensorIndex(int d3, int d2, int d1, int d0)
Parameters
Type | Name | Description |
---|---|---|
int | d3 | Axis 3. |
int | d2 | Axis 2. |
int | d1 | Axis 1. |
int | d0 | Axis 0. |
TensorIndex(int, int, int, int, int)
Creates a rank-5 tensor index (d4, d3, d2, d1, d0) Ex: (5,6,7,8,9)
Declaration
public TensorIndex(int d4, int d3, int d2, int d1, int d0)
Parameters
Type | Name | Description |
---|---|---|
int | d4 | Axis 4. |
int | d3 | Axis 3. |
int | d2 | Axis 2. |
int | d1 | Axis 1. |
int | d0 | Axis 0. |
TensorIndex(int, int, int, int, int, int)
Creates a rank-6 tensor index (d5, d4, d3, d2, d1, d0) Ex: (4,5,6,7,8,9)
Declaration
public TensorIndex(int d5, int d4, int d3, int d2, int d1, int d0)
Parameters
Type | Name | Description |
---|---|---|
int | d5 | Axis 5. |
int | d4 | Axis 4. |
int | d3 | Axis 3. |
int | d2 | Axis 2. |
int | d1 | Axis 1. |
int | d0 | Axis 0. |
TensorIndex(int, int, int, int, int, int, int)
Creates a rank-7 tensor index (d6, d5, d4, d3, d2, d1, d0) Ex: (3,4,5,6,7,8,9)
Declaration
public TensorIndex(int d6, int d5, int d4, int d3, int d2, int d1, int d0)
Parameters
Type | Name | Description |
---|---|---|
int | d6 | Axis 6. |
int | d5 | Axis 5. |
int | d4 | Axis 4. |
int | d3 | Axis 3. |
int | d2 | Axis 2. |
int | d1 | Axis 1. |
int | d0 | Axis 0. |
TensorIndex(int, int, int, int, int, int, int, int)
Creates a rank-8 tensor index (d7, d6, d5, d4, d3, d2, d1, d0) Ex: (2,3,4,5,6,7,8,9)
Declaration
public TensorIndex(int d7, int d6, int d5, int d4, int d3, int d2, int d1, int d0)
Parameters
Type | Name | Description |
---|---|---|
int | d7 | Axis 7. |
int | d6 | Axis 6. |
int | d5 | Axis 5. |
int | d4 | Axis 4. |
int | d3 | Axis 3. |
int | d2 | Axis 2. |
int | d1 | Axis 1. |
int | d0 | Axis 0. |
TensorIndex(int[])
Creates a tensor index given an input int[] representing the index Ex: TensorIndex(new [] {3,4,5,6}) = (3,4,5,6)
Declaration
public TensorIndex(int[] index)
Parameters
Type | Name | Description |
---|---|---|
int[] | index | The index as an array. |
TensorIndex(TensorIndex)
Instantiates and returns a copy of another TensorIndex
.
Declaration
public TensorIndex(TensorIndex index)
Parameters
Type | Name | Description |
---|---|---|
TensorIndex | index | The |
Fields
maxRank
TensorIndex cannot have a bigger rank than maxRank
Declaration
public const int maxRank = 8
Field Value
Type | Description |
---|---|
int |
Properties
this[int]
Gets/Sets tensor index at a given axis Ex: index (3, 4, 5, 6) index 0, 1, 2, 3 -4,-3,-2,-1 index (7, 3, 2) index 0, 1, 2 -3,-2,-1
Declaration
public int this[int axis] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | axis | The axis to get the index at. |
Property Value
Type | Description |
---|---|
int |
rank
Rank of a TensorIndex: Ex: (5) -> rank:1 (3,5) -> rank:2 (7,3,5) -> rank:3 (6,7,3,5) -> rank:4
Declaration
public int rank { get; }
Property Value
Type | Description |
---|---|
int |
Methods
Axis(int)
Wraps axis to positive index between 0,rank (5,2,3,4) axis = -1 => axis_out = 3 axis = 1 => axis_out = 1
Declaration
public int Axis(int axis)
Parameters
Type | Name | Description |
---|---|---|
int | axis | The axis to wrap. |
Returns
Type | Description |
---|---|
int | The wrapped axis. |
Equals(object)
Determines whether the specified object is equal to the current TensorIndex
.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare to the tensor index. |
Returns
Type | Description |
---|---|
bool | Whether the object is equal to the tensor index. |
Overrides
GetHashCode()
Serves as the default hash function.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | The hashed tensor index. |
Overrides
ToString()
Returns a string that represents the TensorIndex
.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The string representation of the tensor index. |
Overrides
Zeros(int)
Creates index with zeros 0 of specified rank Ex: EmptyOfRank(rank: 3) => (0, 0, 0)
Declaration
public static TensorIndex Zeros(int rank)
Parameters
Type | Name | Description |
---|---|---|
int | rank | The rank of the tensor index. |
Returns
Type | Description |
---|---|
TensorIndex | The created tensor index. |
Operators
operator ==(TensorIndex, TensorIndex)
Compares two TensorIndex
objects
Two TensorIndices are equal if they have the same rank and all their dimensions are equal
Declaration
public static bool operator ==(TensorIndex a, TensorIndex b)
Parameters
Type | Name | Description |
---|---|---|
TensorIndex | a | The first tensor index to compare. |
TensorIndex | b | The second tensor index to compare. |
Returns
Type | Description |
---|---|
bool | Whether the tensor indexes are equal. |
operator !=(TensorIndex, TensorIndex)
Compares two TensorIndex
objects
Declaration
public static bool operator !=(TensorIndex a, TensorIndex b)
Parameters
Type | Name | Description |
---|---|---|
TensorIndex | a | The first tensor index to compare. |
TensorIndex | b | The second tensor index to compare. |
Returns
Type | Description |
---|---|
bool | Whether the tensor indexes are not equal. |