public class LibMatrixCUDA extends Object
| Modifier and Type | Field and Description |
|---|---|
static jcuda.jcublas.cublasHandle |
cublasHandle |
static jcuda.jcudnn.cudnnHandle |
cudnnHandle |
static jcuda.jcusparse.cusparseHandle |
cusparseHandle |
static JCudaKernels |
kernels |
| Constructor and Description |
|---|
LibMatrixCUDA() |
| Modifier and Type | Method and Description |
|---|---|
static void |
axpy(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in1,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in2,
String outputName,
double constant)
Performs daxpy operation
|
static void |
batchNormalizationBackward(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject scale,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject ret,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject retScale,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject retBias,
double epsilon)
This method computes the backpropagation errors for image, scale and bias of batch normalization layer
|
static void |
batchNormalizationForwardInference(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject scale,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject bias,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject runningMean,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject runningVar,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject ret,
double epsilon)
Performs the forward BatchNormalization layer computation for inference
|
static void |
batchNormalizationForwardTraining(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject scale,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject bias,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject runningMean,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject runningVar,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject ret,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject retRunningMean,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject retRunningVar,
double epsilon,
double exponentialAverageFactor)
Performs the forward BatchNormalization layer computation for training
|
static void |
biasAdd(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject input,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject bias,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock)
Performs the operation corresponding to the DML script:
ones = matrix(1, rows=1, cols=Hout*Wout)
output = input + matrix(bias %*% ones, rows=1, cols=F*Hout*Wout)
This operation is often followed by conv2d and hence we have introduced bias_add(input, bias) built-in function
|
static void |
biasMultiply(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject input,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject bias,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock)
Performs the operation corresponding to the DML script:
ones = matrix(1, rows=1, cols=Hout*Wout)
output = input * matrix(bias %*% ones, rows=1, cols=F*Hout*Wout)
This operation is often followed by conv2d and hence we have introduced bias_add(input, bias) built-in function
|
protected static void |
bothSparseMatmult(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject output,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject left,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject right,
boolean isLeftTransposed,
boolean isRightTransposed)
Sparse C = Sparse op(A) * Sparse op(B)
Reroutes call to sparse matrix-vector mult if needed
|
static void |
conv2d(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject filter,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock,
int N,
int C,
int H,
int W,
int K,
int R,
int S,
int pad_h,
int pad_w,
int stride_h,
int stride_w,
int P,
int Q) |
static void |
conv2dBackwardData(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject filter,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject output,
int N,
int C,
int H,
int W,
int K,
int R,
int S,
int pad_h,
int pad_w,
int stride_h,
int stride_w,
int P,
int Q)
This method computes the backpropogation errors for previous layer of convolution operation
|
static void |
conv2dBackwardFilter(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock,
int N,
int C,
int H,
int W,
int K,
int R,
int S,
int pad_h,
int pad_w,
int stride_h,
int stride_w,
int P,
int Q)
This method computes the backpropogation errors for filter of convolution operation
|
static void |
conv2dBiasAdd(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject bias,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject filter,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock,
int N,
int C,
int H,
int W,
int K,
int R,
int S,
int pad_h,
int pad_w,
int stride_h,
int stride_w,
int P,
int Q) |
protected static void |
denseDenseMatmult(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject output,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject left1,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject right1,
boolean isLeftTransposed1,
boolean isRightTransposed1)
Dense dense matrix multiply
C = op(A) * op(B), A and B are dense matrices
|
static void |
denseDenseMatmult(String instName,
jcuda.Pointer output,
int leftRows1,
int leftCols1,
int rightRows1,
int rightCols1,
boolean isLeftTransposed1,
boolean isRightTransposed1,
jcuda.Pointer leftPtr,
jcuda.Pointer rightPtr)
Dense-dense matrix multiply
C = op(A) * op(B), A and B are dense matrices
On the host, the matrices are in row-major format; cuBLAS expects them in column-major format.
|
protected static void |
denseSparseMatmult(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject output,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject right,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject left,
boolean isLeftTransposed,
boolean isRightTransposed,
int transA,
int transB,
int m,
int n,
int k)
C = op(A) * op(B) where A is dense and B is sparse
If B is ultrasparse, A is converted to a sparse matrix and
sparseSparseMatmult(MatrixObject, int, int, int, int, int, CSRPointer, CSRPointer) is invoked
otherwise B is converted to a dense matrix and denseDenseMatmult(Pointer, int, int, int, int, boolean, boolean, Pointer, Pointer) is invoked. |
protected static void |
eitherSparseMatmult(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject output,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject left,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject right,
boolean isLeftTransposed,
boolean isRightTransposed)
One of the matrices is sparse, the other dense
C = op(A) x op(B)
|
static void |
exp(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in1,
String outputName)
Performs an "exp" operation on a matrix on the GPU
|
static boolean |
isInSparseFormat(org.apache.sysml.runtime.controlprogram.caching.MatrixObject mo) |
static org.apache.sysml.runtime.controlprogram.caching.MatrixObject |
matmult(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject left1,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject right1,
String outputName,
boolean isLeftTransposed1,
boolean isRightTransposed1)
Matrix multiply on GPU
Examines sparsity and shapes and routes call to appropriate method
from cuBLAS or cuSparse
C = op(A) x op(B)
|
static void |
matmultTSMM(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject left,
String outputName,
boolean isLeftTransposed)
Performs tsmm, A %*% A' or A' %*% A, on GPU by exploiting cublasDsyrk(...)
|
static void |
matrixScalarArithmetic(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in1,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in2,
String outputName,
boolean isLeftTransposed,
boolean isRightTransposed,
org.apache.sysml.runtime.matrix.operators.BinaryOperator op)
Performs elementwise operation specified by op of two input matrices in1 and in2
|
static void |
matrixScalarArithmetic(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in,
String outputName,
boolean isInputTransposed,
org.apache.sysml.runtime.matrix.operators.ScalarOperator op)
Entry point to perform elementwise matrix-scalar operation specified by op
|
static void |
maxpooling(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock,
int N,
int C,
int H,
int W,
int K,
int R,
int S,
int pad_h,
int pad_w,
int stride_h,
int stride_w,
int P,
int Q)
performs maxpooling on GPU by exploiting cudnnPoolingForward(...)
|
static void |
maxpoolingBackward(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock,
int N,
int C,
int H,
int W,
int K,
int R,
int S,
int pad_h,
int pad_w,
int stride_h,
int stride_w,
int P,
int Q)
Performs maxpoolingBackward on GPU by exploiting cudnnPoolingBackward(...)
This method computes the backpropogation errors for previous layer of maxpooling operation
|
static void |
performMaxpooling(String instName,
jcuda.Pointer x,
jcuda.jcudnn.cudnnTensorDescriptor xDesc,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock,
int N,
int C,
int H,
int W,
int K,
int R,
int S,
int pad_h,
int pad_w,
int stride_h,
int stride_w,
int P,
int Q) |
static jcuda.Pointer |
pointerTo(double value) |
static void |
relu(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in,
String outputName)
Performs the relu operation on the GPU.
|
static void |
reluBackward(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject input,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock)
This method computes the backpropagation errors for previous layer of relu operation
|
static void |
reluMaxpooling(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject image,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock,
int N,
int C,
int H,
int W,
int K,
int R,
int S,
int pad_h,
int pad_w,
int stride_h,
int stride_w,
int P,
int Q)
performs relu followed by maxpooling on GPU by exploiting cudnnPoolingForward(...)
|
protected static void |
sparseDenseMatmult(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject output,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject left,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject right,
boolean isLeftTransposed,
boolean isRightTransposed,
int transA,
int transB,
int m,
int n,
int k)
* C = op(A) * op(B) where A is sparse and B is dense
If A is ultrasparse, B is converted to a sparse matrix and
sparseSparseMatmult(MatrixObject, int, int, int, int, int, CSRPointer, CSRPointer) is invoked
otherwise A is converted to a dense matrix and denseDenseMatmult(Pointer, int, int, int, int, boolean, boolean, Pointer, Pointer) is invoked. |
protected static void |
sparseMatrixDenseVectorMult(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject output,
JCudaObject.CSRPointer A,
jcuda.Pointer B_dense,
int transA,
int m,
int k)
C = op(A) x B
A is a sparse matrix, B is a dense vector
|
protected static void |
sparseMatrixVectorMult(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject output,
int transA,
int m,
int n,
int k,
JCudaObject.CSRPointer A,
JCudaObject.CSRPointer B)
Does a sparse matrix-vector multiply.
|
protected static void |
sparseSparseMatmult(String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject output,
int transA,
int transB,
int m,
int n,
int k,
JCudaObject.CSRPointer A,
JCudaObject.CSRPointer B)
Does a sparse-sparse Matrix multiply
C = op(A) x op(B), A, B are sparse matrices
|
static void |
transpose(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in,
String outputName)
Transposes the input matrix using cublasDgeam
|
static void |
unaryAggregate(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in1,
String output,
org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator op)
Entry point to perform Unary aggregate operations on the GPU.
|
public static jcuda.jcudnn.cudnnHandle cudnnHandle
public static jcuda.jcublas.cublasHandle cublasHandle
public static jcuda.jcusparse.cusparseHandle cusparseHandle
public static JCudaKernels kernels
public static boolean isInSparseFormat(org.apache.sysml.runtime.controlprogram.caching.MatrixObject mo)
public static void conv2dBiasAdd(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, org.apache.sysml.runtime.controlprogram.caching.MatrixObject bias, org.apache.sysml.runtime.controlprogram.caching.MatrixObject filter, org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock, int N, int C, int H, int W, int K, int R, int S, int pad_h, int pad_w, int stride_h, int stride_w, int P, int Q) throws DMLRuntimeException
DMLRuntimeExceptionpublic static void conv2d(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, org.apache.sysml.runtime.controlprogram.caching.MatrixObject filter, org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock, int N, int C, int H, int W, int K, int R, int S, int pad_h, int pad_w, int stride_h, int stride_w, int P, int Q) throws DMLRuntimeException
DMLRuntimeExceptionpublic static jcuda.Pointer pointerTo(double value)
public static void reluBackward(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject input, org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout, org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock) throws DMLRuntimeException
instName - the invoking instruction's name for record Statistics.input - input imagedout - next layer error propogationoutputBlock - outputDMLRuntimeException - if DMLRuntimeException occurspublic static void biasMultiply(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject input, org.apache.sysml.runtime.controlprogram.caching.MatrixObject bias, org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock) throws DMLRuntimeException
instName - the invoking instruction's name for record Statistics.input - input imagebias - biasoutputBlock - outputDMLRuntimeException - if DMLRuntimeException occurspublic static void biasAdd(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject input, org.apache.sysml.runtime.controlprogram.caching.MatrixObject bias, org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock) throws DMLRuntimeException
instName - the invoking instruction's name for record Statistics.input - input imagebias - biasoutputBlock - outputDMLRuntimeException - if DMLRuntimeException occurspublic static void batchNormalizationForwardInference(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, org.apache.sysml.runtime.controlprogram.caching.MatrixObject scale, org.apache.sysml.runtime.controlprogram.caching.MatrixObject bias, org.apache.sysml.runtime.controlprogram.caching.MatrixObject runningMean, org.apache.sysml.runtime.controlprogram.caching.MatrixObject runningVar, org.apache.sysml.runtime.controlprogram.caching.MatrixObject ret, double epsilon) throws DMLRuntimeException
instName - name of the instructionimage - input imagescale - scale (as per CuDNN) and gamma as per original paper: shape [1, C, 1, 1]bias - bias (as per CuDNN) and beta as per original paper: shape [1, C, 1, 1]runningMean - running mean accumulated during training phase: shape [1, C, 1, 1]runningVar - running variance accumulated during training phase: shape [1, C, 1, 1]ret - normalized inputepsilon - epsilon value used in the batch normalization formulaDMLRuntimeException - if error occurspublic static void batchNormalizationForwardTraining(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, org.apache.sysml.runtime.controlprogram.caching.MatrixObject scale, org.apache.sysml.runtime.controlprogram.caching.MatrixObject bias, org.apache.sysml.runtime.controlprogram.caching.MatrixObject runningMean, org.apache.sysml.runtime.controlprogram.caching.MatrixObject runningVar, org.apache.sysml.runtime.controlprogram.caching.MatrixObject ret, org.apache.sysml.runtime.controlprogram.caching.MatrixObject retRunningMean, org.apache.sysml.runtime.controlprogram.caching.MatrixObject retRunningVar, double epsilon, double exponentialAverageFactor) throws DMLRuntimeException
instName - name of the instructionimage - input imagescale - scale (as per CuDNN) and gamma as per original paper: shape [1, C, 1, 1]bias - bias (as per CuDNN) and beta as per original paper: shape [1, C, 1, 1]runningMean - running mean accumulated during training phase: shape [1, C, 1, 1]runningVar - running variance accumulated during training phase: shape [1, C, 1, 1]ret - (output) normalized inputretRunningMean - (output) running mean accumulated during training phase: shape [1, C, 1, 1]retRunningVar - (output) running variance accumulated during training phase: shape [1, C, 1, 1]epsilon - epsilon value used in the batch normalization formulaexponentialAverageFactor - factor used in the moving average computationDMLRuntimeException - if error occurspublic static void batchNormalizationBackward(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout, org.apache.sysml.runtime.controlprogram.caching.MatrixObject scale, org.apache.sysml.runtime.controlprogram.caching.MatrixObject ret, org.apache.sysml.runtime.controlprogram.caching.MatrixObject retScale, org.apache.sysml.runtime.controlprogram.caching.MatrixObject retBias, double epsilon) throws DMLRuntimeException
instName - name of the instructionimage - input imagedout - input errors of shape C, H, Wscale - scale (as per CuDNN) and gamma as per original paper: shape [1, C, 1, 1]ret - (output) backpropagation errors for previous layerretScale - backpropagation error for scaleretBias - backpropagation error for biasepsilon - epsilon value used in the batch normalization formulaDMLRuntimeException - if error occurspublic static void conv2dBackwardFilter(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout, org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock, int N, int C, int H, int W, int K, int R, int S, int pad_h, int pad_w, int stride_h, int stride_w, int P, int Q) throws DMLRuntimeException
instName - the invoking instruction's name for record Statistics.image - input imagedout - errors from next layeroutputBlock - output errorsN - number of imagesC - number of channelsH - heightW - widthK - number of filtersR - filter heightS - filter widthpad_h - pad heightpad_w - pad widthstride_h - stride heightstride_w - stride widthP - output activation heightQ - output activation widthDMLRuntimeException - if DMLRuntimeException occurspublic static void conv2dBackwardData(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject filter, org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout, org.apache.sysml.runtime.controlprogram.caching.MatrixObject output, int N, int C, int H, int W, int K, int R, int S, int pad_h, int pad_w, int stride_h, int stride_w, int P, int Q) throws DMLRuntimeException
instName - the invoking instruction's name for record Statistics.filter - filter used in conv2ddout - errors from next layeroutput - output errorsN - number of imagesC - number of channelsH - heightW - widthK - number of filtersR - filter heightS - filter widthpad_h - pad heightpad_w - pad widthstride_h - stride heightstride_w - stride widthP - output activation heightQ - output activation widthDMLRuntimeException - if DMLRuntimeException occurspublic static void maxpooling(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock, int N, int C, int H, int W, int K, int R, int S, int pad_h, int pad_w, int stride_h, int stride_w, int P, int Q) throws DMLRuntimeException
instName - the invoking instruction's name for record Statistics.image - image as matrix objectoutputBlock - output matrixN - batch sizeC - number of channelsH - height of imageW - width of imageK - number of filtersR - height of filterS - width of filterpad_h - vertical paddingpad_w - horizontal paddingstride_h - horizontal stridestride_w - vertical strideP - (H - R + 1 + 2*pad_h)/stride_hQ - (W - S + 1 + 2*pad_w)/stride_wDMLRuntimeException - if DMLRuntimeException occurspublic static void performMaxpooling(String instName, jcuda.Pointer x, jcuda.jcudnn.cudnnTensorDescriptor xDesc, org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock, int N, int C, int H, int W, int K, int R, int S, int pad_h, int pad_w, int stride_h, int stride_w, int P, int Q) throws DMLRuntimeException
DMLRuntimeExceptionpublic static void reluMaxpooling(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock, int N, int C, int H, int W, int K, int R, int S, int pad_h, int pad_w, int stride_h, int stride_w, int P, int Q) throws DMLRuntimeException
instName - the invoking instruction's name for record Statistics.image - image as matrix objectoutputBlock - output matrixN - batch sizeC - number of channelsH - height of imageW - width of imageK - number of filtersR - height of filterS - width of filterpad_h - vertical paddingpad_w - horizontal paddingstride_h - horizontal stridestride_w - vertical strideP - (H - R + 1 + 2*pad_h)/stride_hQ - (W - S + 1 + 2*pad_w)/stride_wDMLRuntimeException - if DMLRuntimeException occurspublic static void maxpoolingBackward(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject image, org.apache.sysml.runtime.controlprogram.caching.MatrixObject dout, org.apache.sysml.runtime.controlprogram.caching.MatrixObject outputBlock, int N, int C, int H, int W, int K, int R, int S, int pad_h, int pad_w, int stride_h, int stride_w, int P, int Q) throws DMLRuntimeException
instName - the invoking instruction's name for record Statistics.image - image as matrix objectdout - delta matrix, output of previous layeroutputBlock - output matrixN - batch sizeC - number of channelsH - height of imageW - width of imageK - number of filtersR - height of filterS - width of filterpad_h - vertical paddingpad_w - horizontal paddingstride_h - horizontal stridestride_w - vertical strideP - (H - R + 1 + 2*pad_h)/stride_hQ - (W - S + 1 + 2*pad_w)/stride_wDMLRuntimeException - if DMLRuntimeException occurspublic static void relu(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in,
String outputName)
throws DMLRuntimeException
ec - currently active ExecutionContextinstName - the invoking instruction's name for record Statistics.in - input matrixoutputName - name of the output matrixDMLRuntimeException - if an error occurspublic static void matmultTSMM(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject left,
String outputName,
boolean isLeftTransposed)
throws DMLRuntimeException
ec - execution contextinstName - the invoking instruction's name for record Statistics.left - input matrix, as in a tsmm expression like A %*% A' or A' %*% A, we just need to check whether the left one is transposed or not, I named it 'left'outputName - output matrix nameisLeftTransposed - if true, left transposedDMLRuntimeException - if DMLRuntimeException occurspublic static org.apache.sysml.runtime.controlprogram.caching.MatrixObject matmult(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject left1,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject right1,
String outputName,
boolean isLeftTransposed1,
boolean isRightTransposed1)
throws DMLRuntimeException
ec - Current ExecutionContext instanceinstName - name of the invoking instruction to recordStatistics.left1 - Matrix Aright1 - Matrix BoutputName - Name of the output matrix C (in code generated after LOP layer)isLeftTransposed1 - op for A, transposed or notisRightTransposed1 - op for B, tranposed or notDMLRuntimeException - if DMLRuntimeException occursprotected static void eitherSparseMatmult(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject output, org.apache.sysml.runtime.controlprogram.caching.MatrixObject left, org.apache.sysml.runtime.controlprogram.caching.MatrixObject right, boolean isLeftTransposed, boolean isRightTransposed) throws DMLRuntimeException
instName - the invoking instruction's name for record Statistics.output - allocated output object for C on host to which GPU output will be attachedleft - Matrix A on hostright - Matrix B on hostisLeftTransposed - op for A, tranposed or notisRightTransposed - op for B, transposed or notDMLRuntimeException - if DMLRuntimeException occursprotected static void denseSparseMatmult(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject output, org.apache.sysml.runtime.controlprogram.caching.MatrixObject right, org.apache.sysml.runtime.controlprogram.caching.MatrixObject left, boolean isLeftTransposed, boolean isRightTransposed, int transA, int transB, int m, int n, int k) throws DMLRuntimeException
sparseSparseMatmult(MatrixObject, int, int, int, int, int, CSRPointer, CSRPointer) is invoked
otherwise B is converted to a dense matrix and denseDenseMatmult(Pointer, int, int, int, int, boolean, boolean, Pointer, Pointer) is invoked.instName - the invoking instruction's name for record Statistics.output - ?right - ?left - ?isLeftTransposed - ?isRightTransposed - ?transA - ?transB - ?m - ?n - ?k - ?DMLRuntimeException - if DMLRuntimeException occursprotected static void sparseDenseMatmult(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject output, org.apache.sysml.runtime.controlprogram.caching.MatrixObject left, org.apache.sysml.runtime.controlprogram.caching.MatrixObject right, boolean isLeftTransposed, boolean isRightTransposed, int transA, int transB, int m, int n, int k) throws DMLRuntimeException
sparseSparseMatmult(MatrixObject, int, int, int, int, int, CSRPointer, CSRPointer) is invoked
otherwise A is converted to a dense matrix and denseDenseMatmult(Pointer, int, int, int, int, boolean, boolean, Pointer, Pointer) is invoked.instName - the invoking instruction's name for record Statistics.output - ?left - ?right - ?isLeftTransposed - ?isRightTransposed - ?transA - ?transB - ?m - ?n - ?k - ?DMLRuntimeException - if DMLRuntimeException occursprotected static void sparseMatrixDenseVectorMult(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject output, JCudaObject.CSRPointer A, jcuda.Pointer B_dense, int transA, int m, int k) throws DMLRuntimeException
instName - the invoking instruction's name for record Statistics.output - allocated output on the host, to which the GPU output C will be attachedA - sparse matrix A on the GPUB_dense - dense matrix/vector B on the GPUtransA - op for A, tranposed or notm - number of rows in A (not op(A))k - number of cols in A or number of rows in B (not op(A) or op(B))DMLRuntimeException - if DMLRuntimeException occursprotected static void bothSparseMatmult(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject output, org.apache.sysml.runtime.controlprogram.caching.MatrixObject left, org.apache.sysml.runtime.controlprogram.caching.MatrixObject right, boolean isLeftTransposed, boolean isRightTransposed) throws DMLRuntimeException
instName - the invoking instruction's name for record Statistics.output - ?instName - name of the invoking instruction to recordStatistics.left - ?right - ?isLeftTransposed - ?isRightTransposed - ?DMLRuntimeException - if DMLRuntimeException occursprotected static void sparseMatrixVectorMult(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject output, int transA, int m, int n, int k, JCudaObject.CSRPointer A, JCudaObject.CSRPointer B) throws DMLRuntimeException
instName - the invoking instruction's name for record Statistics.output - allocated output object C to which the GPU output matrix will be attachedtransA - if A is to be transposed or not (the op in op(A))m - number of rows in A (not op(A))n - number of cols in A (not op(A))k - number of rows in B, (cols in B is assumed to be 1)A - left sparse matrix on GPUB - right sparse vector on GPUDMLRuntimeException - if DMLRuntimeException occursprotected static void sparseSparseMatmult(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject output, int transA, int transB, int m, int n, int k, JCudaObject.CSRPointer A, JCudaObject.CSRPointer B) throws DMLRuntimeException
instName - the invoking instruction's name for record Statistics.output - allocated output object on host to which the GPU output matrix will be attachedtransA - op for A - to be transposed or nottransB - op for Bm - number of rows in op(A)n - number of cols in op(B)k - number of cols in op(A) or rows in op(B)A - left sparse matrix on GPUB - right sparse matrix on GPUDMLRuntimeException - if DMLRuntimeException occursprotected static void denseDenseMatmult(String instName, org.apache.sysml.runtime.controlprogram.caching.MatrixObject output, org.apache.sysml.runtime.controlprogram.caching.MatrixObject left1, org.apache.sysml.runtime.controlprogram.caching.MatrixObject right1, boolean isLeftTransposed1, boolean isRightTransposed1) throws DMLRuntimeException
instName - name of the invoking instruction to recordStatistics.output - output object C on host with GPU data allocatedleft1 - left matrix A on host (in row-major order)right1 - right matrix B on host (in row-major order)isLeftTransposed1 - op for A, transposed or notisRightTransposed1 - op for B, transposed or notDMLRuntimeException - if DMLRuntimeException occurspublic static void denseDenseMatmult(String instName, jcuda.Pointer output, int leftRows1, int leftCols1, int rightRows1, int rightCols1, boolean isLeftTransposed1, boolean isRightTransposed1, jcuda.Pointer leftPtr, jcuda.Pointer rightPtr) throws DMLRuntimeException
instName - name of the invoking instruction to recordStatistics.output - output allocated on GPU in column major formatleftRows1 - number of rows in AleftCols1 - number of cols in ArightRows1 - number of rows in BrightCols1 - number of cols in BisLeftTransposed1 - op for A, transposed or notisRightTransposed1 - op for B, transposed or notleftPtr - A allocated on the GPU in row-major formatrightPtr - B allocated on the GPU in row-major formatDMLRuntimeException - if DMLRuntimeException occurspublic static void unaryAggregate(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in1,
String output,
org.apache.sysml.runtime.matrix.operators.AggregateUnaryOperator op)
throws DMLRuntimeException
ec - Instance of ExecutionContext, from which the output variable will be allocatedinstName - name of the invoking instruction to recordStatistics.in1 - input matrixoutput - output matrix/scalar nameop - Instance of AggregateUnaryOperator which encapsulates the direction of reduction/aggregation and the reduction operation.DMLRuntimeException - if DMLRuntimeException occurspublic static void matrixScalarArithmetic(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in,
String outputName,
boolean isInputTransposed,
org.apache.sysml.runtime.matrix.operators.ScalarOperator op)
throws DMLRuntimeException
ec - execution contextinstName - the invoking instruction's name for record Statistics.in - input matrixoutputName - output matrix nameisInputTransposed - true if input transposedop - scalar operatorDMLRuntimeException - if DMLRuntimeException occurspublic static void matrixScalarArithmetic(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in1,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in2,
String outputName,
boolean isLeftTransposed,
boolean isRightTransposed,
org.apache.sysml.runtime.matrix.operators.BinaryOperator op)
throws DMLRuntimeException
ec - execution contextinstName - the invoking instruction's name for record Statistics.in1 - input matrix 1in2 - input matrix 2outputName - output matrix nameisLeftTransposed - true if left-transposedisRightTransposed - true if right-transposedop - binary operatorDMLRuntimeException - if DMLRuntimeException occurspublic static void transpose(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in,
String outputName)
throws DMLRuntimeException
ec - execution contextinstName - the invoking instruction's name for record Statistics.in - input matrixoutputName - output matrix nameDMLRuntimeException - if DMLRuntimeException occurspublic static void exp(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in1,
String outputName)
throws DMLRuntimeException
ec - execution contextinstName - the invoking instruction's name for record Statistics.in1 - input matrixoutputName - output matrix nameDMLRuntimeException - if DMLRuntimeException occurspublic static void axpy(org.apache.sysml.runtime.controlprogram.context.ExecutionContext ec,
String instName,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in1,
org.apache.sysml.runtime.controlprogram.caching.MatrixObject in2,
String outputName,
double constant)
throws DMLRuntimeException
ec - execution contextinstName - the invoking instruction's name for record Statistics.in1 - input matrix 1in2 - input matrix 2outputName - output matrix nameconstant - pointer constantDMLRuntimeException - if DMLRuntimeException occursCopyright © 2017 The Apache Software Foundation. All rights reserved.