Skip to content
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

add load from buffer #10162

Merged
merged 12 commits into from
Jan 10, 2022
Merged

add load from buffer #10162

merged 12 commits into from
Jan 10, 2022

Conversation

ancienticybeing
Copy link
Contributor

Description: Add LoadFromBuffer API for LearningModel

Motivation and Context

  • Why is this change required? What problem does it solve?
    Currently, to load a model for inferencing, developers are given 2 options:
  1. LoadFromFilePath. Developer would specify a path to the model file in storage, WinML would read and parse the file, and generate the model.
  2. LoadFromStream. Developer would have their model stored in resource and have WinML load the model from a memory access stream.
    However, neither LoadFromFilePath nor LoadFromStream method work well in VTL1 scenario. LoadFromFilePath would fail because VTL1 restricts file access to ensure a more secure trust level than the normal VTL0. LoadFromStream loads extra WinRT dependencies that are either not IUM signed or are not VTL1 registered COM components; on the other hand, LoadFromStream also makes several unnecessary model copies throughout the method call, heavily impacting performance when loading large models.
    The proposed LoadFromBuffer method solves the above issues by not accessing the file system, avoiding loading unnecessary winrt dependencies, and making no extra model copies, making Windows Machine Learning one step closer to VTL1 ready
  • If it fixes an open issue, please link to the issue here.

@ryanlai2
Copy link
Contributor

ryanlai2 commented Jan 3, 2022

TODO: still need to add tests

REDMOND\jingf added 3 commits January 4, 2022 02:24
REDMOND\jingf added 2 commits January 5, 2022 11:22
@@ -104,22 +104,42 @@ namespace ROOT_NS.AI.MachineLearning
//! Loads an ONNX model from a stream asynchronously.
[remote_async]
static Windows.Foundation.IAsyncOperation<LearningModel> LoadFromStreamAsync(Windows.Storage.Streams.IRandomAccessStreamReference modelStream);
//! Loads an ONNX model from a buffer asynchronously.
Copy link
Contributor

Choose a reason for hiding this comment

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

curious what you think about grouping all of these into one (MachineLearningContract, 6) block instead of having four of them?

Copy link
Contributor Author

@ancienticybeing ancienticybeing Jan 5, 2022

Choose a reason for hiding this comment

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

Yeah technically I don't have problem with that, just thought it might make more sense to keep them together within their own group

Copy link
Member

Choose a reason for hiding this comment

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

Remember that this needs an associated change in the OS repo as well.

@ancienticybeing ancienticybeing merged commit 5cd57bb into master Jan 10, 2022
@ancienticybeing ancienticybeing deleted the jingf/add-LoadFromBuffer branch January 10, 2022 18:51
ancienticybeing pushed a commit that referenced this pull request Feb 17, 2022
ancienticybeing pushed a commit that referenced this pull request Mar 8, 2022
lavanyax pushed a commit to intel/onnxruntime that referenced this pull request Mar 29, 2022
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