concatenateGPU function

GPUTensor<Vector> concatenateGPU(
  1. GPUTensor<Vector> a,
  2. GPUTensor<Vector> b,
  3. CommandBuffer tape
)

Implementation

GPUTensor<Vector> concatenateGPU(GPUTensor<Vector> a, GPUTensor<Vector> b, CommandBuffer tape) {
  int aLength = a.shape[0];
  int totalLength = aLength + b.shape[0];

  GPUTensor<Vector> out = GPUTensor<Vector>(List<double>.filled(totalLength, 0.0));

  tape.putInt(OP_CONCATENATE);
  tape.putString(a.id);
  tape.putString(b.id);
  tape.putString(out.id);
  tape.putInt(0);

  out.creator = GPUNode(
    [a, b],
        (CommandBuffer bTape) {
      bTape.putInt(OP_CONCATENATE_BACKWARD);
      bTape.putString(out.id);
      bTape.putString(a.id);
      bTape.putString(b.id);
      bTape.putInt(0);
      bTape.putInt(aLength);
    },
    opName: 'concat_vectorGPU',
    cost: 0,
  );

  return out;
}