From 8914fe687b3dab1fb46bec37c6a46bbbbefcb860 Mon Sep 17 00:00:00 2001 From: Jian Chen Date: Wed, 6 Sep 2023 12:00:16 -0700 Subject: [PATCH] [js/webgpu] Include Support for neg.int32 (#17374) ### Description Include Support for neg.int32 ### Motivation and Context --- .../ops/{abs_int32.jsonc => abs-int32.jsonc} | 0 js/web/test/data/ops/neg-int32.jsonc | 26 +++++++++++++++++++ js/web/test/suite-test-list.jsonc | 3 ++- .../core/providers/js/operators/unary.cc | 4 +-- 4 files changed, 30 insertions(+), 3 deletions(-) rename js/web/test/data/ops/{abs_int32.jsonc => abs-int32.jsonc} (100%) create mode 100644 js/web/test/data/ops/neg-int32.jsonc diff --git a/js/web/test/data/ops/abs_int32.jsonc b/js/web/test/data/ops/abs-int32.jsonc similarity index 100% rename from js/web/test/data/ops/abs_int32.jsonc rename to js/web/test/data/ops/abs-int32.jsonc diff --git a/js/web/test/data/ops/neg-int32.jsonc b/js/web/test/data/ops/neg-int32.jsonc new file mode 100644 index 0000000000..807333db4a --- /dev/null +++ b/js/web/test/data/ops/neg-int32.jsonc @@ -0,0 +1,26 @@ +[ + { + "name": "neg with no attributes", + "operator": "Neg", + "attributes": [], + "cases": [ + { + "name": "T[2,4] (int32)", + "inputs": [ + { + "data": [1, 2, -1, -2, 0, 1, -1, 0], + "dims": [2, 4], + "type": "int32" + } + ], + "outputs": [ + { + "data": [-1, -2, 1, 2, 0, -1, 1, 0], + "dims": [2, 4], + "type": "int32" + } + ] + } + ] + } +] diff --git a/js/web/test/suite-test-list.jsonc b/js/web/test/suite-test-list.jsonc index 995df7381c..52059eb38e 100644 --- a/js/web/test/suite-test-list.jsonc +++ b/js/web/test/suite-test-list.jsonc @@ -1322,7 +1322,7 @@ ], "ops": [ "abs.jsonc", - "abs_int32.jsonc", + "abs-int32.jsonc", "acos.jsonc", "add.jsonc", "add_int32.jsonc", @@ -1351,6 +1351,7 @@ "mul.jsonc", "mul_int32.jsonc", //"neg.jsonc", + "neg-int32.jsonc", "not.jsonc", //"or.jsonc", "layer-norm.jsonc", diff --git a/onnxruntime/core/providers/js/operators/unary.cc b/onnxruntime/core/providers/js/operators/unary.cc index cf9433767c..5e972e43e4 100644 --- a/onnxruntime/core/providers/js/operators/unary.cc +++ b/onnxruntime/core/providers/js/operators/unary.cc @@ -38,8 +38,8 @@ JSEP_ELEMENTWISE_MULTI_TYPED_VERSIONED_KERNEL(Abs, 6, 12, Abs) JSEP_ELEMENTWISE_MULTI_TYPED_KERNEL(Abs, 13, Abs) JSEP_KERNEL_IMPL(Neg, Neg) -JSEP_ELEMENTWISE_VERSIONED_KERNEL(Neg, 6, 12, float, Neg) -JSEP_ELEMENTWISE_KERNEL(Neg, 13, float, Neg) +JSEP_ELEMENTWISE_MULTI_TYPED_VERSIONED_KERNEL(Neg, 6, 12, Neg) +JSEP_ELEMENTWISE_MULTI_TYPED_KERNEL(Neg, 13, Neg) JSEP_KERNEL_IMPL(Floor, Floor) JSEP_ELEMENTWISE_VERSIONED_KERNEL(Floor, 6, 12, float, Floor)