reshapeMatrixTo3DGPU function

GPUTensor<Tensor3D> reshapeMatrixTo3DGPU(
  1. GPUTensor<Matrix> m,
  2. int c,
  3. int h,
  4. int w,
  5. CommandBuffer tape, {
  6. GPUTensor<Tensor3D>? outTensor,
})

Implementation

GPUTensor<Tensor3D> reshapeMatrixTo3DGPU(
    GPUTensor<Matrix> m, int c, int h, int w, CommandBuffer tape,
    {GPUTensor<Tensor3D>? outTensor}) {
  GPUTensor<Tensor3D> out =
      outTensor ?? GPUTensor<Tensor3D>.empty(<int>[c, h, w]);

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

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

  return out;
}