Skip to content

Commit

Permalink
[DML EP] Expose NPU macro via build command (microsoft#20306)
Browse files Browse the repository at this point in the history
### Description
This fixes following things:
- Expose `ENABLE_NPU_ADAPTER_ENUMERATION` macro via build command, so
that a user can enable NPU support for DML EP seamlessly.
- Add keyword `_dmlEp_` as part of the node name, which would be useful
for debugging purpose.



### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
  • Loading branch information
sumitsays authored Apr 18, 2024
1 parent 7643490 commit f664f91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 3 additions & 0 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,9 @@ if (onnxruntime_USE_DML)
list(APPEND ORT_PROVIDER_FLAGS -DUSE_DML=1)
list(APPEND ORT_PROVIDER_CMAKE_FLAGS -Donnxruntime_USE_DML=1)
list(APPEND ONNXRUNTIME_PROVIDER_NAMES dml)
if(onnxruntime_ENABLE_NPU_ADAPTER_ENUMERATION)
list(APPEND ORT_PROVIDER_FLAGS -DENABLE_NPU_ADAPTER_ENUMERATION=1)
endif()
endif()
if (onnxruntime_USE_MIGRAPHX)
list(APPEND ORT_PROVIDER_FLAGS -DUSE_MIGRAPHX=1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ namespace Dml::GraphDescBuilder

uint32_t SetAndGetDmlGraphNodeIndex(
const uint32_t operatorDmlGraphNodeIndex,
const std::string& nodeNamePrefix,
const onnxruntime::Node& node,
AbstractOperatorDesc& operatorDesc,
/*in_out*/std::unordered_map<uint32_t, uint32_t>& operatorDmlGraphToDmlGraphNodeIndexMap,
/*in_out*/std::vector<DmlSerializedGraphNode>& dmlGraphNodes)
Expand All @@ -205,7 +205,7 @@ namespace Dml::GraphDescBuilder
return iter->second;
}
operatorDmlGraphToDmlGraphNodeIndexMap[operatorDmlGraphNodeIndex] = static_cast<uint32_t>(dmlGraphNodes.size());
dmlGraphNodes.push_back({operatorDesc, nodeNamePrefix + std::to_string(operatorDmlGraphNodeIndex)});
dmlGraphNodes.push_back({operatorDesc, GetUniqueNodeName(node) + "_dmlEp_" + std::to_string(operatorDmlGraphNodeIndex)});
return operatorDmlGraphToDmlGraphNodeIndexMap[operatorDmlGraphNodeIndex];
}

Expand Down Expand Up @@ -432,7 +432,7 @@ namespace Dml::GraphDescBuilder
{
uint32_t dmlGraphNodeIndex = SetAndGetDmlGraphNodeIndex(
operatorDmlGraphInputEdge.ToNodeIndex,
node.Name(),
node,
*operatorDmlGraphCreateInfo.nodes[operatorDmlGraphInputEdge.ToNodeIndex],
operatorDmlGraphToDmlGraphNodeIndexMap,
dmlGraphNodes);
Expand Down Expand Up @@ -508,13 +508,13 @@ namespace Dml::GraphDescBuilder
DmlIntermediateSerializedGraphEdge edge = {};
uint32_t shiftedFromNodeIndex = SetAndGetDmlGraphNodeIndex(
operatorGraphIntermediateEdge.FromNodeIndex,
node.Name(),
node,
*operatorDmlGraphCreateInfo.nodes[operatorGraphIntermediateEdge.FromNodeIndex],
operatorDmlGraphToDmlGraphNodeIndexMap,
dmlGraphNodes);
uint32_t shiftedToNodeIndex = SetAndGetDmlGraphNodeIndex(
operatorGraphIntermediateEdge.ToNodeIndex,
node.Name(),
node,
*operatorDmlGraphCreateInfo.nodes[operatorGraphIntermediateEdge.ToNodeIndex],
operatorDmlGraphToDmlGraphNodeIndexMap,
dmlGraphNodes);
Expand All @@ -535,7 +535,7 @@ namespace Dml::GraphDescBuilder
{
uint32_t shiftedNodeIndex = SetAndGetDmlGraphNodeIndex(
operatorGraphOutputEdge.FromNodeIndex,
node.Name(),
node,
*operatorDmlGraphCreateInfo.nodes[operatorGraphOutputEdge.FromNodeIndex],
operatorDmlGraphToDmlGraphNodeIndexMap,
dmlGraphNodes);
Expand Down

0 comments on commit f664f91

Please sign in to comment.