tor-browser

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

cast.https.any.js (46334B)


      1 // META: title=test WebNN API cast 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-cast
     12 // Cast each element in the input tensor to the target data type.
     13 // MLOperand cast(MLOperand input, MLOperandDataType type);
     14 
     15 
     16 const getCastPrecisionTolerance = (graphResources) => {
     17  const toleranceValueDict = {
     18    float32: 1,
     19    float16: 1,
     20    int32: 0,
     21    uint32: 0,
     22    int64: 0,
     23    int8: 0,
     24    uint8: 0
     25  };
     26  const expectedDataType =
     27      getExpectedDataTypeOfSingleOutput(graphResources.expectedOutputs);
     28  return {metricType: 'ULP', value: toleranceValueDict[expectedDataType]};
     29 };
     30 
     31 const castTests = [
     32  {
     33    'name': 'cast float32 0D tensor to int32',
     34    'graph': {
     35      'inputs': {
     36        'castInput': {
     37          'data': [84.77753448486328],
     38          'descriptor': {shape: [], dataType: 'float32'}
     39        }
     40      },
     41      'operators': [{
     42        'name': 'cast',
     43        'arguments': [{'input': 'castInput'}, {'type': 'int32'}],
     44        'outputs': 'castOutput'
     45      }],
     46      'expectedOutputs': {
     47        'castOutput':
     48            {'data': [84], 'descriptor': {shape: [], dataType: 'int32'}}
     49      }
     50    }
     51  },
     52  {
     53    'name': 'cast float32 1D tensor to int32',
     54    'graph': {
     55      'inputs': {
     56        'castInput': {
     57          'data': [
     58            102.1578369140625,   -43.5,
     59            52.84621810913086,   -99.9583511352539,
     60            6.729493141174316,   92.66157531738281,
     61            -10.377813339233398, 106.65289306640625,
     62            -7.126272678375244,  91.51563262939453,
     63            -50.87134552001953,  83.38890075683594,
     64            72.9759750366211,    -31.015382766723633,
     65            79.94034576416016,   41.5,
     66            35.727149963378906,  -2.5,
     67            -96.05252838134766,  -86.76212310791016,
     68            -27.49382972717285,  -23.836687088012695,
     69            70.77123260498047,   83.5
     70          ],
     71          'descriptor': {shape: [24], dataType: 'float32'}
     72        }
     73      },
     74      'operators': [{
     75        'name': 'cast',
     76        'arguments': [{'input': 'castInput'}, {'type': 'int32'}],
     77        'outputs': 'castOutput'
     78      }],
     79      'expectedOutputs': {
     80        'castOutput': {
     81          'data': [
     82            102, -43, 52, -99, 6,  92, -10, 106, -7,  91,  -50, 83,
     83            72,  -31, 79, 41,  35, -2, -96, -86, -27, -23, 70,  83
     84          ],
     85          'descriptor': {shape: [24], dataType: 'int32'}
     86        }
     87      }
     88    }
     89  },
     90  {
     91    'name': 'cast float32 2D tensor to int32',
     92    'graph': {
     93      'inputs': {
     94        'castInput': {
     95          'data': [
     96            102.1578369140625,   -43.5,
     97            52.84621810913086,   -99.9583511352539,
     98            6.729493141174316,   92.66157531738281,
     99            -10.377813339233398, 106.65289306640625,
    100            -7.126272678375244,  91.51563262939453,
    101            -50.87134552001953,  83.38890075683594,
    102            72.9759750366211,    -31.015382766723633,
    103            79.94034576416016,   41.5,
    104            35.727149963378906,  -2.5,
    105            -96.05252838134766,  -86.76212310791016,
    106            -27.49382972717285,  -23.836687088012695,
    107            70.77123260498047,   83.5
    108          ],
    109          'descriptor': {shape: [4, 6], dataType: 'float32'}
    110        }
    111      },
    112      'operators': [{
    113        'name': 'cast',
    114        'arguments': [{'input': 'castInput'}, {'type': 'int32'}],
    115        'outputs': 'castOutput'
    116      }],
    117      'expectedOutputs': {
    118        'castOutput': {
    119          'data': [
    120            102, -43, 52, -99, 6,  92, -10, 106, -7,  91,  -50, 83,
    121            72,  -31, 79, 41,  35, -2, -96, -86, -27, -23, 70,  83
    122          ],
    123          'descriptor': {shape: [4, 6], dataType: 'int32'}
    124        }
    125      }
    126    }
    127  },
    128  {
    129    'name': 'cast float32 3D tensor to int32',
    130    'graph': {
    131      'inputs': {
    132        'castInput': {
    133          'data': [
    134            102.1578369140625,   -43.5,
    135            52.84621810913086,   -99.9583511352539,
    136            6.729493141174316,   92.66157531738281,
    137            -10.377813339233398, 106.65289306640625,
    138            -7.126272678375244,  91.51563262939453,
    139            -50.87134552001953,  83.38890075683594,
    140            72.9759750366211,    -31.015382766723633,
    141            79.94034576416016,   41.5,
    142            35.727149963378906,  -2.5,
    143            -96.05252838134766,  -86.76212310791016,
    144            -27.49382972717285,  -23.836687088012695,
    145            70.77123260498047,   83.5
    146          ],
    147          'descriptor': {shape: [2, 3, 4], dataType: 'float32'}
    148        }
    149      },
    150      'operators': [{
    151        'name': 'cast',
    152        'arguments': [{'input': 'castInput'}, {'type': 'int32'}],
    153        'outputs': 'castOutput'
    154      }],
    155      'expectedOutputs': {
    156        'castOutput': {
    157          'data': [
    158            102, -43, 52, -99, 6,  92, -10, 106, -7,  91,  -50, 83,
    159            72,  -31, 79, 41,  35, -2, -96, -86, -27, -23, 70,  83
    160          ],
    161          'descriptor': {shape: [2, 3, 4], dataType: 'int32'}
    162        }
    163      }
    164    }
    165  },
    166  {
    167    'name': 'cast float32 4D tensor to int32',
    168    'graph': {
    169      'inputs': {
    170        'castInput': {
    171          'data': [
    172            102.1578369140625,   -43.5,
    173            52.84621810913086,   -99.9583511352539,
    174            6.729493141174316,   92.66157531738281,
    175            -10.377813339233398, 106.65289306640625,
    176            -7.126272678375244,  91.51563262939453,
    177            -50.87134552001953,  83.38890075683594,
    178            72.9759750366211,    -31.015382766723633,
    179            79.94034576416016,   41.5,
    180            35.727149963378906,  -2.5,
    181            -96.05252838134766,  -86.76212310791016,
    182            -27.49382972717285,  -23.836687088012695,
    183            70.77123260498047,   83.5
    184          ],
    185          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
    186        }
    187      },
    188      'operators': [{
    189        'name': 'cast',
    190        'arguments': [{'input': 'castInput'}, {'type': 'int32'}],
    191        'outputs': 'castOutput'
    192      }],
    193      'expectedOutputs': {
    194        'castOutput': {
    195          'data': [
    196            102, -43, 52, -99, 6,  92, -10, 106, -7,  91,  -50, 83,
    197            72,  -31, 79, 41,  35, -2, -96, -86, -27, -23, 70,  83
    198          ],
    199          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int32'}
    200        }
    201      }
    202    }
    203  },
    204  {
    205    'name': 'cast float32 5D tensor to int32',
    206    'graph': {
    207      'inputs': {
    208        'castInput': {
    209          'data': [
    210            102.1578369140625,   -43.5,
    211            52.84621810913086,   -99.9583511352539,
    212            6.729493141174316,   92.66157531738281,
    213            -10.377813339233398, 106.65289306640625,
    214            -7.126272678375244,  91.51563262939453,
    215            -50.87134552001953,  83.38890075683594,
    216            72.9759750366211,    -31.015382766723633,
    217            79.94034576416016,   41.5,
    218            35.727149963378906,  -2.5,
    219            -96.05252838134766,  -86.76212310791016,
    220            -27.49382972717285,  -23.836687088012695,
    221            70.77123260498047,   83.5
    222          ],
    223          'descriptor': {shape: [2, 1, 4, 1, 3], dataType: 'float32'}
    224        }
    225      },
    226      'operators': [{
    227        'name': 'cast',
    228        'arguments': [{'input': 'castInput'}, {'type': 'int32'}],
    229        'outputs': 'castOutput'
    230      }],
    231      'expectedOutputs': {
    232        'castOutput': {
    233          'data': [
    234            102, -43, 52, -99, 6,  92, -10, 106, -7,  91,  -50, 83,
    235            72,  -31, 79, 41,  35, -2, -96, -86, -27, -23, 70,  83
    236          ],
    237          'descriptor': {shape: [2, 1, 4, 1, 3], dataType: 'int32'}
    238        }
    239      }
    240    }
    241  },
    242  {
    243    'name': 'cast float32 4D tensor to float16',
    244    'graph': {
    245      'inputs': {
    246        'castInput': {
    247          'data': [
    248            102.1578369140625,  43.60371780395508,  52.84621810913086,
    249            99.9583511352539,   6.729493141174316,  92.66157531738281,
    250            10.377813339233398, 106.65289306640625, 7.126272678375244,
    251            91.51563262939453,  50.87134552001953,  83.38890075683594,
    252            72.9759750366211,   31.015382766723633, 79.94034576416016,
    253            41.844703674316406, 35.727149963378906, 2.614182949066162,
    254            96.05252838134766,  86.76212310791016,  27.49382972717285,
    255            23.836687088012695, 70.77123260498047,  83.8347396850586
    256          ],
    257          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
    258        }
    259      },
    260      'operators': [{
    261        'name': 'cast',
    262        'arguments': [{'input': 'castInput'}, {'type': 'float16'}],
    263        'outputs': 'castOutput'
    264      }],
    265      'expectedOutputs': {
    266        'castOutput': {
    267          'data': [
    268            102.1875, 43.59375,  52.84375, 99.9375,  6.73046875, 92.6875,
    269            10.375,   106.625,   7.125,    91.5,     50.875,     83.375,
    270            73,       31.015625, 79.9375,  41.84375, 35.71875,   2.61328125,
    271            96.0625,  86.75,     27.5,     23.84375, 70.75,      83.8125
    272          ],
    273          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'}
    274        }
    275      }
    276    }
    277  },
    278  {
    279    'name': 'cast float32 4D tensor to uint32',
    280    'graph': {
    281      'inputs': {
    282        'castInput': {
    283          'data': [
    284            102.1578369140625,  43.60371780395508,  52.84621810913086,
    285            99.9583511352539,   6.729493141174316,  92.66157531738281,
    286            10.377813339233398, 106.65289306640625, 7.126272678375244,
    287            91.51563262939453,  50.87134552001953,  83.38890075683594,
    288            72.9759750366211,   31.015382766723633, 79.94034576416016,
    289            41.844703674316406, 35.727149963378906, 2.614182949066162,
    290            96.05252838134766,  86.76212310791016,  27.49382972717285,
    291            23.836687088012695, 70.77123260498047,  83.8347396850586
    292          ],
    293          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
    294        }
    295      },
    296      'operators': [{
    297        'name': 'cast',
    298        'arguments': [{'input': 'castInput'}, {'type': 'uint32'}],
    299        'outputs': 'castOutput'
    300      }],
    301      'expectedOutputs': {
    302        'castOutput': {
    303          'data': [
    304            102, 43, 52, 99, 6,  92, 10, 106, 7,  91, 50, 83,
    305            72,  31, 79, 41, 35, 2,  96, 86,  27, 23, 70, 83
    306          ],
    307          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint32'}
    308        }
    309      }
    310    }
    311  },
    312  {
    313    'name': 'cast float32 4D tensor to int64',
    314    'graph': {
    315      'inputs': {
    316        'castInput': {
    317          'data': [
    318            102.1578369140625,  43.60371780395508,  52.84621810913086,
    319            99.9583511352539,   6.729493141174316,  92.66157531738281,
    320            10.377813339233398, 106.65289306640625, 7.126272678375244,
    321            91.51563262939453,  50.87134552001953,  83.38890075683594,
    322            72.9759750366211,   31.015382766723633, 79.94034576416016,
    323            41.844703674316406, 35.727149963378906, 2.614182949066162,
    324            96.05252838134766,  86.76212310791016,  27.49382972717285,
    325            23.836687088012695, 70.77123260498047,  83.8347396850586
    326          ],
    327          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
    328        }
    329      },
    330      'operators': [{
    331        'name': 'cast',
    332        'arguments': [{'input': 'castInput'}, {'type': 'int64'}],
    333        'outputs': 'castOutput'
    334      }],
    335      'expectedOutputs': {
    336        'castOutput': {
    337          'data': [
    338            '102', '43', '52', '99', '6',  '92', '10', '106',
    339            '7',   '91', '50', '83', '72', '31', '79', '41',
    340            '35',  '2',  '96', '86', '27', '23', '70', '83'
    341          ],
    342          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int64'}
    343        }
    344      }
    345    }
    346  },
    347  {
    348    'name': 'cast float32 4D tensor to int8',
    349    'graph': {
    350      'inputs': {
    351        'castInput': {
    352          'data': [
    353            102.1578369140625,  43.60371780395508,  52.84621810913086,
    354            99.9583511352539,   6.729493141174316,  92.66157531738281,
    355            10.377813339233398, 106.65289306640625, 7.126272678375244,
    356            91.51563262939453,  50.87134552001953,  83.38890075683594,
    357            72.9759750366211,   31.015382766723633, 79.94034576416016,
    358            41.844703674316406, 35.727149963378906, 2.614182949066162,
    359            96.05252838134766,  86.76212310791016,  27.49382972717285,
    360            23.836687088012695, 70.77123260498047,  83.8347396850586
    361          ],
    362          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
    363        }
    364      },
    365      'operators': [{
    366        'name': 'cast',
    367        'arguments': [{'input': 'castInput'}, {'type': 'int8'}],
    368        'outputs': 'castOutput'
    369      }],
    370      'expectedOutputs': {
    371        'castOutput': {
    372          'data': [
    373            102, 43, 52, 99, 6,  92, 10, 106, 7,  91, 50, 83,
    374            72,  31, 79, 41, 35, 2,  96, 86,  27, 23, 70, 83
    375          ],
    376          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int8'}
    377        }
    378      }
    379    }
    380  },
    381  {
    382    'name': 'cast float32 4D tensor to uint8',
    383    'graph': {
    384      'inputs': {
    385        'castInput': {
    386          'data': [
    387            102.1578369140625,  43.60371780395508,  52.84621810913086,
    388            99.9583511352539,   6.729493141174316,  92.66157531738281,
    389            10.377813339233398, 106.65289306640625, 7.126272678375244,
    390            91.51563262939453,  50.87134552001953,  83.38890075683594,
    391            72.9759750366211,   31.015382766723633, 79.94034576416016,
    392            41.844703674316406, 35.727149963378906, 2.614182949066162,
    393            96.05252838134766,  86.76212310791016,  27.49382972717285,
    394            23.836687088012695, 70.77123260498047,  83.8347396850586
    395          ],
    396          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
    397        }
    398      },
    399      'operators': [{
    400        'name': 'cast',
    401        'arguments': [{'input': 'castInput'}, {'type': 'uint8'}],
    402        'outputs': 'castOutput'
    403      }],
    404      'expectedOutputs': {
    405        'castOutput': {
    406          'data': [
    407            102, 43, 52, 99, 6,  92, 10, 106, 7,  91, 50, 83,
    408            72,  31, 79, 41, 35, 2,  96, 86,  27, 23, 70, 83
    409          ],
    410          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'}
    411        }
    412      }
    413    }
    414  },
    415  {
    416    'name': 'cast float16 4D tensor to float32',
    417    'graph': {
    418      'inputs': {
    419        'castInput': {
    420          'data': [
    421            3.103515625, 32.40625, 62.15625, 51.75,      87.0625,    106.25,
    422            125.375,     112.9375, 70.8125,  39.1875,    10.3515625, 21.234375,
    423            99.75,       16.125,   115.625,  66,         49.375,     115.75,
    424            77,          57.15625, 61.6875,  12.9296875, 101.25,     123.9375
    425          ],
    426          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'}
    427        }
    428      },
    429      'operators': [{
    430        'name': 'cast',
    431        'arguments': [{'input': 'castInput'}, {'type': 'float32'}],
    432        'outputs': 'castOutput'
    433      }],
    434      'expectedOutputs': {
    435        'castOutput': {
    436          'data': [
    437            3.103515625, 32.40625, 62.15625, 51.75,      87.0625,    106.25,
    438            125.375,     112.9375, 70.8125,  39.1875,    10.3515625, 21.234375,
    439            99.75,       16.125,   115.625,  66,         49.375,     115.75,
    440            77,          57.15625, 61.6875,  12.9296875, 101.25,     123.9375
    441          ],
    442          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
    443        }
    444      }
    445    }
    446  },
    447  {
    448    'name': 'cast float16 4D tensor to int32',
    449    'graph': {
    450      'inputs': {
    451        'castInput': {
    452          'data': [
    453            3.103515625, 32.40625, 62.15625, 51.75,      87.0625,    106.25,
    454            125.375,     112.9375, 70.8125,  39.1875,    10.3515625, 21.234375,
    455            99.75,       16.125,   115.625,  66,         49.375,     115.75,
    456            77,          57.15625, 61.6875,  12.9296875, 101.25,     123.9375
    457          ],
    458          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'}
    459        }
    460      },
    461      'operators': [{
    462        'name': 'cast',
    463        'arguments': [{'input': 'castInput'}, {'type': 'int32'}],
    464        'outputs': 'castOutput'
    465      }],
    466      'expectedOutputs': {
    467        'castOutput': {
    468          'data': [
    469            3,  32, 62,  51, 87, 106, 125, 112, 70, 39, 10,  21,
    470            99, 16, 115, 66, 49, 115, 77,  57,  61, 12, 101, 123
    471          ],
    472          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int32'}
    473        }
    474      }
    475    }
    476  },
    477  {
    478    'name': 'cast float16 4D tensor to uint32',
    479    'graph': {
    480      'inputs': {
    481        'castInput': {
    482          'data': [
    483            3.103515625, 32.40625, 62.15625, 51.75,      87.0625,    106.25,
    484            125.375,     112.9375, 70.8125,  39.1875,    10.3515625, 21.234375,
    485            99.75,       16.125,   115.625,  66,         49.375,     115.75,
    486            77,          57.15625, 61.6875,  12.9296875, 101.25,     123.9375
    487          ],
    488          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'}
    489        }
    490      },
    491      'operators': [{
    492        'name': 'cast',
    493        'arguments': [{'input': 'castInput'}, {'type': 'uint32'}],
    494        'outputs': 'castOutput'
    495      }],
    496      'expectedOutputs': {
    497        'castOutput': {
    498          'data': [
    499            3,  32, 62,  51, 87, 106, 125, 112, 70, 39, 10,  21,
    500            99, 16, 115, 66, 49, 115, 77,  57,  61, 12, 101, 123
    501          ],
    502          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint32'}
    503        }
    504      }
    505    }
    506  },
    507  {
    508    'name': 'cast float16 4D tensor to int64',
    509    'graph': {
    510      'inputs': {
    511        'castInput': {
    512          'data': [
    513            3.103515625, 32.40625, 62.15625, 51.75,      87.0625,    106.25,
    514            125.375,     112.9375, 70.8125,  39.1875,    10.3515625, 21.234375,
    515            99.75,       16.125,   115.625,  66,         49.375,     115.75,
    516            77,          57.15625, 61.6875,  12.9296875, 101.25,     123.9375
    517          ],
    518          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'}
    519        }
    520      },
    521      'operators': [{
    522        'name': 'cast',
    523        'arguments': [{'input': 'castInput'}, {'type': 'int64'}],
    524        'outputs': 'castOutput'
    525      }],
    526      'expectedOutputs': {
    527        'castOutput': {
    528          'data': [
    529            '3',  '32',  '62', '51', '87', '106', '125', '112',
    530            '70', '39',  '10', '21', '99', '16',  '115', '66',
    531            '49', '115', '77', '57', '61', '12',  '101', '123'
    532          ],
    533          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int64'}
    534        }
    535      }
    536    }
    537  },
    538  {
    539    'name': 'cast float16 4D tensor to int8',
    540    'graph': {
    541      'inputs': {
    542        'castInput': {
    543          'data': [
    544            3.103515625, 32.40625, 62.15625, 51.75,      87.0625,    106.25,
    545            125.375,     112.9375, 70.8125,  39.1875,    10.3515625, 21.234375,
    546            99.75,       16.125,   115.625,  66,         49.375,     115.75,
    547            77,          57.15625, 61.6875,  12.9296875, 101.25,     123.9375
    548          ],
    549          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'}
    550        }
    551      },
    552      'operators': [{
    553        'name': 'cast',
    554        'arguments': [{'input': 'castInput'}, {'type': 'int8'}],
    555        'outputs': 'castOutput'
    556      }],
    557      'expectedOutputs': {
    558        'castOutput': {
    559          'data': [
    560            3,  32, 62,  51, 87, 106, 125, 112, 70, 39, 10,  21,
    561            99, 16, 115, 66, 49, 115, 77,  57,  61, 12, 101, 123
    562          ],
    563          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int8'}
    564        }
    565      }
    566    }
    567  },
    568  {
    569    'name': 'cast float16 4D tensor to uint8',
    570    'graph': {
    571      'inputs': {
    572        'castInput': {
    573          'data': [
    574            3.103515625, 32.40625, 62.15625, 51.75,      87.0625,    106.25,
    575            125.375,     112.9375, 70.8125,  39.1875,    10.3515625, 21.234375,
    576            99.75,       16.125,   115.625,  66,         49.375,     115.75,
    577            77,          57.15625, 61.6875,  12.9296875, 101.25,     123.9375
    578          ],
    579          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'}
    580        }
    581      },
    582      'operators': [{
    583        'name': 'cast',
    584        'arguments': [{'input': 'castInput'}, {'type': 'uint8'}],
    585        'outputs': 'castOutput'
    586      }],
    587      'expectedOutputs': {
    588        'castOutput': {
    589          'data': [
    590            3,  32, 62,  51, 87, 106, 125, 112, 70, 39, 10,  21,
    591            99, 16, 115, 66, 49, 115, 77,  57,  61, 12, 101, 123
    592          ],
    593          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'}
    594        }
    595      }
    596    }
    597  },
    598  {
    599    'name': 'cast int32 4D tensor to float32',
    600    'graph': {
    601      'inputs': {
    602        'castInput': {
    603          'data': [
    604            45, 55, 11, 21, 78, 104, 102, 66, 41, 110, 92, 69,
    605            48, 23, 58, 12, 33, 24,  101, 87, 49, 118, 1,  77
    606          ],
    607          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int32'}
    608        }
    609      },
    610      'operators': [{
    611        'name': 'cast',
    612        'arguments': [{'input': 'castInput'}, {'type': 'float32'}],
    613        'outputs': 'castOutput'
    614      }],
    615      'expectedOutputs': {
    616        'castOutput': {
    617          'data': [
    618            45, 55, 11, 21, 78, 104, 102, 66, 41, 110, 92, 69,
    619            48, 23, 58, 12, 33, 24,  101, 87, 49, 118, 1,  77
    620          ],
    621          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
    622        }
    623      }
    624    }
    625  },
    626  {
    627    'name': 'cast int32 4D constant tensor to float32',
    628    'graph': {
    629      'inputs': {
    630        'castInput': {
    631          'data': [
    632            45, 55, 11, 21, 78, 104, 102, 66, 41, 110, 92, 69,
    633            48, 23, 58, 12, 33, 24,  101, 87, 49, 118, 1,  77
    634          ],
    635          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int32'},
    636          'constant': true,
    637        }
    638      },
    639      'operators': [{
    640        'name': 'cast',
    641        'arguments': [{'input': 'castInput'}, {'type': 'float32'}],
    642        'outputs': 'castOutput'
    643      }],
    644      'expectedOutputs': {
    645        'castOutput': {
    646          'data': [
    647            45, 55, 11, 21, 78, 104, 102, 66, 41, 110, 92, 69,
    648            48, 23, 58, 12, 33, 24,  101, 87, 49, 118, 1,  77
    649          ],
    650          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
    651        }
    652      }
    653    }
    654  },
    655  {
    656    'name': 'cast int32 4D tensor to float16',
    657    'graph': {
    658      'inputs': {
    659        'castInput': {
    660          'data': [
    661            45, 55, 11, 21, 78, 104, 102, 66, 41, 110, 92, 69,
    662            48, 23, 58, 12, 33, 24,  101, 87, 49, 118, 1,  77
    663          ],
    664          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int32'}
    665        }
    666      },
    667      'operators': [{
    668        'name': 'cast',
    669        'arguments': [{'input': 'castInput'}, {'type': 'float16'}],
    670        'outputs': 'castOutput'
    671      }],
    672      'expectedOutputs': {
    673        'castOutput': {
    674          'data': [
    675            45, 55, 11, 21, 78, 104, 102, 66, 41, 110, 92, 69,
    676            48, 23, 58, 12, 33, 24,  101, 87, 49, 118, 1,  77
    677          ],
    678          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'}
    679        }
    680      }
    681    }
    682  },
    683  {
    684    'name': 'cast int32 4D tensor to int64',
    685    'graph': {
    686      'inputs': {
    687        'castInput': {
    688          'data': [
    689            45, 55, 11, 21, 78, 104, 102, 66, 41, 110, 92, 69,
    690            48, 23, 58, 12, 33, 24,  101, 87, 49, 118, 1,  77
    691          ],
    692          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int32'}
    693        }
    694      },
    695      'operators': [{
    696        'name': 'cast',
    697        'arguments': [{'input': 'castInput'}, {'type': 'int64'}],
    698        'outputs': 'castOutput'
    699      }],
    700      'expectedOutputs': {
    701        'castOutput': {
    702          'data': [
    703            '45', '55',  '11',  '21', '78', '104', '102', '66',
    704            '41', '110', '92',  '69', '48', '23',  '58',  '12',
    705            '33', '24',  '101', '87', '49', '118', '1',   '77'
    706          ],
    707          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int64'}
    708        }
    709      }
    710    }
    711  },
    712  {
    713    'name': 'cast int32 4D tensor to int8',
    714    'graph': {
    715      'inputs': {
    716        'castInput': {
    717          'data': [
    718            45, 55, 11, 21, 78, 104, 102, 66, 41, 110, 92, 69,
    719            48, 23, 58, 12, 33, 24,  101, 87, 49, 118, 1,  77
    720          ],
    721          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int32'}
    722        }
    723      },
    724      'operators': [{
    725        'name': 'cast',
    726        'arguments': [{'input': 'castInput'}, {'type': 'int8'}],
    727        'outputs': 'castOutput'
    728      }],
    729      'expectedOutputs': {
    730        'castOutput': {
    731          'data': [
    732            45, 55, 11, 21, 78, 104, 102, 66, 41, 110, 92, 69,
    733            48, 23, 58, 12, 33, 24,  101, 87, 49, 118, 1,  77
    734          ],
    735          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int8'}
    736        }
    737      }
    738    }
    739  },
    740  {
    741    'name': 'cast int32 4D tensor to uint8',
    742    'graph': {
    743      'inputs': {
    744        'castInput': {
    745          'data': [
    746            45, 55, 11, 21, 78, 104, 102, 66, 41, 110, 92, 69,
    747            48, 23, 58, 12, 33, 24,  101, 87, 49, 118, 1,  77
    748          ],
    749          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int32'}
    750        }
    751      },
    752      'operators': [{
    753        'name': 'cast',
    754        'arguments': [{'input': 'castInput'}, {'type': 'uint8'}],
    755        'outputs': 'castOutput'
    756      }],
    757      'expectedOutputs': {
    758        'castOutput': {
    759          'data': [
    760            45, 55, 11, 21, 78, 104, 102, 66, 41, 110, 92, 69,
    761            48, 23, 58, 12, 33, 24,  101, 87, 49, 118, 1,  77
    762          ],
    763          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'}
    764        }
    765      }
    766    }
    767  },
    768  {
    769    'name': 'cast uint32 4D tensor to float32',
    770    'graph': {
    771      'inputs': {
    772        'castInput': {
    773          'data': [
    774            34, 83, 113, 31, 62, 80,  8,   40, 104, 42, 6,  91,
    775            93, 21, 40,  21, 51, 110, 115, 12, 122, 68, 57, 72
    776          ],
    777          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint32'}
    778        }
    779      },
    780      'operators': [{
    781        'name': 'cast',
    782        'arguments': [{'input': 'castInput'}, {'type': 'float32'}],
    783        'outputs': 'castOutput'
    784      }],
    785      'expectedOutputs': {
    786        'castOutput': {
    787          'data': [
    788            34, 83, 113, 31, 62, 80,  8,   40, 104, 42, 6,  91,
    789            93, 21, 40,  21, 51, 110, 115, 12, 122, 68, 57, 72
    790          ],
    791          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
    792        }
    793      }
    794    }
    795  },
    796  {
    797    'name': 'cast uint32 4D tensor to float16',
    798    'graph': {
    799      'inputs': {
    800        'castInput': {
    801          'data': [
    802            34, 83, 113, 31, 62, 80,  8,   40, 104, 42, 6,  91,
    803            93, 21, 40,  21, 51, 110, 115, 12, 122, 68, 57, 72
    804          ],
    805          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint32'}
    806        }
    807      },
    808      'operators': [{
    809        'name': 'cast',
    810        'arguments': [{'input': 'castInput'}, {'type': 'float16'}],
    811        'outputs': 'castOutput'
    812      }],
    813      'expectedOutputs': {
    814        'castOutput': {
    815          'data': [
    816            34, 83, 113, 31, 62, 80,  8,   40, 104, 42, 6,  91,
    817            93, 21, 40,  21, 51, 110, 115, 12, 122, 68, 57, 72
    818          ],
    819          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'}
    820        }
    821      }
    822    }
    823  },
    824  {
    825    'name': 'cast uint32 4D tensor to int32',
    826    'graph': {
    827      'inputs': {
    828        'castInput': {
    829          'data': [
    830            34, 83, 113, 31, 62, 80,  8,   40, 104, 42, 6,  91,
    831            93, 21, 40,  21, 51, 110, 115, 12, 122, 68, 57, 72
    832          ],
    833          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint32'}
    834        }
    835      },
    836      'operators': [{
    837        'name': 'cast',
    838        'arguments': [{'input': 'castInput'}, {'type': 'int32'}],
    839        'outputs': 'castOutput'
    840      }],
    841      'expectedOutputs': {
    842        'castOutput': {
    843          'data': [
    844            34, 83, 113, 31, 62, 80,  8,   40, 104, 42, 6,  91,
    845            93, 21, 40,  21, 51, 110, 115, 12, 122, 68, 57, 72
    846          ],
    847          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int32'}
    848        }
    849      }
    850    }
    851  },
    852  {
    853    'name': 'cast uint32 4D tensor to int64',
    854    'graph': {
    855      'inputs': {
    856        'castInput': {
    857          'data': [
    858            34, 83, 113, 31, 62, 80,  8,   40, 104, 42, 6,  91,
    859            93, 21, 40,  21, 51, 110, 115, 12, 122, 68, 57, 72
    860          ],
    861          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint32'}
    862        }
    863      },
    864      'operators': [{
    865        'name': 'cast',
    866        'arguments': [{'input': 'castInput'}, {'type': 'int64'}],
    867        'outputs': 'castOutput'
    868      }],
    869      'expectedOutputs': {
    870        'castOutput': {
    871          'data': [
    872            '34',  '83',  '113', '31', '62',  '80', '8',  '40',
    873            '104', '42',  '6',   '91', '93',  '21', '40', '21',
    874            '51',  '110', '115', '12', '122', '68', '57', '72'
    875          ],
    876          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int64'}
    877        }
    878      }
    879    }
    880  },
    881  {
    882    'name': 'cast uint32 4D tensor to int8',
    883    'graph': {
    884      'inputs': {
    885        'castInput': {
    886          'data': [
    887            34, 83, 113, 31, 62, 80,  8,   40, 104, 42, 6,  91,
    888            93, 21, 40,  21, 51, 110, 115, 12, 122, 68, 57, 72
    889          ],
    890          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint32'}
    891        }
    892      },
    893      'operators': [{
    894        'name': 'cast',
    895        'arguments': [{'input': 'castInput'}, {'type': 'int8'}],
    896        'outputs': 'castOutput'
    897      }],
    898      'expectedOutputs': {
    899        'castOutput': {
    900          'data': [
    901            34, 83, 113, 31, 62, 80,  8,   40, 104, 42, 6,  91,
    902            93, 21, 40,  21, 51, 110, 115, 12, 122, 68, 57, 72
    903          ],
    904          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int8'}
    905        }
    906      }
    907    }
    908  },
    909  {
    910    'name': 'cast uint32 4D tensor to uint8',
    911    'graph': {
    912      'inputs': {
    913        'castInput': {
    914          'data': [
    915            34, 83, 113, 31, 62, 80,  8,   40, 104, 42, 6,  91,
    916            93, 21, 40,  21, 51, 110, 115, 12, 122, 68, 57, 72
    917          ],
    918          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint32'}
    919        }
    920      },
    921      'operators': [{
    922        'name': 'cast',
    923        'arguments': [{'input': 'castInput'}, {'type': 'uint8'}],
    924        'outputs': 'castOutput'
    925      }],
    926      'expectedOutputs': {
    927        'castOutput': {
    928          'data': [
    929            34, 83, 113, 31, 62, 80,  8,   40, 104, 42, 6,  91,
    930            93, 21, 40,  21, 51, 110, 115, 12, 122, 68, 57, 72
    931          ],
    932          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'}
    933        }
    934      }
    935    }
    936  },
    937  {
    938    'name': 'cast int64 4D tensor to float32',
    939    'graph': {
    940      'inputs': {
    941        'castInput': {
    942          'data': [
    943            50, 1,  28, 20, 102, 86,  70, 38, 50,  19, 11, 4,
    944            56, 77, 40, 80, 45,  127, 4,  87, 125, 26, 63, 11
    945          ],
    946          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int64'}
    947        }
    948      },
    949      'operators': [{
    950        'name': 'cast',
    951        'arguments': [{'input': 'castInput'}, {'type': 'float32'}],
    952        'outputs': 'castOutput'
    953      }],
    954      'expectedOutputs': {
    955        'castOutput': {
    956          'data': [
    957            50, 1,  28, 20, 102, 86,  70, 38, 50,  19, 11, 4,
    958            56, 77, 40, 80, 45,  127, 4,  87, 125, 26, 63, 11
    959          ],
    960          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
    961        }
    962      }
    963    }
    964  },
    965  {
    966    'name': 'cast int64 4D tensor to float16',
    967    'graph': {
    968      'inputs': {
    969        'castInput': {
    970          'data': [
    971            50, 1,  28, 20, 102, 86,  70, 38, 50,  19, 11, 4,
    972            56, 77, 40, 80, 45,  127, 4,  87, 125, 26, 63, 11
    973          ],
    974          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int64'}
    975        }
    976      },
    977      'operators': [{
    978        'name': 'cast',
    979        'arguments': [{'input': 'castInput'}, {'type': 'float16'}],
    980        'outputs': 'castOutput'
    981      }],
    982      'expectedOutputs': {
    983        'castOutput': {
    984          'data': [
    985            50, 1,  28, 20, 102, 86,  70, 38, 50,  19, 11, 4,
    986            56, 77, 40, 80, 45,  127, 4,  87, 125, 26, 63, 11
    987          ],
    988          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'}
    989        }
    990      }
    991    }
    992  },
    993  {
    994    'name': 'cast int64 4D tensor to int32',
    995    'graph': {
    996      'inputs': {
    997        'castInput': {
    998          'data': [
    999            50, 1,  28, 20, 102, 86,  70, 38, 50,  19, 11, 4,
   1000            56, 77, 40, 80, 45,  127, 4,  87, 125, 26, 63, 11
   1001          ],
   1002          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int64'}
   1003        }
   1004      },
   1005      'operators': [{
   1006        'name': 'cast',
   1007        'arguments': [{'input': 'castInput'}, {'type': 'int32'}],
   1008        'outputs': 'castOutput'
   1009      }],
   1010      'expectedOutputs': {
   1011        'castOutput': {
   1012          'data': [
   1013            50, 1,  28, 20, 102, 86,  70, 38, 50,  19, 11, 4,
   1014            56, 77, 40, 80, 45,  127, 4,  87, 125, 26, 63, 11
   1015          ],
   1016          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int32'}
   1017        }
   1018      }
   1019    }
   1020  },
   1021  {
   1022    'name': 'cast int64 4D tensor to uint32',
   1023    'graph': {
   1024      'inputs': {
   1025        'castInput': {
   1026          'data': [
   1027            50, 1,  28, 20, 102, 86,  70, 38, 50,  19, 11, 4,
   1028            56, 77, 40, 80, 45,  127, 4,  87, 125, 26, 63, 11
   1029          ],
   1030          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int64'}
   1031        }
   1032      },
   1033      'operators': [{
   1034        'name': 'cast',
   1035        'arguments': [{'input': 'castInput'}, {'type': 'uint32'}],
   1036        'outputs': 'castOutput'
   1037      }],
   1038      'expectedOutputs': {
   1039        'castOutput': {
   1040          'data': [
   1041            50, 1,  28, 20, 102, 86,  70, 38, 50,  19, 11, 4,
   1042            56, 77, 40, 80, 45,  127, 4,  87, 125, 26, 63, 11
   1043          ],
   1044          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint32'}
   1045        }
   1046      }
   1047    }
   1048  },
   1049  {
   1050    'name': 'cast int64 4D tensor to int8',
   1051    'graph': {
   1052      'inputs': {
   1053        'castInput': {
   1054          'data': [
   1055            50, 1,  28, 20, 102, 86,  70, 38, 50,  19, 11, 4,
   1056            56, 77, 40, 80, 45,  127, 4,  87, 125, 26, 63, 11
   1057          ],
   1058          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int64'}
   1059        }
   1060      },
   1061      'operators': [{
   1062        'name': 'cast',
   1063        'arguments': [{'input': 'castInput'}, {'type': 'int8'}],
   1064        'outputs': 'castOutput'
   1065      }],
   1066      'expectedOutputs': {
   1067        'castOutput': {
   1068          'data': [
   1069            50, 1,  28, 20, 102, 86,  70, 38, 50,  19, 11, 4,
   1070            56, 77, 40, 80, 45,  127, 4,  87, 125, 26, 63, 11
   1071          ],
   1072          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int8'}
   1073        }
   1074      }
   1075    }
   1076  },
   1077  {
   1078    'name': 'cast int64 4D tensor to uint8',
   1079    'graph': {
   1080      'inputs': {
   1081        'castInput': {
   1082          'data': [
   1083            50, 1,  28, 20, 102, 86,  70, 38, 50,  19, 11, 4,
   1084            56, 77, 40, 80, 45,  127, 4,  87, 125, 26, 63, 11
   1085          ],
   1086          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int64'}
   1087        }
   1088      },
   1089      'operators': [{
   1090        'name': 'cast',
   1091        'arguments': [{'input': 'castInput'}, {'type': 'uint8'}],
   1092        'outputs': 'castOutput'
   1093      }],
   1094      'expectedOutputs': {
   1095        'castOutput': {
   1096          'data': [
   1097            50, 1,  28, 20, 102, 86,  70, 38, 50,  19, 11, 4,
   1098            56, 77, 40, 80, 45,  127, 4,  87, 125, 26, 63, 11
   1099          ],
   1100          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'}
   1101        }
   1102      }
   1103    }
   1104  },
   1105  {
   1106    'name': 'cast int8 0D constant tensor to int32',
   1107    'graph': {
   1108      'inputs': {
   1109        'castInput': {
   1110          'data': [17],
   1111          'descriptor': {shape: [], dataType: 'int8'},
   1112          'constant': true
   1113        }
   1114      },
   1115      'operators': [{
   1116        'name': 'cast',
   1117        'arguments': [{'input': 'castInput'}, {'type': 'int32'}],
   1118        'outputs': 'castOutput'
   1119      }],
   1120      'expectedOutputs': {
   1121        'castOutput':
   1122            {'data': [17], 'descriptor': {shape: [], dataType: 'int32'}}
   1123      }
   1124    }
   1125  },
   1126  {
   1127    'name': 'cast int8 1D constant tensor to int32',
   1128    'graph': {
   1129      'inputs': {
   1130        'castInput': {
   1131          'data': [
   1132            123, 17, 31, 77, 88, 44, 84, 40, 14, 64, 109, 4,
   1133            2,   0,  45, 47, 72, 88, 82, 4,  73, 36, 65,  117
   1134          ],
   1135          'descriptor': {shape: [24], dataType: 'int8'},
   1136          'constant': true
   1137        }
   1138      },
   1139      'operators': [{
   1140        'name': 'cast',
   1141        'arguments': [{'input': 'castInput'}, {'type': 'int32'}],
   1142        'outputs': 'castOutput'
   1143      }],
   1144      'expectedOutputs': {
   1145        'castOutput': {
   1146          'data': [
   1147            123, 17, 31, 77, 88, 44, 84, 40, 14, 64, 109, 4,
   1148            2,   0,  45, 47, 72, 88, 82, 4,  73, 36, 65,  117
   1149          ],
   1150          'descriptor': {shape: [24], dataType: 'int32'}
   1151        }
   1152      }
   1153    }
   1154  },
   1155  {
   1156    'name': 'cast int8 4D tensor to float32',
   1157    'graph': {
   1158      'inputs': {
   1159        'castInput': {
   1160          'data': [
   1161            123, 17, 31, 77, 88, 44, 84, 40, 14, 64, 109, 4,
   1162            2,   0,  45, 47, 72, 88, 82, 4,  73, 36, 65,  117
   1163          ],
   1164          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int8'}
   1165        }
   1166      },
   1167      'operators': [{
   1168        'name': 'cast',
   1169        'arguments': [{'input': 'castInput'}, {'type': 'float32'}],
   1170        'outputs': 'castOutput'
   1171      }],
   1172      'expectedOutputs': {
   1173        'castOutput': {
   1174          'data': [
   1175            123, 17, 31, 77, 88, 44, 84, 40, 14, 64, 109, 4,
   1176            2,   0,  45, 47, 72, 88, 82, 4,  73, 36, 65,  117
   1177          ],
   1178          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
   1179        }
   1180      }
   1181    }
   1182  },
   1183  {
   1184    'name': 'cast int8 4D tensor to float16',
   1185    'graph': {
   1186      'inputs': {
   1187        'castInput': {
   1188          'data': [
   1189            123, 17, 31, 77, 88, 44, 84, 40, 14, 64, 109, 4,
   1190            2,   0,  45, 47, 72, 88, 82, 4,  73, 36, 65,  117
   1191          ],
   1192          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int8'}
   1193        }
   1194      },
   1195      'operators': [{
   1196        'name': 'cast',
   1197        'arguments': [{'input': 'castInput'}, {'type': 'float16'}],
   1198        'outputs': 'castOutput'
   1199      }],
   1200      'expectedOutputs': {
   1201        'castOutput': {
   1202          'data': [
   1203            123, 17, 31, 77, 88, 44, 84, 40, 14, 64, 109, 4,
   1204            2,   0,  45, 47, 72, 88, 82, 4,  73, 36, 65,  117
   1205          ],
   1206          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'}
   1207        }
   1208      }
   1209    }
   1210  },
   1211  {
   1212    'name': 'cast int8 4D tensor to int32',
   1213    'graph': {
   1214      'inputs': {
   1215        'castInput': {
   1216          'data': [
   1217            123, 17, 31, 77, 88, 44, 84, 40, 14, 64, 109, 4,
   1218            2,   0,  45, 47, 72, 88, 82, 4,  73, 36, 65,  117
   1219          ],
   1220          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int8'}
   1221        }
   1222      },
   1223      'operators': [{
   1224        'name': 'cast',
   1225        'arguments': [{'input': 'castInput'}, {'type': 'int32'}],
   1226        'outputs': 'castOutput'
   1227      }],
   1228      'expectedOutputs': {
   1229        'castOutput': {
   1230          'data': [
   1231            123, 17, 31, 77, 88, 44, 84, 40, 14, 64, 109, 4,
   1232            2,   0,  45, 47, 72, 88, 82, 4,  73, 36, 65,  117
   1233          ],
   1234          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int32'}
   1235        }
   1236      }
   1237    }
   1238  },
   1239  {
   1240    'name': 'cast int8 4D tensor to uint32',
   1241    'graph': {
   1242      'inputs': {
   1243        'castInput': {
   1244          'data': [
   1245            123, 17, 31, 77, 88, 44, 84, 40, 14, 64, 109, 4,
   1246            2,   0,  45, 47, 72, 88, 82, 4,  73, 36, 65,  117
   1247          ],
   1248          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int8'}
   1249        }
   1250      },
   1251      'operators': [{
   1252        'name': 'cast',
   1253        'arguments': [{'input': 'castInput'}, {'type': 'uint32'}],
   1254        'outputs': 'castOutput'
   1255      }],
   1256      'expectedOutputs': {
   1257        'castOutput': {
   1258          'data': [
   1259            123, 17, 31, 77, 88, 44, 84, 40, 14, 64, 109, 4,
   1260            2,   0,  45, 47, 72, 88, 82, 4,  73, 36, 65,  117
   1261          ],
   1262          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint32'}
   1263        }
   1264      }
   1265    }
   1266  },
   1267  {
   1268    'name': 'cast int8 4D tensor to int64',
   1269    'graph': {
   1270      'inputs': {
   1271        'castInput': {
   1272          'data': [
   1273            123, 17, 31, 77, 88, 44, 84, 40, 14, 64, 109, 4,
   1274            2,   0,  45, 47, 72, 88, 82, 4,  73, 36, 65,  117
   1275          ],
   1276          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int8'}
   1277        }
   1278      },
   1279      'operators': [{
   1280        'name': 'cast',
   1281        'arguments': [{'input': 'castInput'}, {'type': 'int64'}],
   1282        'outputs': 'castOutput'
   1283      }],
   1284      'expectedOutputs': {
   1285        'castOutput': {
   1286          'data': [
   1287            '123', '17', '31',  '77', '88', '44', '84', '40',
   1288            '14',  '64', '109', '4',  '2',  '0',  '45', '47',
   1289            '72',  '88', '82',  '4',  '73', '36', '65', '117'
   1290          ],
   1291          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int64'}
   1292        }
   1293      }
   1294    }
   1295  },
   1296  {
   1297    'name': 'cast int8 4D tensor to uint8',
   1298    'graph': {
   1299      'inputs': {
   1300        'castInput': {
   1301          'data': [
   1302            123, 17, 31, 77, 88, 44, 84, 40, 14, 64, 109, 4,
   1303            2,   0,  45, 47, 72, 88, 82, 4,  73, 36, 65,  117
   1304          ],
   1305          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int8'}
   1306        }
   1307      },
   1308      'operators': [{
   1309        'name': 'cast',
   1310        'arguments': [{'input': 'castInput'}, {'type': 'uint8'}],
   1311        'outputs': 'castOutput'
   1312      }],
   1313      'expectedOutputs': {
   1314        'castOutput': {
   1315          'data': [
   1316            123, 17, 31, 77, 88, 44, 84, 40, 14, 64, 109, 4,
   1317            2,   0,  45, 47, 72, 88, 82, 4,  73, 36, 65,  117
   1318          ],
   1319          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'}
   1320        }
   1321      }
   1322    }
   1323  },
   1324  {
   1325    'name': 'cast uint8 4D tensor to float32',
   1326    'graph': {
   1327      'inputs': {
   1328        'castInput': {
   1329          'data': [
   1330            10,  112, 121, 120, 22, 105, 41, 30, 75, 121, 55, 47,
   1331            121, 24,  16,  33,  97, 24,  3,  37, 45, 6,   56, 57
   1332          ],
   1333          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'}
   1334        }
   1335      },
   1336      'operators': [{
   1337        'name': 'cast',
   1338        'arguments': [{'input': 'castInput'}, {'type': 'float32'}],
   1339        'outputs': 'castOutput'
   1340      }],
   1341      'expectedOutputs': {
   1342        'castOutput': {
   1343          'data': [
   1344            10,  112, 121, 120, 22, 105, 41, 30, 75, 121, 55, 47,
   1345            121, 24,  16,  33,  97, 24,  3,  37, 45, 6,   56, 57
   1346          ],
   1347          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float32'}
   1348        }
   1349      }
   1350    }
   1351  },
   1352  {
   1353    'name': 'cast uint8 4D tensor to float16',
   1354    'graph': {
   1355      'inputs': {
   1356        'castInput': {
   1357          'data': [
   1358            10,  112, 121, 120, 22, 105, 41, 30, 75, 121, 55, 47,
   1359            121, 24,  16,  33,  97, 24,  3,  37, 45, 6,   56, 57
   1360          ],
   1361          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'}
   1362        }
   1363      },
   1364      'operators': [{
   1365        'name': 'cast',
   1366        'arguments': [{'input': 'castInput'}, {'type': 'float16'}],
   1367        'outputs': 'castOutput'
   1368      }],
   1369      'expectedOutputs': {
   1370        'castOutput': {
   1371          'data': [
   1372            10,  112, 121, 120, 22, 105, 41, 30, 75, 121, 55, 47,
   1373            121, 24,  16,  33,  97, 24,  3,  37, 45, 6,   56, 57
   1374          ],
   1375          'descriptor': {shape: [2, 2, 2, 3], dataType: 'float16'}
   1376        }
   1377      }
   1378    }
   1379  },
   1380  {
   1381    'name': 'cast uint8 4D tensor to int32',
   1382    'graph': {
   1383      'inputs': {
   1384        'castInput': {
   1385          'data': [
   1386            10,  112, 121, 120, 22, 105, 41, 30, 75, 121, 55, 47,
   1387            121, 24,  16,  33,  97, 24,  3,  37, 45, 6,   56, 57
   1388          ],
   1389          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'}
   1390        }
   1391      },
   1392      'operators': [{
   1393        'name': 'cast',
   1394        'arguments': [{'input': 'castInput'}, {'type': 'int32'}],
   1395        'outputs': 'castOutput'
   1396      }],
   1397      'expectedOutputs': {
   1398        'castOutput': {
   1399          'data': [
   1400            10,  112, 121, 120, 22, 105, 41, 30, 75, 121, 55, 47,
   1401            121, 24,  16,  33,  97, 24,  3,  37, 45, 6,   56, 57
   1402          ],
   1403          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int32'}
   1404        }
   1405      }
   1406    }
   1407  },
   1408  {
   1409    'name': 'cast uint8 4D tensor to uint32',
   1410    'graph': {
   1411      'inputs': {
   1412        'castInput': {
   1413          'data': [
   1414            10,  112, 121, 120, 22, 105, 41, 30, 75, 121, 55, 47,
   1415            121, 24,  16,  33,  97, 24,  3,  37, 45, 6,   56, 57
   1416          ],
   1417          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'}
   1418        }
   1419      },
   1420      'operators': [{
   1421        'name': 'cast',
   1422        'arguments': [{'input': 'castInput'}, {'type': 'uint32'}],
   1423        'outputs': 'castOutput'
   1424      }],
   1425      'expectedOutputs': {
   1426        'castOutput': {
   1427          'data': [
   1428            10,  112, 121, 120, 22, 105, 41, 30, 75, 121, 55, 47,
   1429            121, 24,  16,  33,  97, 24,  3,  37, 45, 6,   56, 57
   1430          ],
   1431          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint32'}
   1432        }
   1433      }
   1434    }
   1435  },
   1436  {
   1437    'name': 'cast uint8 4D tensor to int64',
   1438    'graph': {
   1439      'inputs': {
   1440        'castInput': {
   1441          'data': [
   1442            10,  112, 121, 120, 22, 105, 41, 30, 75, 121, 55, 47,
   1443            121, 24,  16,  33,  97, 24,  3,  37, 45, 6,   56, 57
   1444          ],
   1445          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'}
   1446        }
   1447      },
   1448      'operators': [{
   1449        'name': 'cast',
   1450        'arguments': [{'input': 'castInput'}, {'type': 'int64'}],
   1451        'outputs': 'castOutput'
   1452      }],
   1453      'expectedOutputs': {
   1454        'castOutput': {
   1455          'data': [
   1456            '10', '112', '121', '120', '22',  '105', '41', '30',
   1457            '75', '121', '55',  '47',  '121', '24',  '16', '33',
   1458            '97', '24',  '3',   '37',  '45',  '6',   '56', '57'
   1459          ],
   1460          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int64'}
   1461        }
   1462      }
   1463    }
   1464  },
   1465  {
   1466    'name': 'cast uint8 4D tensor to int8',
   1467    'graph': {
   1468      'inputs': {
   1469        'castInput': {
   1470          'data': [
   1471            10,  112, 121, 120, 22, 105, 41, 30, 75, 121, 55, 47,
   1472            121, 24,  16,  33,  97, 24,  3,  37, 45, 6,   56, 57
   1473          ],
   1474          'descriptor': {shape: [2, 2, 2, 3], dataType: 'uint8'}
   1475        }
   1476      },
   1477      'operators': [{
   1478        'name': 'cast',
   1479        'arguments': [{'input': 'castInput'}, {'type': 'int8'}],
   1480        'outputs': 'castOutput'
   1481      }],
   1482      'expectedOutputs': {
   1483        'castOutput': {
   1484          'data': [
   1485            10,  112, 121, 120, 22, 105, 41, 30, 75, 121, 55, 47,
   1486            121, 24,  16,  33,  97, 24,  3,  37, 45, 6,   56, 57
   1487          ],
   1488          'descriptor': {shape: [2, 2, 2, 3], dataType: 'int8'}
   1489        }
   1490      }
   1491    }
   1492  }
   1493 ];
   1494 
   1495 webnn_conformance_test(
   1496    castTests, buildAndExecuteGraph, getCastPrecisionTolerance);