Skip to content

Commit ef8345d

Browse files
fujunweichromium-wpt-export-bot
authored andcommitted
webnn: fuse QDQ for gather on tflite
Input and output must all have same scale and zero_point. Bug: 401281047 Change-Id: I9ca47ceb3e8879ae23362439a35f3eea9f9caa9a Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6576037 Commit-Queue: Junwei Fu <junwei.fu@intel.com> Reviewed-by: Phillis Tang <phillis@chromium.org> Reviewed-by: ningxin hu <ningxin.hu@intel.com> Cr-Commit-Position: refs/heads/main@{#1465141}
1 parent bbc9c17 commit ef8345d

1 file changed

Lines changed: 87 additions & 0 deletions

File tree

webnn/conformance_tests/qdq_subgraph.https.any.js

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,93 @@ const subgraphTests = [
687687
}
688688
}
689689
},
690+
{
691+
'name': 'quantized gather',
692+
'graph': {
693+
'inputs': {
694+
'input': {
695+
'data': [
696+
2.549168109893799, 4.794857501983643, 7.413617134094238,
697+
8.413617134094238, 6.108623504638672, 3.549168109893799,
698+
],
699+
'descriptor': {shape: [2, 3], dataType: 'float32'},
700+
'constant': false
701+
},
702+
'inputScale': {
703+
'data': [0.343092918395996],
704+
'descriptor': {shape: [1], dataType: 'float32'},
705+
'constant': true
706+
},
707+
'inputZeroPoint': {
708+
'data': [-128],
709+
'descriptor': {shape: [1], dataType: 'int8'},
710+
'constant': true
711+
},
712+
'gatherIndices': {
713+
'data': [1],
714+
'descriptor': {shape: [], dataType: 'int32'},
715+
'constant': true
716+
},
717+
'outputScale': {
718+
'data': [0.343092918395996],
719+
'descriptor': {shape: [1], dataType: 'float32'},
720+
'constant': true
721+
},
722+
'outputZeroPoint': {
723+
'data': [-128],
724+
'descriptor': {shape: [1], dataType: 'int8'},
725+
'constant': true
726+
},
727+
},
728+
'operators': [
729+
{
730+
'name': 'quantizeLinear',
731+
'arguments': [
732+
{'input': 'input'},
733+
{'scale': 'inputScale', 'zeroPoint': 'inputZeroPoint'}
734+
],
735+
'outputs': 'quantizedInput'
736+
},
737+
{
738+
'name': 'dequantizeLinear',
739+
'arguments': [
740+
{'input': 'quantizedInput'},
741+
{'scale': 'inputScale', 'zeroPoint': 'inputZeroPoint'}
742+
],
743+
'outputs': 'dequantizedInput'
744+
},
745+
{
746+
'name': 'gather',
747+
'arguments': [{'input': 'dequantizedInput'}, {'indices': 'gatherIndices'}],
748+
'outputs': 'gatherOutput'
749+
},
750+
{
751+
'name': 'quantizeLinear',
752+
'arguments': [
753+
{'input': 'gatherOutput'},
754+
{'scale': 'outputScale', 'zeroPoint': 'outputZeroPoint'}
755+
],
756+
'outputs': 'quantizedGatherOutput'
757+
},
758+
{
759+
'name': 'dequantizeLinear',
760+
'arguments': [
761+
{'input': 'quantizedGatherOutput'},
762+
{'scale': 'outputScale', 'zeroPoint': 'outputZeroPoint'}
763+
],
764+
'outputs': 'output'
765+
}
766+
],
767+
'expectedOutputs': {
768+
'output': {
769+
'data': [
770+
8.577322959899902, 6.17567253112793, 3.430929183959961,
771+
],
772+
'descriptor': {shape: [3], dataType: 'float32'}
773+
}
774+
}
775+
}
776+
},
690777
{
691778
'name': 'quantized transpose',
692779
'graph': {

0 commit comments

Comments
 (0)