Skip to content

Refactor InferenceSession::Impl::Load code to remove duplication.#248

Merged
skottmckay merged 5 commits intomasterfrom
scmckay/AddAbilityToUseExistingModelInstanceInInferenceSession
Jan 29, 2019
Merged

Refactor InferenceSession::Impl::Load code to remove duplication.#248
skottmckay merged 5 commits intomasterfrom
scmckay/AddAbilityToUseExistingModelInstanceInInferenceSession

Conversation

@skottmckay
Copy link
Copy Markdown
Contributor

Support use cases where the Model instance is already loaded.

e.g. #168 constant_folding.cc dynamically creates a model but is forced to serialize it to use the current API.

Add generic loading method to InferenceSession::Impl and convert existing methods to use that so load logic isn't cut-and-pasted in 4 places.

@skottmckay skottmckay requested a review from a team as a code owner December 23, 2018 23:57
@snnn
Copy link
Copy Markdown
Contributor

snnn commented Dec 26, 2018

Is this function only for testing purposes?

@linkerzhang
Copy link
Copy Markdown
Contributor

@snnn it can be used for some graph transformers, I think.

@skottmckay
Copy link
Copy Markdown
Contributor Author

There's a link in the description to the PR for constant folding that will use this.


In reply to: 450018587 [](ancestors = 450018587)

Copy link
Copy Markdown
Contributor

@yuanbyu yuanbyu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Constant folding as it is currently implemented is not quite right. I don't understand why we need to make changes in session API to accomodate something that should be completely internal.

* @param model Model to use. InferenceSession::Load must not have been called previously.
* @return OK if success. Error information if failure.
*/
common::Status Initialize(std::shared_ptr<Model>& model);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we ensure that the model is created with the exact same version of protobuf?

Copy link
Copy Markdown
Contributor

@pranavsharma pranavsharma Jan 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scott, FYI: We intentionally removed this method from the interface after RS5 due to protobuf version mismatch issues. We'd added it initially to facilitate faster dev cycles for the Windows folks.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So what alternate approach is best to avoid current ugly necessity to have to serialize a dynamically created Model and reload it in order to be able to execute it? Internal usage only.

e.g. #168 constant_folding.cc dynamically creates a model but is forced to serialize it to use the current API.

Do we need to refactor to split out internal aspects from InferenceSession so that those can be called directly in this sort of scenario instead of using the public InferenceSession API?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed from this PR. Constant folding is going to be refactored and shouldn't need an API change in InferenceSession.

@skottmckay skottmckay changed the title Add ability to initialize InferenceSession with a model that is already loaded. Refactor InferenceSession::Impl::Load code to remove duplication. Jan 25, 2019
@skottmckay skottmckay merged commit 8f215b4 into master Jan 29, 2019
@skottmckay skottmckay deleted the scmckay/AddAbilityToUseExistingModelInstanceInInferenceSession branch January 29, 2019 07:18
yuslepukhin pushed a commit that referenced this pull request Mar 17, 2026
## Describe your changes
make engine register the Pass config instead of Pass instance to support
hardware accelerators

## Checklist before requesting a review
- [x] Add unit tests for this change.
- [x] Make sure all tests can pass.
- [x] Update documents if necessary.
- [x] Format your code by running `pre-commit run --all-files`

## (Optional) Issue link
milpuz01 added a commit to milpuz01/onnxruntime that referenced this pull request Mar 23, 2026
  - Fix SconvNchwcKernelNeon.S KernelFlags==0 remainder path temp spill slot (sp+microsoft#120 -> sp+microsoft#248) to avoid clobbering callee-saved SIMD spills (q8-q15)
  - Replace \@-based local labels with numeric local labels (90f/91b style) for portable assembly parsing (including macOS toolchains)

Signed-off-by: Milos Puzovic <milos.puzovic@arm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants