tor-browser

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

logical_not.https.any.js (5748B)


      1 // META: title=test WebNN API element-wise logicalNot 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-logical
     12 // Invert the values of the input tensor to values 0 or 1, element-wise.
     13 //
     14 // MLOperand logicalNot(MLOperand a);
     15 
     16 const logicalNotTests = [
     17  {
     18    'name': 'logicalNot uint8 0D scalar',
     19    'graph': {
     20      'inputs': {
     21        'logicalNotInput':
     22            {'data': [1], 'descriptor': {shape: [], dataType: 'uint8'}}
     23      },
     24      'operators': [{
     25        'name': 'logicalNot',
     26        'arguments': [{'a': 'logicalNotInput'}],
     27        'outputs': 'logicalNotOutput'
     28      }],
     29      'expectedOutputs': {
     30        'logicalNotOutput':
     31            {'data': [0], 'descriptor': {shape: [], dataType: 'uint8'}}
     32      }
     33    }
     34  },
     35  {
     36    'name': 'logicalNot uint8 1D constant tensor',
     37    'graph': {
     38      'inputs': {
     39        'logicalNotInput': {
     40          'data': [
     41            204, 130, 90, 0,   147, 42, 10,  18,  13,  235, 0,   233,
     42            53,  83,  9,  254, 69,  56, 219, 109, 171, 0,   228, 135
     43          ],
     44          'descriptor': {shape: [24], dataType: 'uint8'},
     45          'constant': true
     46        }
     47      },
     48      'operators': [{
     49        'name': 'logicalNot',
     50        'arguments': [{'a': 'logicalNotInput'}],
     51        'outputs': 'logicalNotOutput'
     52      }],
     53      'expectedOutputs': {
     54        'logicalNotOutput': {
     55          'data': [
     56            0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
     57            0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
     58          ],
     59          'descriptor': {shape: [24], dataType: 'uint8'}
     60        }
     61      }
     62    }
     63  },
     64  {
     65    'name': 'logicalNot uint8 1D tensor',
     66    'graph': {
     67      'inputs': {
     68        'logicalNotInput': {
     69          'data': [
     70            204, 130, 90, 0,   147, 42, 10,  18,  13,  235, 0,   233,
     71            53,  83,  9,  254, 69,  56, 219, 109, 171, 0,   228, 135
     72          ],
     73          'descriptor': {shape: [24], dataType: 'uint8'}
     74        }
     75      },
     76      'operators': [{
     77        'name': 'logicalNot',
     78        'arguments': [{'a': 'logicalNotInput'}],
     79        'outputs': 'logicalNotOutput'
     80      }],
     81      'expectedOutputs': {
     82        'logicalNotOutput': {
     83          'data': [
     84            0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
     85            0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
     86          ],
     87          'descriptor': {shape: [24], dataType: 'uint8'}
     88        }
     89      }
     90    }
     91  },
     92  {
     93    'name': 'logicalNot uint8 2D tensor',
     94    'graph': {
     95      'inputs': {
     96        'logicalNotInput': {
     97          'data': [
     98            204, 130, 90, 0,   147, 42, 10,  18,  13,  235, 0,   233,
     99            53,  83,  9,  254, 69,  56, 219, 109, 171, 0,   228, 135
    100          ],
    101          'descriptor': {shape: [4, 6], dataType: 'uint8'}
    102        }
    103      },
    104      'operators': [{
    105        'name': 'logicalNot',
    106        'arguments': [{'a': 'logicalNotInput'}],
    107        'outputs': 'logicalNotOutput'
    108      }],
    109      'expectedOutputs': {
    110        'logicalNotOutput': {
    111          'data': [
    112            0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
    113            0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
    114          ],
    115          'descriptor': {shape: [4, 6], dataType: 'uint8'}
    116        }
    117      }
    118    }
    119  },
    120  {
    121    'name': 'logicalNot uint8 3D tensor',
    122    'graph': {
    123      'inputs': {
    124        'logicalNotInput': {
    125          'data': [
    126            204, 130, 90, 0,   147, 42, 10,  18,  13,  235, 0,   233,
    127            53,  83,  9,  254, 69,  56, 219, 109, 171, 0,   228, 135
    128          ],
    129          'descriptor': {shape: [2, 3, 4], dataType: 'uint8'}
    130        }
    131      },
    132      'operators': [{
    133        'name': 'logicalNot',
    134        'arguments': [{'a': 'logicalNotInput'}],
    135        'outputs': 'logicalNotOutput'
    136      }],
    137      'expectedOutputs': {
    138        'logicalNotOutput': {
    139          'data': [
    140            0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
    141            0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
    142          ],
    143          'descriptor': {shape: [2, 3, 4], dataType: 'uint8'}
    144        }
    145      }
    146    }
    147  },
    148  {
    149    'name': 'logicalNot uint8 4D tensor',
    150    'graph': {
    151      'inputs': {
    152        'logicalNotInput': {
    153          'data': [
    154            204, 130, 90, 0,   147, 42, 10,  18,  13,  235, 0,   233,
    155            53,  83,  9,  254, 69,  56, 219, 109, 171, 0,   228, 135
    156          ],
    157          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'}
    158        }
    159      },
    160      'operators': [{
    161        'name': 'logicalNot',
    162        'arguments': [{'a': 'logicalNotInput'}],
    163        'outputs': 'logicalNotOutput'
    164      }],
    165      'expectedOutputs': {
    166        'logicalNotOutput': {
    167          'data': [
    168            0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
    169            0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
    170          ],
    171          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'}
    172        }
    173      }
    174    }
    175  },
    176  {
    177    'name': 'logicalNot uint8 5D tensor',
    178    'graph': {
    179      'inputs': {
    180        'logicalNotInput': {
    181          'data': [
    182            204, 130, 90, 0,   147, 42, 10,  18,  13,  235, 0,   233,
    183            53,  83,  9,  254, 69,  56, 219, 109, 171, 0,   228, 135
    184          ],
    185          'descriptor': {shape: [2, 1, 4, 1, 3], dataType: 'uint8'}
    186        }
    187      },
    188      'operators': [{
    189        'name': 'logicalNot',
    190        'arguments': [{'a': 'logicalNotInput'}],
    191        'outputs': 'logicalNotOutput'
    192      }],
    193      'expectedOutputs': {
    194        'logicalNotOutput': {
    195          'data': [
    196            0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
    197            0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0
    198          ],
    199          'descriptor': {shape: [2, 1, 4, 1, 3], dataType: 'uint8'}
    200        }
    201      }
    202    }
    203  }
    204 ];
    205 
    206 webnn_conformance_test(
    207    logicalNotTests, buildAndExecuteGraph, getZeroULPTolerance);