[CUDA EP] Add pad op version from 19 to 23 support for CUDA#27416
[CUDA EP] Add pad op version from 19 to 23 support for CUDA#27416ShirasawaSama wants to merge 1 commit intomicrosoft:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Adds CUDA Execution Provider coverage for ONNX Pad in opset 19–23 (previously only registered up to opset 18), including implementing wrap mode behavior so models exported with newer opsets no longer force a CPU fallback for Pad.
Changes:
- Register CUDA
Padkernels for opset 19–20, 21–22, and 23 (and make opset 18 explicitly versioned). - Add CUDA kernel support for
wrapmode, including handling negative pads via slicing metadata. - Update an existing
wrappadding test comment now that CUDA is expected to support opset 19.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
onnxruntime/test/providers/cpu/tensor/pad_test.cc |
Updates wrap-mode test context now that CUDA can register opset 19+ Pad. |
onnxruntime/core/providers/cuda/tensor/pad_impl.h |
Extends CUDA pad kernel APIs to accept slice/effective-dim metadata needed for wrap + negative pads. |
onnxruntime/core/providers/cuda/tensor/pad_impl.cu |
Implements wrap mode in CUDA kernels and wires new parameters through launch paths. |
onnxruntime/core/providers/cuda/tensor/pad.cc |
Adds CUDA kernel registrations for opset 19–23 and passes slice/effective dims into CUDA implementations. |
onnxruntime/core/providers/cuda/cuda_execution_provider.cc |
Declares/registers the additional versioned CUDA Pad kernels in the EP registry. |
Comments suppressed due to low confidence (1)
onnxruntime/test/providers/cpu/tensor/pad_test.cc:1401
- This test previously avoided CUDA by using an opset version CUDA didn’t register for. Now that CUDA is expected to support opset 19+, it would be good to make the test actually fail if Pad falls back to CPU (otherwise a future regression could silently reintroduce CPU offload while still passing). Consider running this case with
session.disable_cpu_ep_fallback=1and restricting execution providers to CUDA for this test so it validates the new CUDA registration/support for opset 19–23.
OpTester test("Pad", 19);
test.AddInput<float>("data", input_shape, input_data);
test.AddInput<int64_t>("pads", {static_cast<int64_t>(pads.size())}, pads, true);
test.AddOutput<float>("output", expected_shape, expected_data);
test.AddAttribute("mode", "wrap");
test.ConfigExcludeEps({kDmlExecutionProvider, kQnnExecutionProvider,
kTensorrtExecutionProvider, kWebGpuExecutionProvider});
test.RunWithConfig();
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // CUDA registers only up to 18 and does not impl wrap mode | ||
| // so we force version to 19 to automatically exclude EPs that do not | ||
| // implement wrap mode similar to the above tests. |
There was a problem hiding this comment.
I am guessing there are Wrap mode Pad tests already in ?
|
Can you please resolve the conflicts ? |
|
Sorry, I think I found some errors in my math formula (My final code review). I'll try adding more unit tests to cover them. |
This comment was marked as outdated.
This comment was marked as outdated.
3b7e80a to
37eabee
Compare
|
The algorithm has now been modified to use the same formula as the CPU and has passed local testing without any noticeable performance degradation. |
37eabee to
3dc473e
Compare
|
This PR is superseded by #27774 |
Description
Add pad op version from 19 to 23 support for CUDA
Motivation and Context
The current CUDA executor does not support the pad operation in Opset from 19 to 23. When an ONNX model exported in Opset from 19 to 23 is run on the CUDA executor, the pad operation is forcibly offloaded to the CPU, resulting in significant performance degradation.