selectRowGPU function
Extracts a single row out of a matrix m given by rowIndex.
The operation is appended to tape for execution.
Implementation
GPUTensor<Vector> selectRowGPU(
GPUTensor<Matrix> m, int rowIndex, CommandBuffer tape,
{GPUTensor<Vector>? outTensor}) {
int numCols = m.shape[1];
// Output is a vector of length numCols
GPUTensor<Vector> out =
outTensor ?? GPUTensor<Vector>(List<double>.filled(numCols, 0.0));
tape.putInt(OP_SLICE_ROW);
tape.putString(m.id);
tape.putString(out.id);
tape.putInt(rowIndex);
out.creator = GPUNode(
[m],
(CommandBuffer bTape) {
bTape.putInt(OP_SLICE_ROW_BACKWARD);
bTape.putString(out.gradId);
bTape.putString(m.gradId);
bTape.putInt(rowIndex);
},
opName: 'selectRowGPU',
extraParams: {'rowIndex': rowIndex},
cost: 0,
);
return out;
}