Skip to content

Handle missing initializers in allocation planner to fix crashes with DML provider#5244

Merged
jeffbloo merged 3 commits into
masterfrom
jeffbloo/AllowMissingInputsInMemPlanning
Sep 23, 2020
Merged

Handle missing initializers in allocation planner to fix crashes with DML provider#5244
jeffbloo merged 3 commits into
masterfrom
jeffbloo/AllowMissingInputsInMemPlanning

Conversation

@jeffbloo
Copy link
Copy Markdown
Contributor

@jeffbloo jeffbloo commented Sep 22, 2020

This addresses crashes in certain models while creation sessions with the DML provider.

The problem is related to an optimization for memory size in which the DML graph partitioner transfers protobuf initializers out of the graph to manage itself. The presence of the initializer though is needed for the allocation planner to call ProcessDef for that value and initialize “reused_buffer_index". With that field left initialized to zero, the planner thinks it’s decided to reuse the same buffer for that initializer and for another value at index zero, causing that buffer to be freed too many times / too early.

The fix is to initialize reused_buffer_index to -1 and detect this case, as well as make the allocation planner a bit more brittle.

Comment thread onnxruntime/core/framework/allocation_planner.cc
Comment thread onnxruntime/core/framework/allocation_planner.cc
Comment thread onnxruntime/core/framework/allocation_planner.cc
@skottmckay
Copy link
Copy Markdown
Contributor

Are these changes validated by DML unit tests?

@jeffbloo
Copy link
Copy Markdown
Contributor Author

Are these changes validated by DML unit tests?

This will be validated with WindowsAI tests. These have been blocked by the issue below, but the fix is about to merge to our fork.
#5230

Copy link
Copy Markdown
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:

@jeffbloo jeffbloo merged commit 59e69bf into master Sep 23, 2020
@jeffbloo jeffbloo deleted the jeffbloo/AllowMissingInputsInMemPlanning branch September 23, 2020 02:37
tianleiwu pushed a commit that referenced this pull request Sep 23, 2020
… DML provider (#5244)

* Fix memory planning bug with DML EP

* Address PR comments

* Fix typo
tianleiwu pushed a commit that referenced this pull request Sep 23, 2020
… DML provider (#5244)

* Fix memory planning bug with DML EP

* Address PR comments

* Fix typo
edgchen1 pushed a commit that referenced this pull request Sep 24, 2020
… DML provider (#5244)

* Fix memory planning bug with DML EP

* Address PR comments

* Fix typo
edgchen1 pushed a commit that referenced this pull request Sep 24, 2020
… DML provider (#5244)

* Fix memory planning bug with DML EP

* Address PR comments

* Fix typo
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