Table of Contents

Class TensorReduction

Namespace
NVMathNet.Tensor
Assembly
NVMath.Net.dll

Reduction: D[modeD] = alpha · opReduce(opA(A[modeA])) + beta · opC(C[modeD]), reducing the modes of A that do not appear in D.

public sealed class TensorReduction : TensorOperation, IAsyncDisposable, IDisposable

Inheritance

Implements

Inherited Members

Constructors

TensorReduction(long[], int[], long[], int[], TensorDataType, CuTensorOperator, CuTensorOperator, CuTensorOperator, TensorContractionOptions?, CudaStream?)

Creates a reduction.

public TensorReduction(long[] extentA, int[] modeA, long[] extentD, int[] modeD, TensorDataType dataType = TensorDataType.Float32, CuTensorOperator opReduce = CuTensorOperator.Add, CuTensorOperator opA = CuTensorOperator.Identity, CuTensorOperator opC = CuTensorOperator.Identity, TensorContractionOptions? options = null, CudaStream? stream = null)

Parameters

extentA long[]

Sizes of the dimensions of A.

modeA int[]

Mode labels of A.

extentD long[]

Sizes of the dimensions of D (and C).

modeD int[]

Mode labels of D: a subset of modeA.

dataType TensorDataType

Element type of all tensors. Default: float.

opReduce CuTensorOperator

Reduction operator: NVMathNet.Interop.CuTensorOperator.Add, NVMathNet.Interop.CuTensorOperator.Mul, NVMathNet.Interop.CuTensorOperator.Max or NVMathNet.Interop.CuTensorOperator.Min.

opA CuTensorOperator

Unary operator applied to each element of A before reducing. Default: identity.

opC CuTensorOperator

Unary operator applied to C. Default: identity.

options TensorContractionOptions?

Options; null uses defaults.

stream CudaStream?

Optional external stream.

Methods

Execute(nint, nint, nint, double, double)

Executes D = alpha · reduce(A) + beta · C. pC and pD may be the same pointer.

public void Execute(nint pA, nint pC, nint pD, double alpha = 1, double beta = 0)

Parameters

pA nint
pC nint
pD nint
alpha double
beta double

ExecuteAsync(nint, nint, nint, double, double, CancellationToken)

Asynchronous version of NVMathNet.Tensor.TensorReduction.Execute(System.IntPtr,System.IntPtr,System.IntPtr,System.Double,System.Double).

public Task ExecuteAsync(nint pA, nint pC, nint pD, double alpha = 1, double beta = 0, CancellationToken ct = default)

Parameters

pA nint
pC nint
pD nint
alpha double
beta double
ct CancellationToken

Returns

Task

ExecuteAsync<T>(DeviceBuffer<T>, DeviceBuffer<T>, double, double, CancellationToken)

Reduces A into D (beta = 0 by default).

public Task ExecuteAsync<T>(DeviceBuffer<T> a, DeviceBuffer<T> d, double alpha = 1, double beta = 0, CancellationToken ct = default) where T : unmanaged, INumberBase<T>

Parameters

a DeviceBuffer<T>
d DeviceBuffer<T>
alpha double
beta double
ct CancellationToken

Returns

Task

Type Parameters

T

ExecuteInPlace(nint, nint, double, double)

Executes D = alpha · reduce(A) + beta · D in place on D. (Named differently from Execute because an overload with one pointer fewer would silently capture calls such as Execute(a, d, 2, 0).)

public void ExecuteInPlace(nint pA, nint pD, double alpha = 1, double beta = 0)

Parameters

pA nint
pD nint
alpha double
beta double