-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When developing an ONNX Runtime execution provider, how to get the current InferenceSession
instance which the execution provider registers with?
#18046
Comments
What's your use case? Why do you need a reference to the session in the EP? |
Hi @pranavsharma , We already have a couple of EPs in ONNX Runtime codebase, now we are planning to develop a "unified" EP to cover all the existing separate EPs of ours. In order to reuse the implementation of those existing EPs as much as possible, in the "unified" EP, we need to access (in a read-only manner) those EPs. So, I was thinking to add a reference to |
Hi @pranavsharma , can you or your team members please share whatever suggestions and insights? Thanks |
You can include the headers of the relevant EPs in your unified EP and construct them when constructing the unified EP. You'll have one cmake file that builds all the EPs as part of the unified EP which will abstract all the other EPs. The other EPs can still co-exist independently. Will this work? |
Hi @pranavsharma , thanks for the detailed response.
Meanwhile, we are aware that adding a reference to Moreover, it would be great if we could set up a meeting about such unified EP implementation. |
Different EPs are not supposed to be interacting with each other. Multiple pointers to the same EP would co-exist only if the user has registered both the unified EP and one of the other EPs in the unified EP. Depending on the EP, this may or may not be a problem. We need more details. Before setting up a meeting I would like to know what organization you're representing, what EPs you're trying to unify and most importantly the motivation and context behind this work. |
Hi @pranavsharma @faxu , I'm from AMD. I was intentionally hiding the info of my organization and using my personal account. |
Hi @pranavsharma @faxu , Any more information you'd like to know before we can schedule a meeting? Thanks |
Please NOTE - this is still NOT an official AMD comment. To address some of your early concerns:
Regarding our current proposal (and its further evolution) to ONNXRT core: Briefly and at hight level, apart from some technical benefits (with careful implementation), we may be able to (or even we should) open up (perhaps with some constraints) the intaraction between different EPs. This way, ONNXRT EPs would form an ecosystem which would be like (not technically) the ecosystem of dialects of MLIR. |
I don't think we want different EPs to be interacting with each other during graph partitioning and/or execution. Unification of EPs from the same hardware/device is really a code organization/reuse issue than opening up EP interactions. Let's discuss when we're ready to prioritize this. |
Describe the issue
When developing an ONNX Runtime execution provider, how to get the current
InferenceSession
instance which the execution provider registers with?Seems like there is no approach to that so far?
Can we make a few changes to the class
InferenceSession
of ONNXRuntime core?IExecutionProvider
, add a new protected memeber variablestd::shared_ptr<InferenceSession> curr_sess_
and related public getter method and setter method. Then every child class of IExecutionProvider will inherit this attribute and related getter method and setter method.InferenceSession::RegisterExecutionProvider()
, assign thethis
pointer tocurr_sess_
of an instance of a child class ofIExecutionProvider
using the corresponding setter method of the child class.MyCostumExecutionProvider
, add a new private memeber variablestd::shared_ptr<InferenceSession> curr_sess_
and related public getter method and setter method.InferenceSession::RegisterExecutionProvider()
ORInferenceSession::Initialize()
, specially handleMyCustomExecutionProvider
to assign thethis
pointer toMyCustomExecutionProvider::curr_sess_
using the corresponding setter method ofMyCustomExecutionProvider
. An example of specially handling a specific execution provider inInferenceSession
class isDmlExecutionProvider
.To reproduce
N/A.
Urgency
No response
Platform
All
OS Version
All
ONNX Runtime Installation
Other / Unknown
ONNX Runtime Version or Commit ID
All
ONNX Runtime API
C++
Architecture
X64
Execution Provider
Other / Unknown
Execution Provider Library Version
No response
The text was updated successfully, but these errors were encountered: