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, IDisposableInheritance
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
extentAlong[]-
Sizes of the dimensions of A.
modeAint[]-
Mode labels of A.
extentDlong[]-
Sizes of the dimensions of D (and C).
modeDint[]-
Mode labels of D: a subset of
modeA. dataTypeTensorDataType-
Element type of all tensors. Default: float.
opReduceCuTensorOperator-
Reduction operator: NVMathNet.Interop.CuTensorOperator.Add, NVMathNet.Interop.CuTensorOperator.Mul, NVMathNet.Interop.CuTensorOperator.Max or NVMathNet.Interop.CuTensorOperator.Min.
opACuTensorOperator-
Unary operator applied to each element of A before reducing. Default: identity.
opCCuTensorOperator-
Unary operator applied to C. Default: identity.
optionsTensorContractionOptions?-
Options;
nulluses defaults. streamCudaStream?-
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
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
Returns
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
aDeviceBuffer<T>dDeviceBuffer<T>alphadoublebetadoublectCancellationToken
Returns
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)