public NDArray Dot(NDArray result, NDArray lhs, NDArray rhs) { var context = CudaHelpers.TSContextForTensor(lhs); if (lhs.DimensionCount == 1 && rhs.DimensionCount == 1) { return(CudaMatrixMulDot.Dot(context, result, lhs, rhs)); } else if (lhs.DimensionCount == 2 && (rhs.DimensionCount == 1 || rhs.PossibleVector)) { return(CudaMatrixMulMV.Mul_M_V(context, result, lhs, rhs.Ravel()).Reshape(lhs.Shape[0], 1)); } else if (lhs.DimensionCount == 2 && rhs.DimensionCount == 2) { return(CudaMatrixMulMM.Mul_M_M(context, result, lhs, rhs)); } else { throw new NotSupportedException(string.Format("Multiplication of {0}D with {1}D tensor is not supported")); } }
public Tensor Dot(Tensor result, Tensor lhs, Tensor rhs) { var context = CudaHelpers.TSContextForTensor(lhs); if (lhs.DimensionCount == 1 && rhs.DimensionCount == 1) { return(CudaMatrixMulDot.Dot(context, result, lhs, rhs)); } else if (lhs.DimensionCount == 2 && rhs.DimensionCount == 1) { return(CudaMatrixMulMV.Mul_M_V(context, result, lhs, rhs)); } else if (lhs.DimensionCount == 2 && rhs.DimensionCount == 2) { return(CudaMatrixMulMM.Mul_M_M(context, result, lhs, rhs)); } else { throw new NotSupportedException(string.Format("Multiplication of {0}D with {1}D tensor is not supported")); } }