OpenVINOEncapsulation: map float16/bfloat16/bool (char) OV dtypes#2559
Merged
Conversation
OpenVINOEncapsulation builds the EPContext ONNX by mapping each OV model input/output element type (via str(element_type)) to an ONNX TensorProto dtype. The map was missing the OpenVINO spellings for a few common types: - fp16 stringifies as 'float16' (only 'f16' was mapped), - bf16 as 'bfloat16' (only 'bf16'), - ONNX BOOL round-trips through OpenVINO as 'char'. Encapsulating an fp16 model (e.g. an LLM decoder) or any model with a boolean mask input therefore crashed with 'NoneType object cannot be interpreted as an integer' when make_tensor_value_info received a None dtype. Add the missing aliases. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Justin Chu <11205048+justinchuby@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves OpenVINOEncapsulation’s robustness when generating EPContext ONNX models by extending the OpenVINO element-type-string → ONNX TensorProto dtype mapping so common OpenVINO spellings don’t miss the lookup (which previously led to onnx_dtype=None and a downstream crash).
Changes:
- Add missing FP16 alias mapping:
float16→TensorProto.FLOAT16 - Add missing BF16 alias mapping:
bfloat16→TensorProto.BFLOAT16 - Add alias for OpenVINO boolean round-trip spelling:
char→TensorProto.BOOL
Comment on lines
31
to
54
| @@ -48,6 +50,7 @@ class OpenVINOEncapsulation(Pass): | |||
| "uint64_t": TensorProto.UINT64, | |||
| "bool": TensorProto.BOOL, | |||
| "boolean": TensorProto.BOOL, | |||
| "char": TensorProto.BOOL, | |||
| # Add more if needed | |||
xiaoyu-work
approved these changes
Jul 3, 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.
Problem
OpenVINOEncapsulationbuilds theEPContextONNX by mapping each OpenVINO model input/output element type to an ONNXTensorProtodtype viaopenvino_to_onnx_dtype[str(element_type)...]. The map was missing the OpenVINO string spellings for several common types:float16(onlyf16was mapped)bfloat16(onlybf16)BOOLround-trips through OpenVINO ascharAs a result, encapsulating an fp16 model (e.g. an LLM decoder) or any model with a boolean mask input crashes:
(
onnx_dtypeisNonebecause the lookup missed.)Fix
Add the missing aliases:
float16→FLOAT16,bfloat16→BFLOAT16,char→BOOL.Validation
With this fix,
OpenVINOConversion→OpenVINOEncapsulationsuccessfully producesEPContextONNX models for all four components of a multimodal fp16 INT4 decoder+encoders package (Gemma 4 E2B, built viaMobiusBuilder→OnnxKQuantQuantization→MatMulNBitsToQDQ→ OpenVINO 2026.3), including the audio encoder's booleaninput_features_mask. Before the fix, fp16 inputs failed immediately and the boolean-mask encoder failed with the sameNoneTypeerror.