selectRowGPU function

GPUTensor<Vector> selectRowGPU(
  1. GPUTensor<Matrix> m,
  2. int rowIndex,
  3. CommandBuffer tape
)

Implementation

GPUTensor<Vector> selectRowGPU(GPUTensor<Matrix> m, int rowIndex, CommandBuffer tape) {
  int numCols = m.shape[1];
  // Output is a vector of length numCols
  GPUTensor<Vector> out = GPUTensor<Vector>(List<double>.filled(numCols, 0.0));

  tape.putInt(OP_SLICE_ROW);
  tape.putString(m.id);
  tape.putString(out.id);
  tape.putInt(rowIndex);

  out.creator = GPUNode(
    [m],
        (CommandBuffer bTape) {
      bTape.putInt(OP_SLICE_ROW_BACKWARD);
      bTape.putString('${out.id}_grad');
      bTape.putString('${m.id}_grad');
      bTape.putInt(rowIndex);
    },
    opName: 'selectRowGPU',
    extraParams: {'rowIndex': rowIndex},
    cost: 0,
  );

  return out;
}