Add LabelEncoder CUDA execution provider for numeric types#28045
Draft
Add LabelEncoder CUDA execution provider for numeric types#28045
Conversation
Implements LabelEncoder for the CUDA execution provider supporting numeric types (int64, float, double). Uses sorted arrays and binary search on GPU for efficient O(log n) per-element lookup. Supports: - Opset 2-3: int64↔float, int64↔int64, float↔float - Opset 4+: above plus double↔double, double↔int64, int64↔double String types remain CPU-only as they cannot run on GPU. Agent-Logs-Url: https://github.com/microsoft/onnxruntime/sessions/d17c0a15-3bf2-4ac4-bc57-255876153271 Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
Add tests for: - Float NaN keys to int64 values (opset 4) - Float NaN keys to float values (opset 4) - Double NaN keys to int64 values (opset 4) - Int64 to double conversion (opset 4) - Double to double conversion (opset 4) These tests exercise the CUDA binary search with NaN handling and double type support. Agent-Logs-Url: https://github.com/microsoft/onnxruntime/sessions/d17c0a15-3bf2-4ac4-bc57-255876153271 Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
… test intent Agent-Logs-Url: https://github.com/microsoft/onnxruntime/sessions/d17c0a15-3bf2-4ac4-bc57-255876153271 Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add LabelEncoder support for CUDA provider
Add LabelEncoder CUDA execution provider for numeric types
Apr 13, 2026
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.
Description
Implements
ai.onnx.ml.LabelEncoderon the CUDA execution provider for numeric key/value types using sorted arrays + binary search (O(log n) per element).New files (
onnxruntime/core/providers/cuda/ml/):label_encoder_impl.cu/.h— CUDA kernel: per-thread binary search on sorted keys, NaN-aware for float/doublelabel_encoder.cc/.h— Host-side op classes (CudaLabelEncoderfor opset 2-3,CudaLabelEncoder_4for opset 4+). Constructor sorts keys, copies to GPU;ComputeInternallaunches kernel.Modified files:
cuda_execution_provider.cc— Register 11 kernel variants (4 versioned opset 2-3, 7 opset 4+)provider_api.h— Add missingkMLDomainconstant (first ML-domain op on CUDA EP)docs/OperatorKernels.md— Addai.onnx.mlsection to CUDA provider tableSupported type combinations:
int64↔float,int64↔int64,float↔floatdouble↔double,double↔int64,int64↔doubleString types remain CPU-only. NaN keys are placed at end of sorted array and short-circuited before binary search.
Tests: 5 new test cases covering NaN-key-to-numeric-value mappings and double type combinations. Existing numeric tests (
FloatToInt64Opset2,Int64ToFloatOpset2, etc.) will automatically run on CUDA viaOpTester::Run().Motivation and Context
Models with large LabelEncoder nodes (>100k entries) force a CPU round-trip when all other nodes run on GPU. This adds the CUDA implementation to eliminate that data transfer bottleneck.