concatenateGPU function
Appends two vectors a and b together in order a-b.
The operation is appended to tape for execution.
Implementation
GPUTensor<Vector> concatenateGPU(
GPUTensor<Vector> a, GPUTensor<Vector> b, CommandBuffer tape,
{GPUTensor<Vector>? outTensor}) {
int aLength = a.shape[0];
int totalLength = aLength + b.shape[0];
GPUTensor<Vector> out =
outTensor ?? 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.gradId);
bTape.putString(a.gradId);
bTape.putString(b.gradId);
bTape.putInt(0);
bTape.putInt(aLength);
},
opName: 'concat_vectorGPU',
cost: 0,
);
return out;
}