Commit 692a1ed
committed
[tutorials] Migrate the SOFIE GNN tutorials to PyTorch and ONNX
The SOFIE GNN tutorials defined their model with DeepMind graph_nets and
dm-sonnet, whose last releases date from 2020 and which cannot be
installed together with current Python and TensorFlow versions anymore.
Define the same model with plain PyTorch instead: an
Encode-Process-Decode graph network with the identical architecture
(graph-network blocks following Battaglia et al., arXiv:1806.01261,
with 4-layer ReLU MLP update functions, LayerNorm in the core network
and summation aggregation). The components are exported to ONNX with
the torch.export-based exporter and the inference code is generated
with the SOFIE ONNX parser, so the GNN-specific SOFIE classes and the
graph_nets parser are no longer involved.
The graph-network block maps onto standard ONNX operators: Gemm+Relu,
Concat, Gather of the sender/receiver node features,
ScatterElements(reduction=add) for the edge aggregation (the equivalent
of unsorted_segment_sum), ReduceSum and LayerNormalization.
- TMVA_SOFIE_GNN.py validates the generated inference against PyTorch
(agreement at float32 precision) and compares the execution times.
- TMVA_SOFIE_GNN_Parser.py exports the model with dynamic node and edge
counts, generates the inference code and writes variable-sized input
graphs plus PyTorch reference results to a ROOT file.
- TMVA_SOFIE_GNN_Application.C evaluates the generated code in C++ on
that file, like before, now with the ONNX-generated session interface.
The tutorials are now gated on the torch and onnx Python modules
instead of sonnet and graph_nets.
🤖 Done with the help of AI1 parent 0eeb284 commit 692a1ed
4 files changed
Lines changed: 463 additions & 573 deletions
File tree
- tutorials
- machine_learning
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
360 | | - | |
361 | | - | |
362 | 360 | | |
363 | 361 | | |
364 | 362 | | |
| |||
380 | 378 | | |
381 | 379 | | |
382 | 380 | | |
383 | | - | |
| 381 | + | |
| 382 | + | |
384 | 383 | | |
385 | 384 | | |
386 | 385 | | |
| |||
683 | 682 | | |
684 | 683 | | |
685 | 684 | | |
686 | | - | |
| 685 | + | |
687 | 686 | | |
688 | 687 | | |
689 | 688 | | |
| |||
0 commit comments