Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions tutorials/machine_learning/TMVA_SOFIE_GNN.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@
##
## \author

import cppyy
import time

import numpy as np
import ROOT
import torch
import torch.nn as nn

Check failure on line 22 in tutorials/machine_learning/TMVA_SOFIE_GNN.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (I001)

tutorials/machine_learning/TMVA_SOFIE_GNN.py:16:1: I001 Import block is un-sorted or un-formatted help: Organize imports

# defining graph properties
num_nodes = 5
Expand Down Expand Up @@ -200,6 +201,9 @@

receivers = np.ascontiguousarray(graphData["receivers"], dtype=np.int64)
senders = np.ascontiguousarray(graphData["senders"], dtype=np.int64)
i64p = cppyy.ll.cast["const int64_t*"]
receivers_ptr = i64p(receivers.ctypes.data)
senders_ptr = i64p(senders.ctypes.data)

latent = self._as_arrays(
self.encoder_session.infer(c(graphData["nodes"]), c(graphData["edges"]), c(graphData["globals"])),
Expand All @@ -210,8 +214,8 @@
for _ in range(processing_steps):
core_input = tuple(np.concatenate([a, b], axis=1) for a, b in zip(latent0, latent))
latent = self._as_arrays(
self.core_session.infer(c(core_input[0]), c(core_input[1]), c(core_input[2]), receivers, senders),
n_nodes, n_edges,
self.core_session.infer(c(core_input[0]), c(core_input[1]), c(core_input[2]), receivers_ptr, senders_ptr),
n_nodes, n_edges,
)
decoded = self._as_arrays(
self.decoder_session.infer(c(latent[0]), c(latent[1]), c(latent[2])), n_nodes, n_edges
Expand Down
Loading