reshapeVectorToMatrixGPU function

GPUTensor<Matrix> reshapeVectorToMatrixGPU(
  1. GPUTensor<Vector> v,
  2. int numRows,
  3. int numCols,
  4. CommandBuffer tape, {
  5. GPUTensor<Matrix>? outTensor,
})

///////////////////////////////// Data management (0-99) /// /////////////////////////////////

Implementation

GPUTensor<Matrix> reshapeVectorToMatrixGPU(
    GPUTensor<Vector> v, int numRows, int numCols, CommandBuffer tape,
    {GPUTensor<Matrix>? outTensor}) {
  GPUTensor<Matrix> out =
      outTensor ?? GPUTensor<Matrix>.empty(<int>[numRows, numCols]);

  tape.putInt(OP_COPY);
  tape.putString(v.id);
  tape.putString(out.id);

  out.creator = GPUNode(
    [v],
    (CommandBuffer bTape) {
      bTape.putInt(OP_ADD_INTO);
      bTape.putString(out.gradId);
      bTape.putString(v.gradId);
    },
    opName: 'reshapeGPU',
    extraParams: {'numRows': numRows, 'numCols': numCols},
    cost: 0,
  );

  return out;
}