public static void Einsum(Tensor D, Tensor A, string modeA, Tensor B, string modeB, Tensor C, string modeC, double alpha = 1f, double beta = 0f) { int[] mA = new int[modeA.Length]; int[] mB = new int[modeB.Length]; int[] mC = new int[modeC.Length]; for (int i = 0; i < mA.Length; i++) { mA[i] = modeA[i]; } for (int i = 0; i < mB.Length; i++) { mB[i] = modeB[i]; } for (int i = 0; i < mC.Length; i++) mC[i] = modeC[i]; fixed(int *ptrmA = mA, ptrmB = mB, ptrmC = mC) fixed(long *DimensionsA = A.Shape.Dimensions, MultipliedA = A.Shape.Multiplied, DimensionsB = B.Shape.Dimensions, MultipliedB = B.Shape.Multiplied, DimensionsC = C.Shape.Dimensions, MultipliedC = C.Shape.Multiplied, DimensionsD = D.Shape.Dimensions, MultipliedD = D.Shape.Multiplied) CudaKernels.Einsum( A.Base.Array, A.Shape.N, ptrmA, DimensionsA, MultipliedA + 1, CudaTypes.GetDataType(A), B.Base.Array, B.Shape.N, ptrmB, DimensionsB, MultipliedB + 1, CudaTypes.GetDataType(B), C.Base.Array, C.Shape.N, ptrmC, DimensionsC, MultipliedC + 1, CudaTypes.GetDataType(C), D.Base.Array, D.Shape.N, ptrmC, DimensionsD, MultipliedD + 1, CudaTypes.GetDataType(D), alpha, beta, CudaTypes.GetComputeType(C)); }
public static void MultiplyFloat32(Tensor res, Tensor a, Tensor b, float cofmul = 1, float cofadd = 0) { CudaManagement.SetDevice(res.Config.Device.ID); CudaKernels.MultiplyFloat32((float *)res.Base.Array, (float *)a.Base.Array, (float *)b.Base.Array, a.Shape.TotalSize, b.Shape.TotalSize, cofmul, cofadd); }