Share via


Tensor.Create Method

Definition

Overloads

Create<T>(T[], ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Creates a new tensor over the portion of the target array beginning at the specified start index and using the specified lengths and strides.

Create<T>(ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>, Boolean)

Creates a Tensor<T> and initializes it with the default value of T. If pinned is true, the memory will be pinned.

Create<T>(T[], Int32, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Creates a new tensor over the portion of the target array beginning at the specified start index and using the specified lengths and strides.

Create<T>(IEnumerable<T>, ReadOnlySpan<IntPtr>, Boolean)

Creates a Tensor<T> and initializes it with the data from values.

Create<T>(IEnumerable<T>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>, Boolean)

Creates a Tensor<T> and initializes it with the data from values.

Create<T>(ReadOnlySpan<IntPtr>, Boolean)

Creates a Tensor<T> and initializes it with the default value of T. If pinned is true, the memory will be pinned.

Create<T>(IEnumerable<T>, Boolean)
Create<T>(T[], ReadOnlySpan<IntPtr>)

Creates a new tensor over the portion of the target array using the specified lengths.

Create<T>(T[])

Creates a new tensor over the entirety of the target array.

Create<T>(T[], ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Source:
Tensor.cs

Creates a new tensor over the portion of the target array beginning at the specified start index and using the specified lengths and strides.

public:
generic <typename T>
 static System::Numerics::Tensors::Tensor<T> ^ Create(cli::array <T> ^ array, ReadOnlySpan<IntPtr> lengths, ReadOnlySpan<IntPtr> strides);
public static System.Numerics.Tensors.Tensor<T> Create<T>(T[] array, scoped ReadOnlySpan<IntPtr> lengths, scoped ReadOnlySpan<IntPtr> strides);
static member Create : 'T[] * ReadOnlySpan<nativeint> * ReadOnlySpan<nativeint> -> System.Numerics.Tensors.Tensor<'T>
Public Function Create(Of T) (array As T(), lengths As ReadOnlySpan(Of IntPtr), strides As ReadOnlySpan(Of IntPtr)) As Tensor(Of T)

Type Parameters

T

Parameters

array
T[]

The target array.

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of the dimensions. If an empty span is provided, the created tensor will have a single dimension that is the same length as array.

strides

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The strides of each dimension. If an empty span is provided, then strides will be automatically calculated from lengths.

Returns

A new tensor that uses array as its backing buffer and with the specified lengths and strides.

Applies to

Create<T>(ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>, Boolean)

Source:
Tensor.cs
Source:
Tensor.Factory.cs

Creates a Tensor<T> and initializes it with the default value of T. If pinned is true, the memory will be pinned.

public static System.Numerics.Tensors.Tensor<T> Create<T>(scoped ReadOnlySpan<IntPtr> lengths, scoped ReadOnlySpan<IntPtr> strides, bool pinned = false);
static member Create : ReadOnlySpan<nativeint> * ReadOnlySpan<nativeint> * bool -> System.Numerics.Tensors.Tensor<'T>
Public Function Create(Of T) (lengths As ReadOnlySpan(Of IntPtr), strides As ReadOnlySpan(Of IntPtr), Optional pinned As Boolean = false) As Tensor(Of T)

Type Parameters

T

Parameters

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

A ReadOnlySpan<T> indicating the lengths of each dimension.

strides

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

A ReadOnlySpan<T> indicating the strides of each dimension.

pinned
Boolean

A Boolean whether the underlying data should be pinned or not.

Returns

A new tensor with the specified lengths and strides.

Applies to

Create<T>(T[], Int32, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>)

Source:
Tensor.cs

Creates a new tensor over the portion of the target array beginning at the specified start index and using the specified lengths and strides.

public:
generic <typename T>
 static System::Numerics::Tensors::Tensor<T> ^ Create(cli::array <T> ^ array, int start, ReadOnlySpan<IntPtr> lengths, ReadOnlySpan<IntPtr> strides);
public static System.Numerics.Tensors.Tensor<T> Create<T>(T[] array, int start, scoped ReadOnlySpan<IntPtr> lengths, scoped ReadOnlySpan<IntPtr> strides);
static member Create : 'T[] * int * ReadOnlySpan<nativeint> * ReadOnlySpan<nativeint> -> System.Numerics.Tensors.Tensor<'T>
Public Function Create(Of T) (array As T(), start As Integer, lengths As ReadOnlySpan(Of IntPtr), strides As ReadOnlySpan(Of IntPtr)) As Tensor(Of T)

Type Parameters

T

Parameters

array
T[]

The target array.

start
Int32

The index at which to begin the tensor.

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of the dimensions. If an empty span is provided, the created tensor will have a single dimension that is the same length as array.

strides

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The strides of each dimension. If an empty span is provided, then strides will be automatically calculated from lengths.

Returns

A new tensor that uses array as its backing buffer and with the specified lengths and strides.

Applies to

Create<T>(IEnumerable<T>, ReadOnlySpan<IntPtr>, Boolean)

Source:
Tensor.cs
Source:
Tensor.Factory.cs

Creates a Tensor<T> and initializes it with the data from values.

public static System.Numerics.Tensors.Tensor<T> Create<T>(System.Collections.Generic.IEnumerable<T> enumerable, scoped ReadOnlySpan<IntPtr> lengths, bool pinned = false);
static member Create : seq<'T> * ReadOnlySpan<nativeint> * bool -> System.Numerics.Tensors.Tensor<'T>
Public Function Create(Of T) (enumerable As IEnumerable(Of T), lengths As ReadOnlySpan(Of IntPtr), Optional pinned As Boolean = false) As Tensor(Of T)

Type Parameters

T

Parameters

enumerable
IEnumerable<T>
lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

A ReadOnlySpan<T> indicating the lengths of each dimension.

pinned
Boolean

A Boolean indicating whether the values were pinned or not.

Returns

A new tensor that contains elements copied from enumerable and with the specified lengths.

Applies to

Create<T>(IEnumerable<T>, ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>, Boolean)

Source:
Tensor.cs
Source:
Tensor.Factory.cs

Creates a Tensor<T> and initializes it with the data from values.

public static System.Numerics.Tensors.Tensor<T> Create<T>(System.Collections.Generic.IEnumerable<T> enumerable, scoped ReadOnlySpan<IntPtr> lengths, scoped ReadOnlySpan<IntPtr> strides, bool pinned = false);
static member Create : seq<'T> * ReadOnlySpan<nativeint> * ReadOnlySpan<nativeint> * bool -> System.Numerics.Tensors.Tensor<'T>
Public Function Create(Of T) (enumerable As IEnumerable(Of T), lengths As ReadOnlySpan(Of IntPtr), strides As ReadOnlySpan(Of IntPtr), Optional pinned As Boolean = false) As Tensor(Of T)

Type Parameters

T

Parameters

enumerable
IEnumerable<T>
lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

A ReadOnlySpan<T> indicating the lengths of each dimension.

strides

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

A ReadOnlySpan<T> indicating the strides of each dimension.

pinned
Boolean

A Boolean indicating whether the values were pinned or not.

Returns

A new tensor that contains elements copied from enumerable and with the specified lengths and strides.

Applies to

Create<T>(ReadOnlySpan<IntPtr>, Boolean)

Source:
Tensor.cs
Source:
Tensor.Factory.cs

Creates a Tensor<T> and initializes it with the default value of T. If pinned is true, the memory will be pinned.

public static System.Numerics.Tensors.Tensor<T> Create<T>(scoped ReadOnlySpan<IntPtr> lengths, bool pinned = false);
static member Create : ReadOnlySpan<nativeint> * bool -> System.Numerics.Tensors.Tensor<'T>
Public Function Create(Of T) (lengths As ReadOnlySpan(Of IntPtr), Optional pinned As Boolean = false) As Tensor(Of T)

Type Parameters

T

Parameters

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

A ReadOnlySpan<T> indicating the lengths of each dimension.

pinned
Boolean

A Boolean whether the underlying data should be pinned or not.

Returns

A new tensor with the specified lengths.

Applies to

Create<T>(IEnumerable<T>, Boolean)

Source:
Tensor.cs
public static System.Numerics.Tensors.Tensor<T> Create<T>(System.Collections.Generic.IEnumerable<T> enumerable, bool pinned = false);
static member Create : seq<'T> * bool -> System.Numerics.Tensors.Tensor<'T>
Public Function Create(Of T) (enumerable As IEnumerable(Of T), Optional pinned As Boolean = false) As Tensor(Of T)

Type Parameters

T

Parameters

enumerable
IEnumerable<T>
pinned
Boolean

Returns

A new tensor that contains elements copied from enumerable.

Applies to

Create<T>(T[], ReadOnlySpan<IntPtr>)

Source:
Tensor.cs

Creates a new tensor over the portion of the target array using the specified lengths.

public:
generic <typename T>
 static System::Numerics::Tensors::Tensor<T> ^ Create(cli::array <T> ^ array, ReadOnlySpan<IntPtr> lengths);
public static System.Numerics.Tensors.Tensor<T> Create<T>(T[] array, scoped ReadOnlySpan<IntPtr> lengths);
static member Create : 'T[] * ReadOnlySpan<nativeint> -> System.Numerics.Tensors.Tensor<'T>
Public Function Create(Of T) (array As T(), lengths As ReadOnlySpan(Of IntPtr)) As Tensor(Of T)

Type Parameters

T

Parameters

array
T[]

The target array.

lengths

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

The lengths of the dimensions. If an empty span is provided, the created tensor will have a single dimension that is the same length as array.

Returns

A new tensor that uses array as its backing buffer and with the specified lengths.

Applies to

Create<T>(T[])

Source:
Tensor.cs

Creates a new tensor over the entirety of the target array.

public:
generic <typename T>
 static System::Numerics::Tensors::Tensor<T> ^ Create(cli::array <T> ^ array);
public static System.Numerics.Tensors.Tensor<T> Create<T>(T[] array);
static member Create : 'T[] -> System.Numerics.Tensors.Tensor<'T>
Public Function Create(Of T) (array As T()) As Tensor(Of T)

Type Parameters

T

Parameters

array
T[]

The target array.

Returns

A new tensor that uses array as its backing buffer.

Applies to