Skip to content

fix: make --device flag case-insensitive consistent with other commands (#215)#264

Merged
DingmaomaoBJTU merged 1 commit into
mainfrom
fix/device-option-case-insensitive
Apr 8, 2026
Merged

fix: make --device flag case-insensitive consistent with other commands (#215)#264
DingmaomaoBJTU merged 1 commit into
mainfrom
fix/device-option-case-insensitive

Conversation

@DingmaomaoBJTU
Copy link
Copy Markdown
Collaborator

Summary

winml analyze --device only accepted uppercase (NPU, GPU, CPU). All other commands (compile, eval, perf, config) accept lowercase. This single-character fix makes the device_option() helper consistent.

Change

src/winml/modelkit/utils/cli.py:81case_sensitive=Truecase_sensitive=False

click.Choice with case_sensitive=False normalizes the user input to match the canonical form in the choices list ("npu""NPU"), so no downstream code changes are needed.

Before / After

Before — lowercase input fails:

$ winml analyze --model model.onnx --ep qnn --device npu
Error: Invalid value for '--device': 'npu' is not one of 'CPU', 'GPU', 'NPU'.

$ winml analyze --model model.onnx --ep qnn --device gpu
Error: Invalid value for '--device': 'gpu' is not one of 'CPU', 'GPU', 'NPU'.

After — any casing accepted, value normalized to uppercase:

$ winml analyze --model model.onnx --ep qnn --device npu   # ✓ device=NPU
$ winml analyze --model model.onnx --ep qnn --device NPU   # ✓ device=NPU
$ winml analyze --model model.onnx --ep qnn --device gpu   # ✓ device=GPU
$ winml analyze --model model.onnx --ep qnn --device Gpu   # ✓ device=GPU

Closes #215

…ds (#215)

winml analyze --device only accepted uppercase (CPU/GPU/NPU) while all
other commands (compile, eval, perf, config) accept lowercase.
Change click.Choice to case_sensitive=False so npu/gpu/cpu are accepted.
Click normalizes the value to uppercase, so no downstream code changes
are needed.
@DingmaomaoBJTU DingmaomaoBJTU requested a review from a team as a code owner April 8, 2026 02:33
@DingmaomaoBJTU DingmaomaoBJTU merged commit e48ad29 into main Apr 8, 2026
9 checks passed
@DingmaomaoBJTU DingmaomaoBJTU deleted the fix/device-option-case-insensitive branch April 8, 2026 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

winml analyze --device requires uppercase (NPU/GPU/CPU) inconsistent with other commands

3 participants