[DML EP] Expose NPU macro via build command (#20306)

### 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. -->
This commit is contained in:
Sumit Agarwal 2024-04-18 11:23:13 -07:00 committed by GitHub
parent 76434907fb
commit f664f91298
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 6 deletions

View file

@ -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)

View file

@ -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)
@ -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];
}
@ -432,7 +432,7 @@ namespace Dml::GraphDescBuilder
{
uint32_t dmlGraphNodeIndex = SetAndGetDmlGraphNodeIndex(
operatorDmlGraphInputEdge.ToNodeIndex,
node.Name(),
node,
*operatorDmlGraphCreateInfo.nodes[operatorDmlGraphInputEdge.ToNodeIndex],
operatorDmlGraphToDmlGraphNodeIndexMap,
dmlGraphNodes);
@ -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);
@ -535,7 +535,7 @@ namespace Dml::GraphDescBuilder
{
uint32_t shiftedNodeIndex = SetAndGetDmlGraphNodeIndex(
operatorGraphOutputEdge.FromNodeIndex,
node.Name(),
node,
*operatorDmlGraphCreateInfo.nodes[operatorGraphOutputEdge.FromNodeIndex],
operatorDmlGraphToDmlGraphNodeIndexMap,
dmlGraphNodes);