Show / Hide Table of Contents

# Class ArrayTensorExtensions

##### Inheritance

System.Object
ArrayTensorExtensions

##### Inherited Members

System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()

###### Namespace: Microsoft.ML.OnnxRuntime.Tensors

###### Assembly: cs.temp.dll.dll

##### Syntax

    public static class ArrayTensorExtensions

### Methods

#### ToTensor<T>(T[])

Creates a copy of this single-dimensional array as a DenseTensor<T>

##### Declaration

    public static DenseTensor<T> ToTensor<T>(this T[] array)

##### Parameters

Type | Name | Description
--- | --- | ---
T[] | array | The array to create a DenseTensor<T> from.

##### Returns

Type | Description
--- | ---
DenseTensor<T> | A 1-dimensional DenseTensor<T> with the same length and content as `array`.

##### Type Parameters

Name | Description
--- | ---
T | Type contained in the array to copy to the DenseTensor<T>.

#### ToTensor<T>(T[,,,], Boolean)

Creates a copy of this four-dimensional array as a DenseTensor<T>

##### Declaration

    public static DenseTensor<T> ToTensor<T>(this T[,,, ] array, bool reverseStride = false)

##### Parameters

Type | Name | Description
--- | --- | ---
T[,,,] | array | The array to create a DenseTensor<T> from.
System.Boolean | reverseStride | False (default) to indicate that the first dimension is most major (farthest apart) and the last dimension is most minor (closest together): akin to row-major in a rank-2 tensor. True to indicate that the last dimension is most major (farthest apart) and the first dimension is most minor (closest together): akin to column-major in a rank-2 tensor.

##### Returns

Type | Description
--- | ---
DenseTensor<T> | A 4-dimensional DenseTensor<T> with the same dimensions and content as `array`.

##### Type Parameters

Name | Description
--- | ---
T | Type contained in the array to copy to the DenseTensor<T>.

#### ToTensor<T>(T[,,], Boolean)

Creates a copy of this three-dimensional array as a DenseTensor<T>

##### Declaration

    public static DenseTensor<T> ToTensor<T>(this T[,, ] array, bool reverseStride = false)

##### Parameters

Type | Name | Description
--- | --- | ---
T[,,] | array | The array to create a DenseTensor<T> from.
System.Boolean | reverseStride | False (default) to indicate that the first dimension is most major (farthest apart) and the last dimension is most minor (closest together): akin to row-major in a rank-2 tensor. True to indicate that the last dimension is most major (farthest apart) and the first dimension is most minor (closest together): akin to column-major in a rank-2 tensor.

##### Returns

Type | Description
--- | ---
DenseTensor<T> | A 3-dimensional DenseTensor<T> with the same dimensions and content as `array`.

##### Type Parameters

Name | Description
--- | ---
T | Type contained in the array to copy to the DenseTensor<T>.

#### ToTensor<T>(T[,], Boolean)

Creates a copy of this two-dimensional array as a DenseTensor<T>

##### Declaration

    public static DenseTensor<T> ToTensor<T>(this T[, ] array, bool reverseStride = false)

##### Parameters

Type | Name | Description
--- | --- | ---
T[,] | array | The array to create a DenseTensor<T> from.
System.Boolean | reverseStride | False (default) to indicate that the first dimension is most major (farthest apart) and the last dimension is most minor (closest together): row-major. True to indicate that the last dimension is most major (farthest apart) and the first dimension is most minor (closest together): column-major.

##### Returns

Type | Description
--- | ---
DenseTensor<T> | A 2-dimensional DenseTensor<T> with the same dimensions and content as `array`.

##### Type Parameters

Name | Description
--- | ---
T | Type contained in the array to copy to the DenseTensor<T>.

#### ToTensor<T>(Array, Boolean)

Creates a copy of this n-dimensional array as a DenseTensor<T>

##### Declaration

    public static DenseTensor<T> ToTensor<T>(this Array array, bool reverseStride = false)

##### Parameters

Type | Name | Description
--- | --- | ---
Array | array | The array to create a DenseTensor<T> from.
System.Boolean | reverseStride | False (default) to indicate that the first dimension is most major (farthest apart) and the last dimension is most minor (closest together): akin to row-major in a rank-2 tensor. True to indicate that the last dimension is most major (farthest apart) and the first dimension is most minor (closest together): akin to column-major in a rank-2 tensor.

##### Returns

Type | Description
--- | ---
DenseTensor<T> | A n-dimensional DenseTensor<T> with the same dimensions and content as `array`.

##### Type Parameters

Name | Description
--- | ---
T | Type contained in the array to copy to the DenseTensor<T>.