Skip to content

Update Ort::Custom::GetOrtDType() to fix unreachable code warning. - #1122

Open
Edward Chen (edgchen1) wants to merge 2 commits into
mainfrom
edgchen1/fix_unreachable_code_warning
Open

Edward Chen (edgchen1) wants to merge 2 commits into
mainfrom
edgchen1/fix_unreachable_code_warning

Conversation

@edgchen1

Copy link
Copy Markdown
Contributor

Replace return after ORTX_CXX_API_THROW with static_assert on unsupported type.

Also added support for additional types and made the function constexpr.

@edgchen1
Edward Chen (edgchen1) requested a review from a team as a code owner September 17, 2026 20:02
Copilot AI lite review requested due to automatic review settings September 17, 2026 20:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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, and std::string_view mappings.
  • 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, and std::string_view, but test/static_test/test_tensor_api.cc has no assertions for Tensor::Type() or GetOrtDType(). 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.

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.

3 participants