Skip to content

swift-package: Add ORTTensorElementDataTypeBool support - #32215

Open
Bingcheng Hu (bingcheng1998) wants to merge 1 commit into
microsoft:mainfrom
bingcheng1998:add-bool-tensor-support
Open

swift-package: Add ORTTensorElementDataTypeBool support#32215
Bingcheng Hu (bingcheng1998) wants to merge 1 commit into
microsoft:mainfrom
bingcheng1998:add-bool-tensor-support

Conversation

@bingcheng1998

Copy link
Copy Markdown

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 ORTTensorElementDataTypeBool to the Objective-C API and maps it to ONNX_TENSOR_ELEMENT_DATA_TYPE_BOOL in ort_enums.mm, with sizeof(bool) as the element size. A unit test testInitBoolTensorOk is 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 that onnxruntime-swift-package-manager copies 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 because ORTTensorElementDataType has 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.

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.
Copilot AI balanced review requested due to automatic review settings August 22, 2026 06:59
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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.

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.

@bingcheng1998

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@bingcheng1998

Copy link
Copy Markdown
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 ORTTensorElementDataTypeBool so bool mask inputs (e.g. pixel attention models) can be constructed from the ObjC/Swift API.

@bingcheng1998 Bingcheng Hu (bingcheng1998) changed the title Add ORTTensorElementDataTypeBool support swift-package: Add ORTTensorElementDataTypeBool support Aug 25, 2026
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.

4 participants