-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DML EP] Add dynamic graph compilation (#17876)
Historically, DML was only able to fuse partitions when all sizes are known in advance or when we were overriding them at session creation time. But in practice, it should be possible to compile partitions at compute time if the caller knows that the dimensions won't be changed for every inference (e.g. resizing a webcam window, or padding the input to powers of 2). This graph will be cached and reused until the sizes change. This is an opt-in option gated under the `enable_dynamic_graph_fusion` option, which means that it will only be enabled when the caller requests it since they have more context on how their model will be called between inferences. This PR also adds the option to disable metacommands from the python API, which is an option for the C API but was lacking for python.
- Loading branch information
1 parent
d30d4d3
commit 538e97c
Showing
26 changed files
with
1,127 additions
and
143 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
onnxruntime/core/providers/dml/DmlExecutionProvider/src/DmlEdgeShapes.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
#pragma once | ||
|
||
namespace Windows::AI::MachineLearning::Adapter | ||
{ | ||
// edges and unused edges have an empty array of dimensions. | ||
class EdgeShapes | ||
{ | ||
public: | ||
EdgeShapes() = default; | ||
|
||
EdgeShapes(size_t count) : m_shapes(count) {} | ||
|
||
const std::vector<uint32_t>& GetShape(size_t edgeIndex) const | ||
{ | ||
return m_shapes[edgeIndex]; | ||
} | ||
|
||
std::vector<uint32_t>& GetMutableShape(size_t edgeIndex) | ||
{ | ||
return m_shapes[edgeIndex]; | ||
} | ||
|
||
size_t EdgeCount() const { return m_shapes.size(); } | ||
|
||
void Reset(size_t edge_count) | ||
{ | ||
m_shapes.clear(); | ||
m_shapes.resize(edge_count); | ||
} | ||
|
||
bool operator!=(const EdgeShapes& other) const noexcept | ||
{ | ||
return (m_shapes != other.m_shapes); | ||
} | ||
|
||
private: | ||
std::vector<std::vector<uint32_t>> m_shapes; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.