multiplyGPU<T> function
GPUTensor<T>
multiplyGPU<T>(
- GPUTensor<
T> a, - GPUTensor<
T> b, - CommandBuffer tape, {
- GPUTensor<
T> ? outTensor,
Appends the commands for element wise multiplication of two GPUTensors a and b of type T to tape.
Creates and allocates a Tensor to store the results.
Implementation
GPUTensor<T> multiplyGPU<T>(GPUTensor<T> a, GPUTensor<T> b, CommandBuffer tape,
{GPUTensor<T>? outTensor}) {
GPUTensor<T> out = outTensor ?? GPUTensor<T>.empty(a.shape);
tape.putInt(OP_MULTIPLY);
tape.putString(a.id);
tape.putString(b.id);
tape.putString(out.id);
out.creator = GPUNode(
<GPUTensor>[a, b],
(CommandBuffer bTape) {
bTape.putInt(OP_MULTIPLY_BACKWARD);
bTape.putString(out.gradId);
bTape.putString(b.id);
bTape.putString(a.gradId);
bTape.putInt(OP_MULTIPLY_BACKWARD);
bTape.putString(out.gradId);
bTape.putString(a.id);
bTape.putString(b.gradId);
},
opName: 'multiplyGPU',
cost: 1,
);
return out;
}