-
Notifications
You must be signed in to change notification settings - Fork 18
Add compatibility tests generated from Android Neural Networks API (NNAPI) Compatibility Test Suite. #29
Add compatibility tests generated from Android Neural Networks API (NNAPI) Compatibility Test Suite. #29
Conversation
…e ops: clamp / conv2d / add sub mul div max min / exp sigmoid sqrt tanh / averagePool2d maxPool2d / relu / reshape / squeeze / transpose
…ests with 'nchw' layout.
Total: 188 Pass: 176 / Fail: 12 clamp test: 8/8 conv2d test: 76/76 add test: 2/2 sub test: 12/12 mul test: 4/4 div test: 4/4 max test: 6/6 min test: 6/6 exp test: 2/2 sigmoid test: 4/4 sqrt test: 2/2 tanh test: 2/2 averagePool2d test: 12/24 maxPool2d test: 18/18 relu test: 4/4 reshape test: 4/4 squeeze test: 4/4 transpose test: 6/6
Thanks @BruceDai! This is quite a substantial PR so I'll defer to @huningxin for the detailed review. Web spec usually reuse https://web-platform-tests.org/ infrastructure. Can these tests be repurposed to use testharness.js with a reasonable effort? It is not a hard requirement to have tests written using testharness.js, but it'd help sharing tests cross-browser and also many (all?) browsers automatically import and run w-p-t tests as part of their CI processes. |
@BruceDai , thanks for your great efforts! This work would help Conformance testing of ML APIs for the We by reusing/porting Android NNAPI CTS. @anssiko , I propose this as an agenda item for the next WebML CG call for wide feedbacks. |
test/cts/from_nnapi/README.md
Outdated
| MAX_POOL_2D | maxPool2d [+ relu/clamp] | | ||
| CONV_2D | conv2d [+ add + relu/clamp] | | ||
| DEPTHWISE_CONV_2D | conv2d [+ add + relu/clamp] | | ||
| GROUPED_CONV_2D | conv2d [+ add + relu/clamp] | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't find test cases for grouped_conv_2d
?
@anssiko Yes, these tests can use w-p-t testharness.js as we're discussing "Reuse mocha tests for web platform tests" #2 . |
Good suggestion, added to WebML CG Teleconference – 10 December 2020 - 15:00-16:00 UTC+0. |
Use node es6 modules support
test/cts/from_nnapi/tests/V1_0/test_add_clamp_converted_from_add.js
Outdated
Show resolved
Hide resolved
f08a375
to
d4b9869
Compare
@BruceDai , tf.js released 2.8.3, could you please verify whether it fixes the issue? |
was fixed from tf.js 2.8.2.
@huningxin Thanks for your suggestion. Now I have upgrade tf.js to latest 2.8.3, the 12 skipped pool tests now all pass. |
Thanks @BruceDai , since you upgraded the tf.js version, could you please confirm there are no regressions for other tests? |
Thanks @huningxin |
As there were no objects in WebML CG 7 Jan call, I am going to merge this PR. Thanks for your great contributions, @BruceDai ! |
…config binding on Linux successfully
This PR is on the purpose of adding compatibility tests for WebNN first wave ops by converting existed native Android Neural Networks API tests.
NNAPI Operations mapping to WebNN Operations (first wave ops)
The Android Neural Networks API (NNAPI) is an Android C API designed for running computationally intensive operations for machine learning on Android devices. NNAPI is designed to provide a base layer of functionality for higher-level machine learning frameworks.
Here's a table of NNAPI Operations mapping to WebNN Operations (first wave ops), please review details of converting NNAPI CTS on this link.
The NNAPI ADD/SUB/MUL/DIV/AVERAGE_POOL_2D/MAX_POOL_2D Operations fused activation computation, and CONV_2D/DEPTHWISE_CONV_2D/FULLY_CONNECTED Operations fused both add bias computation and activation computation.
Generated WebNN Tests Status
Please have a quick glance at those converted test on this link. Current I leverage and upgrade NNAPI test_generator tools to generate total 250 (Pass: 250) compatibility tests of Int32 and Float32 types which are supported by WebNN Polyfill API, please the detail generated test cases on the above table.
Except WebNN API unsupported Operand types, there're following cases for some NNAPI CTS not being converted for WebNN API:
And for FULLY_CONNECTED tests, if rank of input is greater than 2, this convert tool would flatten input to a 2-D Tensor of generated tests for WebNN API.
Accuracy for Generated Tests
Current WebNN Test adopts this accuracy:
While generated tests follows NNAPI accuracy:
and for relaxed tests using this following accuracy
@anssiko @huningxin Please take a look. What's your suggestion? Thanks.