ATLAS Offline Software
Loading...
Searching...
No Matches
OnnxRuntimeInferenceConfig.py
Go to the documentation of this file.
1# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
4from AthenaConfiguration.ComponentFactory import CompFactory
5from AthOnnxComps.OnnxRuntimeFlags import OnnxRuntimeType
6from typing import Optional
7from AthOnnxComps.OnnxRuntimeSessionConfig import OnnxRuntimeSessionToolCfg
8
10 model_fname: str = None,
11 execution_provider: Optional[OnnxRuntimeType] = None,
12 name="OnnxRuntimeInferenceTool", **kwargs):
13 """Configure OnnxRuntimeInferenceTool in Control/AthOnnx/AthOnnxComps/src"""
14
15 acc = ComponentAccumulator()
16
17 if "OnnxRuntimeSvc" not in kwargs:
18 from AthOnnxComps.OnnxRuntimeSvcConfig import OnnxRuntimeSvcCfg
19 kwargs.setdefault("OnnxRuntimeSvc", acc.getPrimaryAndMerge(OnnxRuntimeSvcCfg(flags)))
20 kwargs.setdefault("ORTSessionTool", acc.popToolsAndMerge(OnnxRuntimeSessionToolCfg(flags, model_fname, execution_provider)))
21 acc.setPrivateTools(CompFactory.AthOnnx.OnnxRuntimeInferenceTool(name, **kwargs))
22 return acc
OnnxRuntimeInferenceToolCfg(flags, str model_fname=None, Optional[OnnxRuntimeType] execution_provider=None, name="OnnxRuntimeInferenceTool", **kwargs)