Update Ort::Custom::GetOrtDType() to fix unreachable code warning. - #1122
Open
Edward Chen (edgchen1) wants to merge 2 commits into
Open
Edward Chen (edgchen1) wants to merge 2 commits into
Edward Chen (edgchen1) wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No blocking issues were identified; additional mapping tests are a minor nit.
Pull request overview
Updates Ort::Custom::GetOrtDType() with constexpr type mapping and compile-time validation for unsupported types.
Changes:
- Adds
MFloat16,BFloat16, andstd::string_viewmappings. - Replaces unreachable fallback code with a dependent
static_assert.
File summaries
| File | Summary |
|---|---|
include/custom_op/tensor_api.h |
Updates tensor element-type mappings and unsupported-type handling. |
Review details
Suppressed comments (1)
include/custom_op/tensor_api.h:150
- This changes the type mapping for
MFloat16,BFloat16, andstd::string_view, buttest/static_test/test_tensor_api.cchas no assertions forTensor::Type()orGetOrtDType(). Add coverage for these mappings so a regression does not silently restore the previous exception or report the wrong ONNX element type.
#if ORT_API_VERSION >= 16
else if constexpr (std::is_same<TT, MFloat16>::value)
return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16;
else if constexpr (std::is_same<TT, BFloat16>::value)
return ONNX_TENSOR_ELEMENT_DATA_TYPE_BFLOAT16;
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or 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.
Replace
returnafterORTX_CXX_API_THROWwithstatic_asserton unsupported type.Also added support for additional types and made the function
constexpr.