powGPU<T> function

GPUTensor<T> powGPU<T>(
  1. GPUTensor<T> a,
  2. double exponent,
  3. CommandBuffer tape, {
  4. GPUTensor<T>? outTensor,
})

Appends the commands for applying pow(v,exponent) exponential function on every element of v to tape.

Implementation

GPUTensor<T> powGPU<T>(GPUTensor<T> a, double exponent, CommandBuffer tape,
    {GPUTensor<T>? outTensor}) {
  GPUTensor<T> out = outTensor ?? GPUTensor<T>.empty(a.shape);

  tape.putInt(OP_POW_ELEMENTWISE);
  tape.putString(a.id);
  tape.putString(out.id);
  tape.putFloat(exponent);

  out.creator = GPUNode(
    <GPUTensor>[a],
    (CommandBuffer bTape) {
      bTape.putInt(OP_POW_BACKWARD);
      bTape.putString(out.gradId);
      bTape.putString(a.id);
      bTape.putString(a.gradId);
      bTape.putFloat(exponent);
    },
    opName: 'powGPU',
  );

  return out;
}