Class Tensor
Various methods for creating and manipulating Tensor<T>
Inheritance
Inherited Members
Namespace: Microsoft.ML.OnnxRuntime.Tensors
Assembly: Microsoft.ML.OnnxRuntime.dll
Syntax
public static class Tensor
Methods
| Improve this Doc View SourceCreateFromDiagonal<T>(Tensor<T>)
Creates a n+1-rank tensor using the specified n-rank diagonal. Values not on the diagonal will be filled with zeros.
Declaration
public static Tensor<T> CreateFromDiagonal<T>(Tensor<T> diagonal)
Parameters
Type | Name | Description |
---|---|---|
Tensor<T> | diagonal | Tensor representing the diagonal to build the new tensor from. |
Returns
Type | Description |
---|---|
Tensor<T> | A new tensor of the same layout and order as |
Type Parameters
Name | Description |
---|---|
T | type contained within the Tensor. Typically a value type such as int, double, float, etc. |
CreateFromDiagonal<T>(Tensor<T>, Int32)
Creates a n+1-dimension tensor using the specified n-dimension diagonal at the specified offset from the center. Values not on the diagonal will be filled with zeros.
Declaration
public static Tensor<T> CreateFromDiagonal<T>(Tensor<T> diagonal, int offset)
Parameters
Type | Name | Description |
---|---|---|
Tensor<T> | diagonal | Tensor representing the diagonal to build the new tensor from. |
Int32 | offset | Offset of diagonal to set in returned tensor. 0 for the main diagonal, less than zero for diagonals below, greater than zero from diagonals above. |
Returns
Type | Description |
---|---|
Tensor<T> | A new tensor of the same layout and order as |
Type Parameters
Name | Description |
---|---|
T | type contained within the Tensor. Typically a value type such as int, double, float, etc. |
CreateIdentity<T>(Int32)
Creates an identity tensor of the specified size. An identity tensor is a two dimensional tensor with 1s in the diagonal.
Declaration
public static Tensor<T> CreateIdentity<T>(int size)
Parameters
Type | Name | Description |
---|---|---|
Int32 | size | Width and height of the identity tensor to create. |
Returns
Type | Description |
---|---|
Tensor<T> | a |
Type Parameters
Name | Description |
---|---|
T | type contained within the Tensor. Typically a value type such as int, double, float, etc. |
CreateIdentity<T>(Int32, Boolean)
Creates an identity tensor of the specified size and layout (row vs column major). An identity tensor is a two dimensional tensor with 1s in the diagonal.
Declaration
public static Tensor<T> CreateIdentity<T>(int size, bool columMajor)
Parameters
Type | Name | Description |
---|---|---|
Int32 | size | Width and height of the identity tensor to create. |
Boolean | columMajor |
|
Returns
Type | Description |
---|---|
Tensor<T> | a |
Type Parameters
Name | Description |
---|---|
T | type contained within the Tensor. Typically a value type such as int, double, float, etc. |
CreateIdentity<T>(Int32, Boolean, T)
Creates an identity tensor of the specified size and layout (row vs column major) using the specified one value. An identity tensor is a two dimensional tensor with 1s in the diagonal. This may be used in case T is a type that doesn't have a known 1 value.
Declaration
public static Tensor<T> CreateIdentity<T>(int size, bool columMajor, T oneValue)
Parameters
Type | Name | Description |
---|---|---|
Int32 | size | Width and height of the identity tensor to create. |
Boolean | columMajor |
|
T | oneValue | Value of |
Returns
Type | Description |
---|---|
Tensor<T> | a |
Type Parameters
Name | Description |
---|---|
T | type contained within the Tensor. Typically a value type such as int, double, float, etc. |