Skip to content

fix: support Float16/BFloat16/Float8 in TensorArray custom op#28335

Open
Rishi-Dave wants to merge 1 commit intomicrosoft:mainfrom
Rishi-Dave:rishidave/fix/tensorarray-fp16-bfloat16-support
Open

fix: support Float16/BFloat16/Float8 in TensorArray custom op#28335
Rishi-Dave wants to merge 1 commit intomicrosoft:mainfrom
Rishi-Dave:rishidave/fix/tensorarray-fp16-bfloat16-support

Conversation

@Rishi-Dave
Copy link
Copy Markdown
Contributor

Description

The Ort::Custom::TensorArray (alias Variadic) constructor in include/onnxruntime/core/session/onnxruntime_lite_custom_op.h was missing case arms for Float16, BFloat16, and the four Float8* variants. Any custom op accepting const Ort::Custom::TensorArray& with one of those input types fell through to the default: arm and threw "unknown input type" at construction.

This PR adds the six missing case arms so the constructor handles every floating-point variant the rest of the file already supports. The new arms mirror the type-name parity already established in CREATE_TUPLE (around lines 619-637) and PARSE_ARGS (around lines 744-762) within the same header — same Ort::Float16_t / Ort::BFloat16_t / Ort::Float8E4M3FN_t / Ort::Float8E4M3FNUZ_t / Ort::Float8E5M2_t / Ort::Float8E5M2FNUZ_t template arguments.

The change is purely additive: 18 lines, header-only, no API/ABI impact, no behavior change for any previously-supported type.

Motivation and Context

Fixes #23373.

Custom ops authored against the Lite Custom Op API and declared with a const Ort::Custom::TensorArray& parameter currently cannot accept fp16, bf16, or fp8 inputs even though Custom::Tensor<Ort::Float16_t> etc. are first-class everywhere else in the API. This blocks half-precision and 8-bit-float variadic custom op authors on CPU EP and any EP that dispatches via the lite API.

The TensorArray (Variadic) constructor's switch in
onnxruntime_lite_custom_op.h was missing case arms for Float16,
BFloat16, and the four Float8 variants, so any custom op accepting
const Ort::Custom::TensorArray& with those input types threw
"unknown input type" at construction.

Add the six missing case arms, mirroring the type-name parity already
established in CREATE_TUPLE and PARSE_ARGS within the same header.

Fixes microsoft#23373
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.

How to create custom op with fp16 input

1 participant