From 5eb8973d524feeb227fa89697bba1ffecd1ba251 Mon Sep 17 00:00:00 2001 From: zesongw Date: Fri, 1 Dec 2023 14:01:53 +0800 Subject: [PATCH] Fix several issues - Set default DISABLE_WEBNN to false, to allow to build WebNN EP locally. - Update test suite for WebNN, comment tests with int32/int64 input. - Fix lint error. --- js/web/script/build.ts | 16 ++++-- js/web/test/suite-test-list.jsonc | 90 +++++++++++++++---------------- js/web/test/test-runner.ts | 2 +- 3 files changed, 58 insertions(+), 50 deletions(-) diff --git a/js/web/script/build.ts b/js/web/script/build.ts index 6cc75dd8bddf2..11892881a2adf 100644 --- a/js/web/script/build.ts +++ b/js/web/script/build.ts @@ -44,7 +44,7 @@ const SOURCE_ROOT_FOLDER = path.join(__dirname, '../..'); // /js/ const DEFAULT_DEFINE = { 'BUILD_DEFS.DISABLE_WEBGL': 'false', 'BUILD_DEFS.DISABLE_WEBGPU': 'false', - 'BUILD_DEFS.DISABLE_WEBNN': 'true', // Disable WebNN until CI is ready. + 'BUILD_DEFS.DISABLE_WEBNN': 'false', 'BUILD_DEFS.DISABLE_WASM': 'false', 'BUILD_DEFS.DISABLE_WASM_PROXY': 'false', 'BUILD_DEFS.DISABLE_WASM_THREAD': 'false', @@ -360,6 +360,7 @@ async function main() { ...DEFAULT_DEFINE, 'BUILD_DEFS.DISABLE_WEBGPU': 'true', 'BUILD_DEFS.DISABLE_WEBGL': 'true', + 'BUILD_DEFS.DISABLE_WEBNN': 'true', 'BUILD_DEFS.DISABLE_WASM_PROXY': 'true', 'BUILD_DEFS.DISABLE_WASM_THREAD': 'true', }, @@ -371,7 +372,7 @@ async function main() { await addBuildTask(buildOrt({ outputBundleName: 'ort.all', format: 'iife', - define: {...DEFAULT_DEFINE, 'BUILD_DEFS.DISABLE_WEBNN': 'false'} + define: {...DEFAULT_DEFINE} })); } @@ -396,7 +397,7 @@ async function main() { // ort.webgpu[.min].js await addAllWebBuildTasks({ outputBundleName: 'ort.webgpu', - define: {...DEFAULT_DEFINE, 'BUILD_DEFS.DISABLE_WEBGL': 'true'}, + define: {...DEFAULT_DEFINE, 'BUILD_DEFS.DISABLE_WEBGL': 'true', 'BUILD_DEFS.DISABLE_WEBNN': 'true'}, }); // ort.wasm[.min].js await addAllWebBuildTasks({ @@ -406,7 +407,12 @@ async function main() { // ort.webgl[.min].js await addAllWebBuildTasks({ outputBundleName: 'ort.webgl', - define: {...DEFAULT_DEFINE, 'BUILD_DEFS.DISABLE_WEBGPU': 'true', 'BUILD_DEFS.DISABLE_WASM': 'true'}, + define: { + ...DEFAULT_DEFINE, + 'BUILD_DEFS.DISABLE_WEBGPU': 'true', + 'BUILD_DEFS.DISABLE_WASM': 'true', + 'BUILD_DEFS.DISABLE_WEBNN': 'true', + }, }); // ort.wasm-core[.min].js await addAllWebBuildTasks({ @@ -415,6 +421,7 @@ async function main() { ...DEFAULT_DEFINE, 'BUILD_DEFS.DISABLE_WEBGPU': 'true', 'BUILD_DEFS.DISABLE_WEBGL': 'true', + 'BUILD_DEFS.DISABLE_WEBNN': 'true', 'BUILD_DEFS.DISABLE_WASM_PROXY': 'true', 'BUILD_DEFS.DISABLE_WASM_THREAD': 'true', }, @@ -427,6 +434,7 @@ async function main() { 'BUILD_DEFS.DISABLE_TRAINING': 'false', 'BUILD_DEFS.DISABLE_WEBGPU': 'true', 'BUILD_DEFS.DISABLE_WEBGL': 'true', + 'BUILD_DEFS.DISABLE_WEBNN': 'true', }, }); } diff --git a/js/web/test/suite-test-list.jsonc b/js/web/test/suite-test-list.jsonc index 3c7683cdcde26..27dd441c1ca1a 100644 --- a/js/web/test/suite-test-list.jsonc +++ b/js/web/test/suite-test-list.jsonc @@ -2185,44 +2185,44 @@ // "test_reflect_pad", "test_relu", // "test_reshape_allowzero_reordered", - "test_reshape_extended_dims", - "test_reshape_negative_dim", - "test_reshape_negative_extended_dims", - "test_reshape_one_dim", - "test_reshape_reduced_dims", - "test_reshape_reordered_all_dims", - "test_reshape_reordered_dims", - "test_reshape_reordered_last_dims", - "test_reshape_zero_and_negative_dim", - "test_reshape_zero_dim", - "test_resize_downsample_linear", - "test_resize_downsample_nearest", - "test_resize_downsample_scales_cubic_A_n0p5_exclude_outside", + // "test_reshape_extended_dims", + // "test_reshape_negative_dim", + // "test_reshape_negative_extended_dims", + // "test_reshape_one_dim", + // "test_reshape_reduced_dims", + // "test_reshape_reordered_all_dims", + // "test_reshape_reordered_dims", + // "test_reshape_reordered_last_dims", + // "test_reshape_zero_and_negative_dim", + // "test_reshape_zero_dim", + // "test_resize_downsample_linear", + // "test_resize_downsample_nearest", + // "test_resize_downsample_scales_cubic_A_n0p5_exclude_outside", // "test_resize_downsample_scales_cubic_align_corners", - "test_resize_downsample_scales_cubic", + // "test_resize_downsample_scales_cubic", // "test_resize_downsample_scales_linear_align_corners", - "test_resize_downsample_scales_linear", - "test_resize_downsample_scales_nearest", - "test_resize_downsample_sizes_cubic", - "test_resize_downsample_sizes_linear_pytorch_half_pixel", - "test_resize_downsample_sizes_nearest_tf_half_pixel_for_nn", - "test_resize_downsample_sizes_nearest", - "test_resize_nearest", - "test_resize_tf_crop_and_resize", - "test_resize_upsample_linear", - "test_resize_upsample_nearest", - "test_resize_upsample_scales_cubic_A_n0p5_exclude_outside", - "test_resize_upsample_scales_cubic_align_corners", - "test_resize_upsample_scales_cubic_asymmetric", - "test_resize_upsample_scales_cubic", - "test_resize_upsample_scales_linear_align_corners", - "test_resize_upsample_scales_linear", - "test_resize_upsample_scales_nearest", - "test_resize_upsample_sizes_cubic", - "opset{12,13,17,18}/test_resize_upsample_sizes_nearest_ceil_half_pixel", - "opset{12,13,17,18}/test_resize_upsample_sizes_nearest_floor_align_corners", - "opset{12,13,17,18}/test_resize_upsample_sizes_nearest_round_prefer_ceil_asymmetric", - "test_resize_upsample_sizes_nearest", + // "test_resize_downsample_scales_linear", + // "test_resize_downsample_scales_nearest", + // "test_resize_downsample_sizes_cubic", + // "test_resize_downsample_sizes_linear_pytorch_half_pixel", + // "test_resize_downsample_sizes_nearest_tf_half_pixel_for_nn", + // "test_resize_downsample_sizes_nearest", + // "test_resize_nearest", + // "test_resize_tf_crop_and_resize", + // "test_resize_upsample_linear", + // "test_resize_upsample_nearest", + // "test_resize_upsample_scales_cubic_A_n0p5_exclude_outside", + // "test_resize_upsample_scales_cubic_align_corners", + // "test_resize_upsample_scales_cubic_asymmetric", + // "test_resize_upsample_scales_cubic", + // "test_resize_upsample_scales_linear_align_corners", + // "test_resize_upsample_scales_linear", + // "test_resize_upsample_scales_nearest", + // "test_resize_upsample_sizes_cubic", + // "opset{12,13,17,18}/test_resize_upsample_sizes_nearest_ceil_half_pixel", + // "opset{12,13,17,18}/test_resize_upsample_sizes_nearest_floor_align_corners", + // "opset{12,13,17,18}/test_resize_upsample_sizes_nearest_round_prefer_ceil_asymmetric", + // "test_resize_upsample_sizes_nearest", // // "test_reversesequence_batch", // // "test_reversesequence_time", // // "test_rnn_seq_length", @@ -2436,17 +2436,17 @@ // // "test_softsign", // "test_spacetodepth_example", // "test_spacetodepth", - "test_split_equal_parts_1d", - "test_split_equal_parts_2d", - "test_split_equal_parts_default_axis", - "test_split_variable_parts_1d", - "test_split_variable_parts_2d", - "test_split_variable_parts_default_axis", - "test_split_zero_size_splits", + // "test_split_equal_parts_1d", + // "test_split_equal_parts_2d", + // "test_split_equal_parts_default_axis", + // "test_split_variable_parts_1d", + // "test_split_variable_parts_2d", + // "test_split_variable_parts_default_axis", + // "test_split_zero_size_splits", "test_sqrt_example", "test_sqrt", - "test_squeeze_negative_axes", - "test_squeeze", + // "test_squeeze_negative_axes", + // "test_squeeze", // // "test_stft_with_window", // // "test_stft", // // "test_strnormalizer_export_monday_casesensintive_lower", diff --git a/js/web/test/test-runner.ts b/js/web/test/test-runner.ts index a5b18b0028ff9..706539e84b659 100644 --- a/js/web/test/test-runner.ts +++ b/js/web/test/test-runner.ts @@ -244,7 +244,7 @@ export class ModelTestContext { const initStart = now(); const executionProviderConfig = - modelTest.backend == 'webnn' ? (testOptions?.webnnOptions || 'webnn') : modelTest.backend!; + modelTest.backend === 'webnn' ? (testOptions?.webnnOptions || 'webnn') : modelTest.backend!; const session = await initializeSession( modelTest.modelUrl, executionProviderConfig, modelTest.ioBinding, profile, testOptions?.sessionOptions || {}, this.cache);