tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

ceil.https.any.js (15192B)


      1 // META: title=test WebNN API element-wise ceil operation
      2 // META: global=window
      3 // META: variant=?cpu
      4 // META: variant=?gpu
      5 // META: variant=?npu
      6 // META: script=../resources/utils.js
      7 // META: timeout=long
      8 
      9 'use strict';
     10 
     11 // https://www.w3.org/TR/webnn/#api-mlgraphbuilder-unary
     12 // Compute the ceiling of the input tensor, element-wise.
     13 //
     14 // MLOperand ceil(MLOperand input);
     15 
     16 
     17 const getCeilPrecisionTolerance = (graphResources) => {
     18  const toleranceValueDict = {float32: 0, float16: 0};
     19  const expectedDataType =
     20      getExpectedDataTypeOfSingleOutput(graphResources.expectedOutputs);
     21  return {metricType: 'ULP', value: toleranceValueDict[expectedDataType]};
     22 };
     23 
     24 const ceilTests = [
     25  {
     26    'name': 'ceil float32 0D scalar',
     27    'graph': {
     28      'inputs': {
     29        'ceilInput': {
     30          'data': [67.38941955566406],
     31          'descriptor': {shape: [], dataType: 'float32'}
     32        }
     33      },
     34      'operators': [{
     35        'name': 'ceil',
     36        'arguments': [{'input': 'ceilInput'}],
     37        'outputs': 'ceilOutput'
     38      }],
     39      'expectedOutputs': {
     40        'ceilOutput':
     41            {'data': [68], 'descriptor': {shape: [], dataType: 'float32'}}
     42      }
     43    }
     44  },
     45  {
     46    'name': 'ceil float32 1D constant tensor',
     47    'graph': {
     48      'inputs': {
     49        'ceilInput': {
     50          'data': [
     51            67.38941955566406,   36.78218460083008,   99.10649108886719,
     52            -22.58710479736328,  32.70173645019531,   17.68880844116211,
     53            5.631034851074219,   12.965238571166992,  83.1319351196289,
     54            -29.292461395263672, 19.84463119506836,   65.2790298461914,
     55            26.31110954284668,   24.285673141479492,  -48.39767074584961,
     56            -5.617412567138672,  61.53380584716797,   -87.81197357177734,
     57            69.71428680419922,   5.0031023025512695,  84.36833953857422,
     58            -9.390542030334473,  -27.856616973876953, -34.895931243896484
     59          ],
     60          'descriptor': {shape: [24], dataType: 'float32'},
     61          'constant': true
     62        }
     63      },
     64      'operators': [{
     65        'name': 'ceil',
     66        'arguments': [{'input': 'ceilInput'}],
     67        'outputs': 'ceilOutput'
     68      }],
     69      'expectedOutputs': {
     70        'ceilOutput': {
     71          'data': [
     72            68, 37, 100, -22, 33, 18,  6,  13, 84, -29, 20,  66,
     73            27, 25, -48, -5,  62, -87, 70, 6,  85, -9,  -27, -34
     74          ],
     75          'descriptor': {shape: [24], dataType: 'float32'}
     76        }
     77      }
     78    }
     79  },
     80  {
     81    'name': 'ceil float32 1D tensor',
     82    'graph': {
     83      'inputs': {
     84        'ceilInput': {
     85          'data': [
     86            67.38941955566406,   36.78218460083008,   99.10649108886719,
     87            -22.58710479736328,  32.70173645019531,   17.68880844116211,
     88            5.631034851074219,   12.965238571166992,  83.1319351196289,
     89            -29.292461395263672, 19.84463119506836,   65.2790298461914,
     90            26.31110954284668,   24.285673141479492,  -48.39767074584961,
     91            -5.617412567138672,  61.53380584716797,   -87.81197357177734,
     92            69.71428680419922,   5.0031023025512695,  84.36833953857422,
     93            -9.390542030334473,  -27.856616973876953, -34.895931243896484
     94          ],
     95          'descriptor': {shape: [24], dataType: 'float32'}
     96        }
     97      },
     98      'operators': [{
     99        'name': 'ceil',
    100        'arguments': [{'input': 'ceilInput'}],
    101        'outputs': 'ceilOutput'
    102      }],
    103      'expectedOutputs': {
    104        'ceilOutput': {
    105          'data': [
    106            68, 37, 100, -22, 33, 18,  6,  13, 84, -29, 20,  66,
    107            27, 25, -48, -5,  62, -87, 70, 6,  85, -9,  -27, -34
    108          ],
    109          'descriptor': {shape: [24], dataType: 'float32'}
    110        }
    111      }
    112    }
    113  },
    114  {
    115    'name': 'ceil float32 2D tensor',
    116    'graph': {
    117      'inputs': {
    118        'ceilInput': {
    119          'data': [
    120            67.38941955566406,   36.78218460083008,   99.10649108886719,
    121            -22.58710479736328,  32.70173645019531,   17.68880844116211,
    122            5.631034851074219,   12.965238571166992,  83.1319351196289,
    123            -29.292461395263672, 19.84463119506836,   65.2790298461914,
    124            26.31110954284668,   24.285673141479492,  -48.39767074584961,
    125            -5.617412567138672,  61.53380584716797,   -87.81197357177734,
    126            69.71428680419922,   5.0031023025512695,  84.36833953857422,
    127            -9.390542030334473,  -27.856616973876953, -34.895931243896484
    128          ],
    129          'descriptor': {shape: [4, 6], dataType: 'float32'}
    130        }
    131      },
    132      'operators': [{
    133        'name': 'ceil',
    134        'arguments': [{'input': 'ceilInput'}],
    135        'outputs': 'ceilOutput'
    136      }],
    137      'expectedOutputs': {
    138        'ceilOutput': {
    139          'data': [
    140            68, 37, 100, -22, 33, 18,  6,  13, 84, -29, 20,  66,
    141            27, 25, -48, -5,  62, -87, 70, 6,  85, -9,  -27, -34
    142          ],
    143          'descriptor': {shape: [4, 6], dataType: 'float32'}
    144        }
    145      }
    146    }
    147  },
    148  {
    149    'name': 'ceil float32 3D tensor',
    150    'graph': {
    151      'inputs': {
    152        'ceilInput': {
    153          'data': [
    154            67.38941955566406,   36.78218460083008,   99.10649108886719,
    155            -22.58710479736328,  32.70173645019531,   17.68880844116211,
    156            5.631034851074219,   12.965238571166992,  83.1319351196289,
    157            -29.292461395263672, 19.84463119506836,   65.2790298461914,
    158            26.31110954284668,   24.285673141479492,  -48.39767074584961,
    159            -5.617412567138672,  61.53380584716797,   -87.81197357177734,
    160            69.71428680419922,   5.0031023025512695,  84.36833953857422,
    161            -9.390542030334473,  -27.856616973876953, -34.895931243896484
    162          ],
    163          'descriptor': {shape: [2, 3, 4], dataType: 'float32'}
    164        }
    165      },
    166      'operators': [{
    167        'name': 'ceil',
    168        'arguments': [{'input': 'ceilInput'}],
    169        'outputs': 'ceilOutput'
    170      }],
    171      'expectedOutputs': {
    172        'ceilOutput': {
    173          'data': [
    174            68, 37, 100, -22, 33, 18,  6,  13, 84, -29, 20,  66,
    175            27, 25, -48, -5,  62, -87, 70, 6,  85, -9,  -27, -34
    176          ],
    177          'descriptor': {shape: [2, 3, 4], dataType: 'float32'}
    178        }
    179      }
    180    }
    181  },
    182  {
    183    'name': 'ceil float32 4D tensor',
    184    'graph': {
    185      'inputs': {
    186        'ceilInput': {
    187          'data': [
    188            67.38941955566406,   36.78218460083008,   99.10649108886719,
    189            -22.58710479736328,  32.70173645019531,   17.68880844116211,
    190            5.631034851074219,   12.965238571166992,  83.1319351196289,
    191            -29.292461395263672, 19.84463119506836,   65.2790298461914,
    192            26.31110954284668,   24.285673141479492,  -48.39767074584961,
    193            -5.617412567138672,  61.53380584716797,   -87.81197357177734,
    194            69.71428680419922,   5.0031023025512695,  84.36833953857422,
    195            -9.390542030334473,  -27.856616973876953, -34.895931243896484
    196          ],
    197          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
    198        }
    199      },
    200      'operators': [{
    201        'name': 'ceil',
    202        'arguments': [{'input': 'ceilInput'}],
    203        'outputs': 'ceilOutput'
    204      }],
    205      'expectedOutputs': {
    206        'ceilOutput': {
    207          'data': [
    208            68, 37, 100, -22, 33, 18,  6,  13, 84, -29, 20,  66,
    209            27, 25, -48, -5,  62, -87, 70, 6,  85, -9,  -27, -34
    210          ],
    211          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
    212        }
    213      }
    214    }
    215  },
    216  {
    217    'name': 'ceil float32 5D tensor',
    218    'graph': {
    219      'inputs': {
    220        'ceilInput': {
    221          'data': [
    222            67.38941955566406,   36.78218460083008,   99.10649108886719,
    223            -22.58710479736328,  32.70173645019531,   17.68880844116211,
    224            5.631034851074219,   12.965238571166992,  83.1319351196289,
    225            -29.292461395263672, 19.84463119506836,   65.2790298461914,
    226            26.31110954284668,   24.285673141479492,  -48.39767074584961,
    227            -5.617412567138672,  61.53380584716797,   -87.81197357177734,
    228            69.71428680419922,   5.0031023025512695,  84.36833953857422,
    229            -9.390542030334473,  -27.856616973876953, -34.895931243896484
    230          ],
    231          'descriptor': {shape: [2, 1, 4, 1, 3], dataType: 'float32'}
    232        }
    233      },
    234      'operators': [{
    235        'name': 'ceil',
    236        'arguments': [{'input': 'ceilInput'}],
    237        'outputs': 'ceilOutput'
    238      }],
    239      'expectedOutputs': {
    240        'ceilOutput': {
    241          'data': [
    242            68, 37, 100, -22, 33, 18,  6,  13, 84, -29, 20,  66,
    243            27, 25, -48, -5,  62, -87, 70, 6,  85, -9,  -27, -34
    244          ],
    245          'descriptor': {shape: [2, 1, 4, 1, 3], dataType: 'float32'}
    246        }
    247      }
    248    }
    249  },
    250 
    251  // float16 tests
    252  {
    253    'name': 'ceil float16 0D scalar',
    254    'graph': {
    255      'inputs': {
    256        'ceilInput':
    257            {'data': [67.375], 'descriptor': {shape: [], dataType: 'float16'}}
    258      },
    259      'operators': [{
    260        'name': 'ceil',
    261        'arguments': [{'input': 'ceilInput'}],
    262        'outputs': 'ceilOutput'
    263      }],
    264      'expectedOutputs': {
    265        'ceilOutput':
    266            {'data': [68], 'descriptor': {shape: [], dataType: 'float16'}}
    267      }
    268    }
    269  },
    270  {
    271    'name': 'ceil float16 1D constant tensor',
    272    'graph': {
    273      'inputs': {
    274        'ceilInput': {
    275          'data': [
    276            67.375,     36.78125,  99.125,     -22.59375, 32.6875,
    277            17.6875,    5.6328125, 12.96875,   83.125,    -29.296875,
    278            19.84375,   65.25,     26.3125,    24.28125,  -48.40625,
    279            -5.6171875, 61.53125,  -87.8125,   69.6875,   5.00390625,
    280            84.375,     -9.390625, -27.859375, -34.90625
    281          ],
    282          'descriptor': {shape: [24], dataType: 'float16'},
    283          'constant': true
    284        }
    285      },
    286      'operators': [{
    287        'name': 'ceil',
    288        'arguments': [{'input': 'ceilInput'}],
    289        'outputs': 'ceilOutput'
    290      }],
    291      'expectedOutputs': {
    292        'ceilOutput': {
    293          'data': [
    294            68, 37, 100, -22, 33, 18,  6,  13, 84, -29, 20,  66,
    295            27, 25, -48, -5,  62, -87, 70, 6,  85, -9,  -27, -34
    296          ],
    297          'descriptor': {shape: [24], dataType: 'float16'}
    298        }
    299      }
    300    }
    301  },
    302  {
    303    'name': 'ceil float16 1D tensor',
    304    'graph': {
    305      'inputs': {
    306        'ceilInput': {
    307          'data': [
    308            67.375,     36.78125,  99.125,     -22.59375, 32.6875,
    309            17.6875,    5.6328125, 12.96875,   83.125,    -29.296875,
    310            19.84375,   65.25,     26.3125,    24.28125,  -48.40625,
    311            -5.6171875, 61.53125,  -87.8125,   69.6875,   5.00390625,
    312            84.375,     -9.390625, -27.859375, -34.90625
    313          ],
    314          'descriptor': {shape: [24], dataType: 'float16'}
    315        }
    316      },
    317      'operators': [{
    318        'name': 'ceil',
    319        'arguments': [{'input': 'ceilInput'}],
    320        'outputs': 'ceilOutput'
    321      }],
    322      'expectedOutputs': {
    323        'ceilOutput': {
    324          'data': [
    325            68, 37, 100, -22, 33, 18,  6,  13, 84, -29, 20,  66,
    326            27, 25, -48, -5,  62, -87, 70, 6,  85, -9,  -27, -34
    327          ],
    328          'descriptor': {shape: [24], dataType: 'float16'}
    329        }
    330      }
    331    }
    332  },
    333  {
    334    'name': 'ceil float16 2D tensor',
    335    'graph': {
    336      'inputs': {
    337        'ceilInput': {
    338          'data': [
    339            67.375,     36.78125,  99.125,     -22.59375, 32.6875,
    340            17.6875,    5.6328125, 12.96875,   83.125,    -29.296875,
    341            19.84375,   65.25,     26.3125,    24.28125,  -48.40625,
    342            -5.6171875, 61.53125,  -87.8125,   69.6875,   5.00390625,
    343            84.375,     -9.390625, -27.859375, -34.90625
    344          ],
    345          'descriptor': {shape: [4, 6], dataType: 'float16'}
    346        }
    347      },
    348      'operators': [{
    349        'name': 'ceil',
    350        'arguments': [{'input': 'ceilInput'}],
    351        'outputs': 'ceilOutput'
    352      }],
    353      'expectedOutputs': {
    354        'ceilOutput': {
    355          'data': [
    356            68, 37, 100, -22, 33, 18,  6,  13, 84, -29, 20,  66,
    357            27, 25, -48, -5,  62, -87, 70, 6,  85, -9,  -27, -34
    358          ],
    359          'descriptor': {shape: [4, 6], dataType: 'float16'}
    360        }
    361      }
    362    }
    363  },
    364  {
    365    'name': 'ceil float16 3D tensor',
    366    'graph': {
    367      'inputs': {
    368        'ceilInput': {
    369          'data': [
    370            67.375,     36.78125,  99.125,     -22.59375, 32.6875,
    371            17.6875,    5.6328125, 12.96875,   83.125,    -29.296875,
    372            19.84375,   65.25,     26.3125,    24.28125,  -48.40625,
    373            -5.6171875, 61.53125,  -87.8125,   69.6875,   5.00390625,
    374            84.375,     -9.390625, -27.859375, -34.90625
    375          ],
    376          'descriptor': {shape: [2, 3, 4], dataType: 'float16'}
    377        }
    378      },
    379      'operators': [{
    380        'name': 'ceil',
    381        'arguments': [{'input': 'ceilInput'}],
    382        'outputs': 'ceilOutput'
    383      }],
    384      'expectedOutputs': {
    385        'ceilOutput': {
    386          'data': [
    387            68, 37, 100, -22, 33, 18,  6,  13, 84, -29, 20,  66,
    388            27, 25, -48, -5,  62, -87, 70, 6,  85, -9,  -27, -34
    389          ],
    390          'descriptor': {shape: [2, 3, 4], dataType: 'float16'}
    391        }
    392      }
    393    }
    394  },
    395  {
    396    'name': 'ceil float16 4D tensor',
    397    'graph': {
    398      'inputs': {
    399        'ceilInput': {
    400          'data': [
    401            67.375,     36.78125,  99.125,     -22.59375, 32.6875,
    402            17.6875,    5.6328125, 12.96875,   83.125,    -29.296875,
    403            19.84375,   65.25,     26.3125,    24.28125,  -48.40625,
    404            -5.6171875, 61.53125,  -87.8125,   69.6875,   5.00390625,
    405            84.375,     -9.390625, -27.859375, -34.90625
    406          ],
    407          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'}
    408        }
    409      },
    410      'operators': [{
    411        'name': 'ceil',
    412        'arguments': [{'input': 'ceilInput'}],
    413        'outputs': 'ceilOutput'
    414      }],
    415      'expectedOutputs': {
    416        'ceilOutput': {
    417          'data': [
    418            68, 37, 100, -22, 33, 18,  6,  13, 84, -29, 20,  66,
    419            27, 25, -48, -5,  62, -87, 70, 6,  85, -9,  -27, -34
    420          ],
    421          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'}
    422        }
    423      }
    424    }
    425  },
    426  {
    427    'name': 'ceil float16 5D tensor',
    428    'graph': {
    429      'inputs': {
    430        'ceilInput': {
    431          'data': [
    432            67.375,     36.78125,  99.125,     -22.59375, 32.6875,
    433            17.6875,    5.6328125, 12.96875,   83.125,    -29.296875,
    434            19.84375,   65.25,     26.3125,    24.28125,  -48.40625,
    435            -5.6171875, 61.53125,  -87.8125,   69.6875,   5.00390625,
    436            84.375,     -9.390625, -27.859375, -34.90625
    437          ],
    438          'descriptor': {shape: [2, 1, 4, 1, 3], dataType: 'float16'}
    439        }
    440      },
    441      'operators': [{
    442        'name': 'ceil',
    443        'arguments': [{'input': 'ceilInput'}],
    444        'outputs': 'ceilOutput'
    445      }],
    446      'expectedOutputs': {
    447        'ceilOutput': {
    448          'data': [
    449            68, 37, 100, -22, 33, 18,  6,  13, 84, -29, 20,  66,
    450            27, 25, -48, -5,  62, -87, 70, 6,  85, -9,  -27, -34
    451          ],
    452          'descriptor': {shape: [2, 1, 4, 1, 3], dataType: 'float16'}
    453        }
    454      }
    455    }
    456  }
    457 ];
    458 
    459 webnn_conformance_test(
    460    ceilTests, buildAndExecuteGraph, getCeilPrecisionTolerance);