sqrtGPU<T> function

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

Implementation

GPUTensor<T> sqrtGPU<T>(GPUTensor<T> a, CommandBuffer tape) {
  GPUTensor<T> out = GPUTensor<T>.empty(a.shape);

  tape.putInt(OP_SQRT_ELEMENTWISE);
  tape.putString(a.id);
  tape.putString(out.id);

  out.creator = GPUNode(
    <GPUTensor>[a],
        (CommandBuffer bTape) {
      // Sqrt backward optimizes perfectly by passing the OUT data instead of IN
      bTape.putInt(OP_SQRT_BACKWARD);
      bTape.putString('${out.id}_grad');
      bTape.putString(out.id);
      bTape.putString('${a.id}_grad');
    },
    opName: 'sqrtGPU',
  );

  return out;
}