26@contextlib.contextmanager
28 """Silence a known third-party warning and raise if it stops firing.
30 Notifies us to drop the workaround once the upstream library is fixed.
43 f
"Expected {category.__name__} containing {message!r} was not "
44 "emitted. This tutorial's workaround can probably be removed."
72 modelFile = modelName +
".onnx"
83 input_names=[
"input"],
84 output_names=[
"output"],
88 print(
"calling torch.onnx.export with parameters", kwargs)
94 with expect_warning(FutureWarning,
"isinstance(treespec, LeafSpec)"):
96 print(
"model exported to ONNX as", modelFile)
99 print(
"Cannot export model from pytorch to ONNX - with version ",
torch.__version__)
100 print(
"Skip tutorial execution")
113 print(
"0weight", data)
115 print(
"2weight", data)
125 print(
"Generated model header file ", modelCode)
134modelName =
"LinearModel"
155sofie =
getattr(ROOT,
"TMVA_SOFIE_" + modelName)
159print(
"\n************************************************************")
160print(
"Running inference with SOFIE ")
161print(
"\ninput to model is ", x)
165print(
"-> output using SOFIE = ", y_sofie)
169 import onnxruntime
as ort
172 print(
"Running inference with ONNXRuntime ")
178 print(
"-> output using ORT =", y_ort)
180 testFailed = abs(y_sofie - y_ort) > 0.01
182 raise RuntimeError(
"Result is different between SOFIE and ONNXRT")
187 print(
"Missing ONNXRuntime: skipping comparison test")
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.