concatenate3DGPU function
Appends two Tensor3Ds a and b together in order a-b.
The operation is appended to tape for execution.
Implementation
GPUTensor<Tensor3D> concatenate3DGPU(
GPUTensor<Tensor3D> a, GPUTensor<Tensor3D> b, CommandBuffer tape,
{GPUTensor<Tensor3D>? outTensor}) {
int aDepth = a.shape[0];
int bDepth = b.shape[0];
int totalDepth = aDepth + bDepth;
int height = a.shape[1];
int width = a.shape[2];
GPUTensor<Tensor3D> out =
outTensor ?? GPUTensor<Tensor3D>.empty([totalDepth, height, width]);
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(aDepth);
},
opName: 'concat_3dGPU',
cost: 0,
);
return out;
}