From 931c8b01479197ba2aa293a609d0e91a221e47bb Mon Sep 17 00:00:00 2001 From: Hariharan Seshadri Date: Thu, 1 Sep 2022 18:30:57 -0700 Subject: [PATCH] Resolve GH issue 12706 (#12815) --- .../transpose_optimizer/transpose_optimizer.cc | 12 ++++++++++++ .../test/optimizer/transpose_optimizer_test.cc | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/onnxruntime/core/optimizer/transpose_optimizer/transpose_optimizer.cc b/onnxruntime/core/optimizer/transpose_optimizer/transpose_optimizer.cc index 81adcee7cb..2cac02033e 100644 --- a/onnxruntime/core/optimizer/transpose_optimizer/transpose_optimizer.cc +++ b/onnxruntime/core/optimizer/transpose_optimizer/transpose_optimizer.cc @@ -1691,7 +1691,19 @@ static const std::unordered_map handler_ma {"Split", split_handler}, {"Shape", shape_handler}, {"Pad", pad_handler}, +// The CUDA Resize kernel assumes that the input is NCHW and +// Resize can't be supported in ORT builds with CUDA enabled. +// TODO: Enable this once the CUDA Resize kernel is implemented +// "generically" (i.e.) aligning with the generic nature of the +// ONNX spec. +// See https://github.com/microsoft/onnxruntime/pull/10824 for +// a similar fix applied to the CPU Resize kernel. +// Per tests included in #10824, the ROCM EP also generates +// incorrect results when this handler is used, so the Resize +// handler is not enabled even for those builds. +#if !defined(USE_CUDA) && !defined(USE_ROCM) {"Resize", resize_handler}, +#endif {"ReduceSum", reduce_sum_handler}, {"ReduceLogSum", reduce_op_handler}, diff --git a/onnxruntime/test/optimizer/transpose_optimizer_test.cc b/onnxruntime/test/optimizer/transpose_optimizer_test.cc index cfeb9a2202..980ac01b9d 100644 --- a/onnxruntime/test/optimizer/transpose_optimizer_test.cc +++ b/onnxruntime/test/optimizer/transpose_optimizer_test.cc @@ -294,6 +294,17 @@ TEST(TransposeOptimizerTests, TestPadNonconst) { /*opset_version*/ 11); } +// The CUDA Resize kernel assumes that the input is NCHW and +// Resize can't be supported in ORT builds with CUDA enabled. +// TODO: Enable this once the CUDA Resize kernel is implemented +// "generically" (i.e.) aligning with the generic nature of the +// ONNX spec. +// See https://github.com/microsoft/onnxruntime/pull/10824 for +// a similar fix applied to the CPU Resize kernel. +// Per tests included in #10824, the ROCM EP also generates +// incorrect results when this handler is used, so the Resize +// handler is not enabled even for those builds. +#if !defined(USE_CUDA) && !defined(USE_ROCM) TEST(TransposeOptimizerTests, TestResize) { auto build_test_case_1 = [&](ModelTestBuilder& builder) { auto* input0_arg = MakeInput(builder, {{4, -1, 2, -1}}, {4, 6, 2, 10}, 0.0, 1.0); @@ -498,6 +509,7 @@ TEST(TransposeOptimizerTests, TestResizeNonconstOpset13) { /*opset_version*/ 13); } +#endif TEST(TransposeOptimizerTests, TestAdd) { auto build_test_case_1 = [&](ModelTestBuilder& builder) { auto* input0_arg = builder.MakeInput({4, 6, 10}, 0.0, 1.0);