absGPU<T> function
Appends the commands for applying the abs(v) exponential function on every element of a to tape.
Implementation
GPUTensor<T> absGPU<T>(GPUTensor<T> a, CommandBuffer tape,
{GPUTensor<T>? outTensor}) {
// CORRECT: Inherits the exact shape from the input tensor (no 0-length tensors)
GPUTensor<T> out = outTensor ?? GPUTensor<T>.empty(a.shape);
tape.putInt(OP_ABS_ELEMENTWISE);
tape.putString(a.id);
tape.putString(out.id);
out.creator = GPUNode(
<GPUTensor>[a],
(CommandBuffer bTape) {
bTape.putInt(OP_ABS_BACKWARD);
bTape.putString(out.gradId);
bTape.putString(a.id);
bTape.putString(a.gradId);
},
opName: 'absGPU',
);
return out;
}