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 an option to use the input model bytes (ORT format only) directly without copy at session creation #8502

Merged
merged 4 commits into from
Jul 27, 2021

Conversation

guoyu-wang
Copy link
Contributor

@guoyu-wang guoyu-wang commented Jul 27, 2021

Description: Add an option to use the input model bytes (ORT format only) directly without copy at session creation

Motivation and Context

  • When we load an ORT format model from given byte array, we copy the array first to ensure the bytes are valid. There is a recent issue Prevent data copy in CreateSessionFromArray  #8328, where the current behavior may cause extra memory usage where iOS may kill the process
  • Add an option to not copy the input model bytes, however, in this case, the user will have to guarantee the buffer is valid until the session is created (this is the 1st step to reduce memory consumption). The default behavior is still copying the model bytes. The user has to specifically set the option to disable the copy.
  • Added UT cases

@guoyu-wang guoyu-wang requested a review from a team as a code owner July 27, 2021 01:09
skottmckay
skottmckay previously approved these changes Jul 27, 2021
Copy link
Contributor

@skottmckay skottmckay left a comment

Choose a reason for hiding this comment

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

:shipit:

@@ -71,5 +79,3 @@ static const char* const kOrtSessionOptionsConfigAllowIntraOpSpinning = "session
// If not specified, the default set of stop ops is used. To specify an empty stop ops types list and disable stop op
// exclusion, set the value to "".
static const char* const kOrtSessionOptionsConfigNnapiEpPartitioningStopOps = "ep.nnapi.partitioning_stop_ops";

// NNAPI EP keys end
Copy link
Contributor

Choose a reason for hiding this comment

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

if removing the "end" comment, can you also remove the "begin" one and change the note to say "The NNAPI EP options..." instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do in my next change

@guoyu-wang guoyu-wang merged commit 4c939e1 into master Jul 27, 2021
@guoyu-wang guoyu-wang deleted the gwang-msft/not_copy_ort_model_data branch July 27, 2021 16:11
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.

3 participants