clipGradValueGPU function

void clipGradValueGPU(
  1. GPUTensor tensor,
  2. double clipValue,
  3. CommandBuffer tape
)

Performs an in place update of the provided data values by clipping them in between the intervall (-clipValue)-(clipValue). The operation is appended to tape for execution.

Implementation

void clipGradValueGPU(
    GPUTensor<dynamic> tensor, double clipValue, CommandBuffer tape) {
  tape.putInt(OP_CLIP_GRAD_VALUE);
  // Usually applied directly to the gradients before the optimizer step
  tape.putString(tensor.gradId);
  tape.putFloat(clipValue);
}