Register CPU kernels for the generator ops at opset 22 - #32201
Open
Arne H Juul (arnej27959) wants to merge 1 commit into
Open
Register CPU kernels for the generator ops at opset 22#32201Arne H Juul (arnej27959) wants to merge 1 commit into
Arne H Juul (arnej27959) wants to merge 1 commit into
Conversation
RandomNormal, RandomNormalLike, RandomUniform, RandomUniformLike and Multinomial were revised in ONNX opset 22, but their CPU kernels stayed registered at their original start version with no end version, which matches that version exactly. As a result these ops had no CPU kernel at opset 22+. Cap the old registrations at 21 and add new ones at 22, the same split EyeLike and the CUDA Random kernels already use. Type constraints are unchanged (float and double). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
There was a problem hiding this comment.
Pull request overview
Registers CPU kernels for five generator operators revised in ONNX opset 22.
Changes:
- Splits CPU kernel registrations at opset 22.
- Adds CPU-specific opset 22 tests.
- Regenerates kernel documentation.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
onnxruntime/core/providers/cpu/generator/random.cc |
Defines versioned generator kernels. |
onnxruntime/core/providers/cpu/cpu_execution_provider.cc |
Registers the new kernel versions. |
onnxruntime/test/providers/cpu/generator/random_test.cc |
Adds opset 22 CPU coverage. |
docs/OperatorKernels.md |
Documents supported version ranges. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Discovered when trying to use RandomNormal (opset 22) in a unit test:
RandomNormal, RandomNormalLike, RandomUniform, RandomUniformLike and Multinomial were revised in ONNX opset 22, but their CPU kernels stayed registered at their original start version with no end version, which matches that version exactly. As a result these ops had no CPU kernel at opset 22+. Cap the old registrations at 21 and add new ones at 22, the same split EyeLike and the CUDA Random kernels already use.
Type constraints are unchanged (float and double).
Description
Splits the CPU kernel registrations for
RandomNormal,RandomNormalLike,RandomUniform,RandomUniformLikeandMultinomialat opset 22: the existing registrations are capped with anend version of 21, and a new registration is added at 22 for each op.
docs/OperatorKernels.mdisregenerated to match, and each op gets an opset 22 test.
Type constraints are unchanged — the opset 22 registrations declare the same
float/doubleconstraints as the earlier ones.
Motivation and Context
All five ops were revised in ONNX opset 22, but their CPU kernels stayed registered at their
original start version (1, or 7 for
Multinomial) with no end version. A kernel registered thatway matches its start version exactly:
VerifyVersioninkernel_registry.cconly takes therange branch when
kernel_end_version != INT_MAX, on the reasoning that without an end version ORTcannot know whether a later op revision added something the kernel mishandles. Since the version
that gets matched is the op's schema
since_version— 1 for opsets 1-21 and 22 for opsets 22+ —these ops had no CPU kernel at all at opset 22 and later.
Version matching happens before type matching, so this is not type-specific: an opset 22
RandomNormalwithdtype=float, squarely inside the registered type constraints, still failedwith
Could not find an implementation for RandomNormal(22).EyeLikewas revised in the same opset and was updated at the time; it shows the intended patternof capping the old registration and adding a new one. CUDA already has that split for the four
Random ops, so this was CPU-side drift. This PR applies the same treatment to all five ops.
Opset 22 also widened these schemas to the full set of float types by adding
bfloat16. That isdeliberately not implemented here — supporting a new dtype is a separate feature, whereas this
change restores a working kernel lookup for the types already supported.
On the tests
OpTester's defaultRun()pre-assigns every node to an EP and, when no EP has a matching kernel,logs a warning and returns without failing. The obvious version of these tests therefore passed
against the unfixed code. The new tests run with an explicitly specified CPU EP, which leaves node
assignment to the graph partitioner, so a missing registration surfaces as a session initialization
failure. All five new tests were verified failing before this change and passing after.