Share via


Tensor.Create Method

Definition

Overloads

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

Creates a Tensor<T> from the provided values. If the product of the lengths does not equal the length of the values array, an exception will be thrown.

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

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

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

Creates a Tensor<T> from the provided values. If the product of the lengths does not equal the length of the values array, an exception will be thrown.

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>, ReadOnlySpan<IntPtr>, Boolean)

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

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[], ReadOnlySpan<IntPtr>, ReadOnlySpan<IntPtr>, Boolean)

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

Creates a Tensor<T> from the provided values. If the product of the lengths does not equal the length of the values array, an exception will be thrown.

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

Type Parameters

T

Parameters

values
T[]

An array of the backing memory.

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

Exceptions

Applies to

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

Source:
Tensor.Factory.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> values, 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) (values 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

values
IEnumerable<T>

A IEnumerable<T> with the data to use for the initialization.

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

Applies to

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

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

Creates a Tensor<T> from the provided values. If the product of the lengths does not equal the length of the values array, an exception will be thrown.

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

Type Parameters

T

Parameters

values
T[]

An array of the backing memory.

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

Exceptions

Applies to

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

Source:
Tensor.Factory.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

Applies to

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

Source:
Tensor.Factory.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> values, 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) (values As IEnumerable(Of T), lengths As ReadOnlySpan(Of IntPtr), Optional pinned As Boolean = false) As Tensor(Of T)

Type Parameters

T

Parameters

values
IEnumerable<T>

A IEnumerable<T> with the data to use for the initialization.

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

Applies to

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

Source:
Tensor.Factory.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

Applies to