Edit

Share via


TensorMarshal.CreateTensorSpan<T> Method

Definition

Creates a new tensor span over a portion of a regular managed object.

public:
generic <typename T>
 static System::Numerics::Tensors::TensorSpan<T> CreateTensorSpan(T % data, IntPtr dataLength, ReadOnlySpan<IntPtr> lengths, ReadOnlySpan<IntPtr> strides, bool pinned);
public static System.Numerics.Tensors.TensorSpan<T> CreateTensorSpan<T>(scoped ref T data, IntPtr dataLength, scoped ReadOnlySpan<IntPtr> lengths, scoped ReadOnlySpan<IntPtr> strides, bool pinned);
static member CreateTensorSpan : 'T * nativeint * ReadOnlySpan<nativeint> * ReadOnlySpan<nativeint> * bool -> System.Numerics.Tensors.TensorSpan<'T>
Public Shared Function CreateTensorSpan(Of T) (ByRef data As T, dataLength As IntPtr, lengths As ReadOnlySpan(Of IntPtr), strides As ReadOnlySpan(Of IntPtr), pinned As Boolean) As TensorSpan(Of T)

Type Parameters

T

The type of the data items.

Parameters

data
T

A reference to data.

dataLength
IntPtr

nativeint

The number of T elements that data contains.

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

strides

ReadOnlySpan<IntPtr>

ReadOnlySpan<nativeint>

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

pinned
Boolean

true if data is permanently pinned; otherwise, false.

Returns

The created tensor span.

Remarks

This method should be used with caution. It is dangerous because the inputs may not be fully checked. Even though data is marked as scoped, it will be stored into the returned tensor span, and the lifetime of the returned tensor span will not be validated for safety, even by span-aware languages.

Applies to