docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct DynamicTensorShape

    Represents the shape of an input tensor, or the predicted shape of a tensor before Sentis executes.

    Inherited Members
    object.Equals(object, object)
    object.GetType()
    object.ReferenceEquals(object, object)
    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 to copy.

    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 TensorShape to copy.

    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 DynamicTensorShape.

    Returns
    Type Description
    DynamicTensorShape

    The created DynamicTensorShape.

    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 DynamicTensorShape.

    Overrides
    ValueType.Equals(object)

    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
    ValueType.GetHashCode()

    IsStatic()

    Checks if the DynamicTensorShape is static and can be converted to a TensorShape.

    Declaration
    public bool IsStatic()
    Returns
    Type Description
    bool

    Whether the DynamicTensorShape has static rank all static dimensions.

    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 DynamicTensorShape.

    Overrides
    ValueType.ToString()

    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 TensorShape.

    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 to compare.

    DynamicTensorShape b

    The second DynamicTensorShape to compare.

    Returns
    Type Description
    bool

    Whether the two DynamicTensorShape objects are equal.

    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 to compare.

    DynamicTensorShape b

    The second DynamicTensorShape to compare.

    Returns
    Type Description
    bool

    Whether the two DynamicTensorShape objects are not equal.


    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
      • DynamicTensorShape(int)
      • DynamicTensorShape(int, int)
      • DynamicTensorShape(int, int, int)
      • DynamicTensorShape(int, int, int, int)
      • DynamicTensorShape(int, int, int, int, int)
      • DynamicTensorShape(int, int, int, int, int, int)
      • DynamicTensorShape(int, int, int, int, int, int, int)
      • DynamicTensorShape(int, int, int, int, int, int, int, int)
      • DynamicTensorShape(ReadOnlySpan<int>)
      • DynamicTensorShape(DynamicTensorShape)
      • DynamicTensorShape(TensorShape)
    • Properties
      • isRankDynamic
      • rank
    • Methods
      • DynamicOfRank(int)
      • Equals(object)
      • Get(int)
      • GetHashCode()
      • IsStatic()
      • Ones(int)
      • Set(int, int)
      • SetDynamic(int)
      • ToIntArray()
      • ToString()
      • ToTensorShape()
    • Operators
      • operator ==(DynamicTensorShape, DynamicTensorShape)
      • operator !=(DynamicTensorShape, DynamicTensorShape)
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)