GPUNode constructor
A GPUNode connects different GPUTensor together. In contrast to Node GPUNodes are used to generate a CommandBuffer creating a runnable list of mathematical functions. GPUNodes create a directed acyclical graph structure and each GPUNode can be viewed as functions holding reference to its input GPUTensors.
opName is used to give a function a recognisable name for debugging and traceability.
extraParams allows to store additional arguments fe. an integer describing recursive depth used in the function.
The additional parameter for the backwards function is for the writing of the operation to the backwards CommandBuffer.
GPUNodes are mostly used within the creation and coupling of GPUTensor and may not be required unless explicitly defining new functions.
Example:
out.creator = GPUNode(
<GPUTensor>[a, b],
(CommandBuffer bTape) {
bTape.putInt(OP_ADD_INTO);
bTape.putString('${out.id}_grad');
bTape.putString('${a.id}_grad');
bTape.putInt(OP_ADD_INTO);
bTape.putString('${out.id}_grad');
bTape.putString('${b.id}_grad');
},
opName: 'addGPU',
);
Implementation
GPUNode(
this.inputs,
this.backwardFn, {
this.opName = 'op',
this.cost = 0,
this.extraParams = const {},
});