reshapeMatrixTo3DGPU function

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

Implementation

GPUTensor<Tensor3D> reshapeMatrixTo3DGPU(GPUTensor<Matrix> m, int c, int h, int w, CommandBuffer tape) {
  GPUTensor<Tensor3D> out = 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.id}_grad');
      bTape.putString('${m.id}_grad');
    },
    opName: 'reshapeMatrixTo3DGPU',
    cost: 0,
  );

  return out;
}