elementWiseMultiplyMatrixGPU function
GPUTensor<Matrix>
elementWiseMultiplyMatrixGPU(
- GPUTensor<
Matrix> a, - GPUTensor<
Matrix> b, - CommandBuffer tape
Implementation
GPUTensor<Matrix> elementWiseMultiplyMatrixGPU(GPUTensor<Matrix> a, GPUTensor<Matrix> b, CommandBuffer tape) {
int numRows = a.shape[0];
int numCols = a.shape[1];
GPUTensor<Matrix> out = GPUTensor<Matrix>.empty([numRows, numCols]);
tape.putInt(OP_MULTIPLY);
tape.putString(a.id);
tape.putString(b.id);
tape.putString(out.id);
out.creator = GPUNode(
[a, b],
(CommandBuffer bTape) {
bTape.putInt(OP_MULTIPLY_BACKWARD);
bTape.putString('${out.id}_grad');
bTape.putString(b.id);
bTape.putString('${a.id}_grad');
bTape.putInt(OP_MULTIPLY_BACKWARD);
bTape.putString('${out.id}_grad');
bTape.putString(a.id);
bTape.putString('${b.id}_grad');
},
opName: 'multiply_matrixGPU',
cost: numRows * numCols,
);
return out;
}