From ddbc8bc5fc607adf0e79d28957a12ee9a46a9275 Mon Sep 17 00:00:00 2001 From: Hariharan Seshadri Date: Wed, 1 Sep 2021 21:38:55 -0700 Subject: [PATCH] Fix CPU Xor implementation (#8934) --- onnxruntime/core/providers/cpu/math/element_wise_ops.cc | 2 +- .../test/providers/cpu/math/element_wise_ops_test.cc | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/onnxruntime/core/providers/cpu/math/element_wise_ops.cc b/onnxruntime/core/providers/cpu/math/element_wise_ops.cc index b00de30dca..bfc6388954 100644 --- a/onnxruntime/core/providers/cpu/math/element_wise_ops.cc +++ b/onnxruntime/core/providers/cpu/math/element_wise_ops.cc @@ -898,7 +898,7 @@ Status Xor::Compute(OpKernelContext* context) const { ProcessBroadcastSpanFuncs funcs{ [](BroadcastHelper& per_iter_bh) { bool input0 = per_iter_bh.ScalarInput0(); - auto input1 = per_iter_bh.EigenInput0(); + auto input1 = per_iter_bh.EigenInput1(); auto output = per_iter_bh.OutputEigen(); if (input0) output.array() = !input1.array(); diff --git a/onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc b/onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc index f4047b2c88..c95f3daf5b 100644 --- a/onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc +++ b/onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc @@ -1553,6 +1553,15 @@ TEST(MathOpTest, Xor) { test.Run(); } + +TEST(MathOpTest, Xor_Issue8880) { + OpTester test("Xor"); + test.AddInput("A", {1}, {true}); + test.AddInput("B", {1}, {false}); + test.AddOutput("C", {1}, {true}); + test.Run(); +} + TEST(MathOpTest, Xor_bcast3v2d) { OpTester test("Xor");