reshape3DToMatrixGPU function

GPUTensor<Matrix> reshape3DToMatrixGPU(
  1. GPUTensor<Tensor3D> t,
  2. int rows,
  3. int cols,
  4. CommandBuffer tape, {
  5. GPUTensor<Matrix>? outTensor,
})

Implementation

GPUTensor<Matrix> reshape3DToMatrixGPU(
    GPUTensor<Tensor3D> t, int rows, int cols, CommandBuffer tape,
    {GPUTensor<Matrix>? outTensor}) {
  GPUTensor<Matrix> out =
      outTensor ?? GPUTensor<Matrix>.empty(<int>[rows, cols]);

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

  out.creator = GPUNode(
    <GPUTensor>[t],
    (CommandBuffer bTape) {
      bTape.putInt(OP_ADD_INTO);
      bTape.putString(out.gradId);
      bTape.putString(t.gradId);
    },
    opName: 'reshape3DToMatrixGPU',
    cost: 0,
  );

  return out;
}