flatten3DToMatrixGPU function
GPUTensor<Matrix>
flatten3DToMatrixGPU(
- GPUTensor<
Tensor3D> t, - CommandBuffer tape, {
- GPUTensor<
Matrix> ? outTensor,
Implementation
GPUTensor<Matrix> flatten3DToMatrixGPU(
GPUTensor<Tensor3D> t, CommandBuffer tape,
{GPUTensor<Matrix>? outTensor}) {
int c = t.shape[0];
int h = t.shape[1];
int w = t.shape[2];
int flatSize = c * h * w;
GPUTensor<Matrix> out =
outTensor ?? GPUTensor<Matrix>.empty(<int>[1, flatSize]);
tape.putInt(OP_COPY);
tape.putString(t.id);
tape.putString(out.id);
out.creator = GPUNode(
<GPUTensor>[t],
(CommandBuffer bTape) {
bTape.putInt(OP_ADD_INTO);
bTape.putString(out.gradId);
bTape.putString(t.gradId);
},
opName: 'flatten3DToMatrixGPU',
cost: 0,
);
return out;
}