absGPU<T> function

GPUTensor<T> absGPU<T>(
  1. GPUTensor<T> a,
  2. CommandBuffer tape
)

Implementation

GPUTensor<T> absGPU<T>(GPUTensor<T> a, CommandBuffer tape) {
  // CORRECT: Inherits the exact shape from the input tensor (no 0-length tensors)
  GPUTensor<T> out = 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.id}_grad');
      bTape.putString(a.id);
      bTape.putString('${a.id}_grad');
    },
    opName: 'absGPU',
  );

  return out;
}