tor-browser

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

constant-reshape-optimization.https.any.js (3143B)


      1 // META: title=test constant reshape optimization
      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 const tests = [{
     12  'name': 'reshape + reshape + reshape + instanceNormalization float32',
     13  'graph': {
     14    'inputs': {
     15      'originalInput': {
     16        'data': [
     17          -97.949951171875,    29.44037628173828,  -73.92131042480469,
     18          -38.11185836791992,  41.33772659301758,  -59.77853012084961,
     19          -74.66901397705078,  -68.16508483886719, 35.82481384277344,
     20          -6.948329448699951,  54.42462158203125,  47.53074645996094,
     21          66.93562316894531,   76.74034881591797,  5.6758809089660645,
     22          25.68659210205078,   37.37651062011719,  56.252689361572266,
     23          -16.574905395507812, 42.949893951416016, 73.8739242553711,
     24          -99.00035095214844,  -33.11322784423828, -17.380685806274414
     25        ],
     26        'descriptor': {shape: [3, 8], dataType: 'float32'},
     27        'constant': true
     28      },
     29      'originalScale': {
     30        'data': [-94.42772674560547, 66.69620513916016, -98.56572723388672],
     31        'descriptor': {shape: [1, 3, 1, 1], dataType: 'float32'},
     32        'constant': true
     33      },
     34      'originalBias': {
     35        'data': [-33.048641204833984, 4.511423587799072, -37.93617248535156],
     36        'descriptor': {shape: [1, 3, 1, 1], dataType: 'float32'},
     37        'constant': true
     38      },
     39    },
     40    'operators': [
     41      {
     42        'name': 'reshape',
     43        'arguments': [{'input': 'originalInput'}, {'newShape': [2, 3, 2, 2]}],
     44        'outputs': 'reshapedInput'
     45      },
     46      {
     47        'name': 'reshape',
     48        'arguments': [{'input': 'originalScale'}, {'newShape': [3]}],
     49        'outputs': 'reshapedScale'
     50      },
     51      {
     52        'name': 'reshape',
     53        'arguments': [{'input': 'originalBias'}, {'newShape': [3]}],
     54        'outputs': 'reshapedBias'
     55      },
     56      {
     57        'name': 'instanceNormalization',
     58        'arguments': [
     59          {'input': 'reshapedInput'}, {
     60            'options': {
     61              'scale': 'reshapedScale',
     62              'bias': 'reshapedBias',
     63              'epsilon': 0.000001,
     64              'layout': 'nchw'
     65            }
     66          }
     67        ],
     68        'outputs': 'instanceNormOutput'
     69      }
     70    ],
     71    'expectedOutputs': {
     72      'instanceNormOutput': {
     73        'data': [
     74          70.77738189697266,   -179.65554809570312, 23.540178298950195,
     75          -46.8565788269043,   119.31526184082031,  -22.847837448120117,
     76          -43.782920837402344, -34.6388053894043,   -50.821895599365234,
     77          126.01134490966797,  -127.71744537353516, -99.2166976928711,
     78          -108.09159851074219, -139.83889770507812, 90.26488494873047,
     79          25.471038818359375,  22.237276077270508,  67.60342407226562,
     80          -107.4271011352539,  35.6320915222168,    -186.15142822265625,
     81          90.01669311523438,   -15.238543510437012, -40.37141418457031
     82        ],
     83        'descriptor': {shape: [2, 3, 2, 2], dataType: 'float32'}
     84      }
     85    }
     86  }
     87 }];
     88 
     89 webnn_conformance_test(
     90    tests, buildAndExecuteGraph, getInstanceNormPrecisionTolerance);