Skip to content

Commit

Permalink
webnn: utilize constant nodes in DirectML backend
Browse files Browse the repository at this point in the history
This CL utilizes `DML_GRAPH_NODE_TYPE_CONSTANT` introduced in
`DML_FEATURE_LEVEL_6_2` for constant scalar inputs, which allows CPU
memory to be directly consumed during graph compilation.

Change-Id: I468e600e0b1dae59a0ab017ef7fe86b5e0e00c59
Bug: 366284850
Cq-Include-Trybots: luci.chromium.try:win11-blink-rel, mac14.arm64-blink-rel, mac14-blink-rel, mac15.arm64-blink-rel, mac15-blink-rel, linux-blink-rel
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5859935
Reviewed-by: Rafael Cintron <rafael.cintron@microsoft.com>
Commit-Queue: Shiyi Zou <shiyi.zou@intel.com>
Reviewed-by: ningxin hu <ningxin.hu@intel.com>
Auto-Submit: Shiyi Zou <shiyi.zou@intel.com>
Cr-Commit-Position: refs/heads/main@{#1367255}
  • Loading branch information
shiyi9801 authored and chromium-wpt-export-bot committed Oct 11, 2024
1 parent 0ca2856 commit 8903062
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions webnn/conformance_tests/subgraph.https.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -2464,6 +2464,65 @@ const subgraphTests = [
}
}
},
{
'name': 'add + sub + mul + gather default',
'graph': {
'inputs': {
'addA': {
'data': [10],
'descriptor': {shape: [], dataType: 'int32'},
'constant': true
},
'addB': {
'data': [20],
'descriptor': {shape: [], dataType: 'int32'},
'constant': true
},
'subB': {
'data': [40],
'descriptor': {shape: [], dataType: 'int32'},
},
'divA': {
'data': [-20],
'descriptor': {shape: [], dataType: 'int32'},
'constant': true
},
'gatherInput': {
'data': [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2],
'descriptor': {shape: [3, 4], dataType: 'float32'},
'constant': true
},
},
'operators': [
{
'name': 'add',
'arguments': [{'a': 'addA'}, {'b': 'addB'}],
'outputs': 'addOutput'
},
{
'name': 'sub',
'arguments': [{'a': 'addOutput'}, {'b': 'subB'}],
'outputs': 'subOutput'
},
{
'name': 'div',
'arguments': [{'a': 'divA'}, {'b': 'subOutput'}],
'outputs': 'divOutput'
},
{
'name': 'gather',
'arguments': [{'input': 'gatherInput'}, {'indices': 'divOutput'}],
'outputs': 'output'
},
],
'expectedOutputs': {
'output': {
'data': [0.9, 1.0, 1.1, 1.2],
'descriptor': {shape: [4], dataType: 'float32'}
}
}
}
},
];

if (navigator.ml) {
Expand Down

0 comments on commit 8903062

Please sign in to comment.