swift-package: Add ORTTensorElementDataTypeBool support - #32215
Open
Bingcheng Hu (bingcheng1998) wants to merge 1 commit into
Open
swift-package: Add ORTTensorElementDataTypeBool support#32215Bingcheng Hu (bingcheng1998) wants to merge 1 commit into
Bingcheng Hu (bingcheng1998) wants to merge 1 commit into
Conversation
Expose the ONNX BOOL tensor element type through the Objective-C API so that models requiring tensor(bool) inputs can be used. The new enum value is appended at the end to keep existing raw values stable.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Copilot started reviewing on behalf of
Bingcheng Hu (bingcheng1998)
August 22, 2026 07:00
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Exposes BOOL tensors through the Objective-C API, enabling models with tensor(bool) inputs.
Changes:
- Adds
ORTTensorElementDataTypeBool. - Maps it to the ONNX BOOL type and storage size.
- Adds creation, metadata, and round-trip data coverage.
No actionable issues identified.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
objectivec/include/ort_enums.h |
Adds the public BOOL enum value. |
objectivec/ort_enums.mm |
Adds BOOL type and size mapping. |
objectivec/test/ort_value_test.mm |
Tests BOOL tensor creation and readback. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Author
|
@microsoft-github-policy-service agree |
Author
|
Edward Chen (@edgchen1) This is the upstream change corresponding to onnxruntime-swift-package-manager#31 and PR #41, which you asked to be opened in this repo. Adding |
Xavier Dupré (xadupre)
approved these changes
Sep 2, 2026
Edward Chen (edgchen1)
approved these changes
Sep 2, 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.
Expose the ONNX BOOL tensor element type through the Objective-C API so that models requiring tensor(bool) inputs can be used. The new enum value is appended at the end to keep existing raw values stable.
Description
This adds
ORTTensorElementDataTypeBoolto the Objective-C API and maps it toONNX_TENSOR_ELEMENT_DATA_TYPE_BOOLinort_enums.mm, withsizeof(bool)as the element size. A unit testtestInitBoolTensorOkis added to verify that a bool tensor can be created and read back correctly.The
objectivec/directory in this repo is the source of truth thatonnxruntime-swift-package-managercopies from (see PR #41), so the change needs to land here first.Motivation and Context
Several ONNX models require a
tensor(bool)input that the Objective-C/Swift bindings currently cannot construct. onnxruntime-swift-package-manager#31 reports a model using a bool mask for pixel attention that fails becauseORTTensorElementDataTypehas no bool value.Supporting the type at the source (
objectivec/) lets the SPM package pick it up in its next sync and unblocks those models. The new enum value is appended at the end so existing raw values stay stable.