Align the representation of NodeId values with the FlatBuffers schema, which uses uint (u32) as the type, except for operator inputs and outputs where ints are used, with negative values representing missing optional inputs.
Since node IDs are in the range [0, i32::MAX] we can reserve higher values as a niche, making Option<NodeId> the same size as a NodeId.
Performance-wise the main function of interest is Graph::run_plan. Testing with GPT-2 which has 3.3K operations, the change appears to be a small win or neutral. The time spent in run_plan drops from ~3.2% of runtime to ~3.0%.
Align the representation of NodeId values with the FlatBuffers schema, which uses
uint
(u32) as the type, except for operator inputs and outputs whereint
s are used, with negative values representing missing optional inputs.Since node IDs are in the range
[0, i32::MAX]
we can reserve higher values as a niche, makingOption<NodeId>
the same size as aNodeId
.Performance-wise the main function of interest is
Graph::run_plan
. Testing with GPT-2 which has 3.3K operations, the change appears to be a small win or neutral. The time spent inrun_plan
drops from ~3.2% of runtime to ~3.0%.