webmachinelearning/webnn-native

Unable to run webnn_end2end_tests.exe under third_party using webnn_enable_dml

Closed this issue · 1 comments

I am trying to run webnn_end2end_tests.exe where webnn_native component gets built under the .\third_party sub-directory like how most components of Chromium reside (ex. third_party\Dawn).

But when I run webnn_end2end_tests.exe, built using webnn_enable_dml = true edited in build_overrides/webnn_features.gni, the following output returns:

[==========] Running 194 tests from 32 test suites.
[----------] Global test environment set-up.
[----------] 3 tests from AddTests
[ RUN      ] AddTests.AddConstantAndInput
Detected memory leaks!
Dumping objects ->
{2566} normal block at 0x000001B988199940, 12 bytes long.
 Data: <            > 03 00 00 00 04 00 00 00 05 00 00 00 
{2564} normal block at 0x000001B98819A160, 12 bytes long.
 Data: <            > 03 00 00 00 04 00 00 00 05 00 00 00 
...

And the test fails (does not continue to run).

Any idea how to proceed (maybe memory leak checking is causing an issue)?

@huningxin @fujunwei

Debugged this a bit further and it looks like WebNN's DML backend always assumes the highest feature level or DML_FEATURE_LEVEL_3_0 is supported. I know this because the debug layer reports this error:

D3D12 ERROR: An invalid tensor dimension count of '3' was specified for 'ATensor'. The only valid values for DimensionCount are 4 and 5. [ UNKNOWN ERROR #1: STRING_FROM_APPLICATION]
D3D12: **BREAK** enabled for the previous message, which was: [ ERROR UNKNOWN #1: STRING_FROM_APPLICATION ]

And breaks on this DML operator, DML_ELEMENT_WISE_ADD_OPERATOR:

{dataType=DML_TENSOR_DATA_TYPE_FLOAT32 (1) flags=DML_TENSOR_FLAG_NONE (0) sizes={ size=3 } ...}

Notice size=3 isn't allowed [1] with anything lower than DML_FEATURE_LEVEL_3_0.

To fix, I believe we'll need to either explicitly require DML_FEATURE_LEVEL_3_0 via DMLCreateDevice1 and fail, or re-develop the builder to handle the rank supported by the device.

[1] https://docs.microsoft.com/en-us/windows/win32/api/directml/ns-directml-dml_element_wise_add_operator_desc