elu.https.any.js (1323B)
1 // META: title=validation tests for WebNN API elu operation 2 // META: global=window 3 // META: variant=?cpu 4 // META: variant=?gpu 5 // META: variant=?npu 6 // META: script=../resources/utils_validation.js 7 8 'use strict'; 9 10 validateInputFromAnotherBuilder('elu'); 11 12 const label = 'elu_xxx'; 13 const regrexp = new RegExp('\\[' + label + '\\]'); 14 15 validateSingleInputOperation('elu', label); 16 17 promise_test(async t => { 18 const builder = new MLGraphBuilder(context); 19 const options = {alpha: 1.0}; 20 const input = builder.input('input', {dataType: 'float32', shape: [1, 2, 3]}); 21 const output = builder.elu(input, options); 22 assert_equals(output.dataType, 'float32'); 23 assert_array_equals(output.shape, [1, 2, 3]); 24 }, '[elu] Build with options'); 25 26 promise_test(async t => { 27 const builder = new MLGraphBuilder(context); 28 const options = {alpha: NaN}; 29 const input = builder.input('input', {dataType: 'float16', shape: []}); 30 assert_throws_js(TypeError, () => builder.elu(input, options)); 31 }, '[elu] Throw if options.alpha is NaN'); 32 33 promise_test(async t => { 34 const builder = new MLGraphBuilder(context); 35 const options = {alpha: Infinity}; 36 const input = builder.input('input', {dataType: 'float32', shape: [1]}); 37 assert_throws_js(TypeError, () => builder.elu(input, options)); 38 }, '[elu] Throw if options.alpha is Infinity');