docs.unity3d.com
    Show / Hide Table of Contents

    Struct TensorIndex

    Represents a set of indices corresponding to each axis of a tensor

    Inherited Members
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Namespace: Unity.Sentis
    Syntax
    [Serializable]
    public struct TensorIndex

    Constructors

    TensorIndex(Int32)

    Creates a rank-1 tensor index (d0) Ex: (9)

    Declaration
    public TensorIndex(int d0)
    Parameters
    Type Name Description
    Int32 d0

    TensorIndex(Int32, Int32)

    Creates a rank-2 tensor index (d1, d0) Ex: (8,9)

    Declaration
    public TensorIndex(int d1, int d0)
    Parameters
    Type Name Description
    Int32 d1
    Int32 d0

    TensorIndex(Int32, Int32, Int32)

    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
    Int32 d2
    Int32 d1
    Int32 d0

    TensorIndex(Int32, Int32, Int32, Int32)

    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
    Int32 d3
    Int32 d2
    Int32 d1
    Int32 d0

    TensorIndex(Int32, Int32, Int32, Int32, Int32)

    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
    Int32 d4
    Int32 d3
    Int32 d2
    Int32 d1
    Int32 d0

    TensorIndex(Int32, Int32, Int32, Int32, Int32, Int32)

    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
    Int32 d5
    Int32 d4
    Int32 d3
    Int32 d2
    Int32 d1
    Int32 d0

    TensorIndex(Int32, Int32, Int32, Int32, Int32, Int32, Int32)

    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
    Int32 d6
    Int32 d5
    Int32 d4
    Int32 d3
    Int32 d2
    Int32 d1
    Int32 d0

    TensorIndex(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)

    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
    Int32 d7
    Int32 d6
    Int32 d5
    Int32 d4
    Int32 d3
    Int32 d2
    Int32 d1
    Int32 d0

    TensorIndex(Int32[])

    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
    Int32[] index

    TensorIndex(TensorIndex)

    Copy constructor

    Declaration
    public TensorIndex(TensorIndex index)
    Parameters
    Type Name Description
    TensorIndex index

    Fields

    maxRank

    TensorIndex cannot have a bigger rank than maxRank

    Declaration
    public const int maxRank = 8
    Field Value
    Type Description
    Int32

    Properties

    Item[Int32]

    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
    Int32 axis
    Property Value
    Type Description
    Int32

    rank

    Declaration
    public readonly int rank { get; }
    Property Value
    Type Description
    Int32

    Methods

    Axis(Int32)

    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
    Int32 axis
    Returns
    Type Description
    Int32

    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
    Returns
    Type Description
    Boolean
    Overrides
    ValueType.Equals(Object)

    GetHashCode()

    Serves as the default hash function.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    Int32
    Overrides
    ValueType.GetHashCode()

    ToString()

    Returns a string that represents the TensorIndex.

    Declaration
    public override string ToString()
    Returns
    Type Description
    String
    Overrides
    ValueType.ToString()

    Zeros(Int32)

    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
    Int32 rank
    Returns
    Type Description
    TensorIndex

    Operators

    Equality(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
    TensorIndex b
    Returns
    Type Description
    Boolean

    Inequality(TensorIndex, TensorIndex)

    Declaration
    public static bool operator !=(TensorIndex a, TensorIndex b)
    Parameters
    Type Name Description
    TensorIndex a
    TensorIndex b
    Returns
    Type Description
    Boolean

    Did you find this page useful? Please give it a rating:

    Thanks for rating this page!

    Report a problem on this page

    What kind of problem would you like to report?

    • This page needs code samples
    • Code samples do not work
    • Information is missing
    • Information is incorrect
    • Information is unclear or confusing
    • There is a spelling/grammar error on this page
    • Something else

    Thanks for letting us know! This page has been marked for review based on your feedback.

    If you have time, you can provide more information to help us fix the problem faster.

    Provide more information

    You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:

    You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:

    You've told us there is information missing from this page. Please tell us more about what's missing:

    You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:

    You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:

    You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:

    You've told us this page has a problem. Please tell us more about what's wrong:

    Thank you for helping to make the Unity documentation better!

    Your feedback has been submitted as a ticket for our documentation team to review.

    We are not able to reply to every ticket submitted.

    In This Article
    • Constructors
      • TensorIndex(Int32)
      • TensorIndex(Int32, Int32)
      • TensorIndex(Int32, Int32, Int32)
      • TensorIndex(Int32, Int32, Int32, Int32)
      • TensorIndex(Int32, Int32, Int32, Int32, Int32)
      • TensorIndex(Int32, Int32, Int32, Int32, Int32, Int32)
      • TensorIndex(Int32, Int32, Int32, Int32, Int32, Int32, Int32)
      • TensorIndex(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32)
      • TensorIndex(Int32[])
      • TensorIndex(TensorIndex)
    • Fields
      • maxRank
    • Properties
      • Item[Int32]
      • rank
    • Methods
      • Axis(Int32)
      • Equals(Object)
      • GetHashCode()
      • ToString()
      • Zeros(Int32)
    • Operators
      • Equality(TensorIndex, TensorIndex)
      • Inequality(TensorIndex, TensorIndex)
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023