Skip to content

add minimum data types and rank range for operations#910

Open
BruceDai wants to merge 13 commits into
webmachinelearning:mainfrom
BruceDai:minimum_datatype_rankrange
Open

add minimum data types and rank range for operations#910
BruceDai wants to merge 13 commits into
webmachinelearning:mainfrom
BruceDai:minimum_datatype_rankrange

Conversation

@BruceDai
Copy link
Copy Markdown
Contributor

@BruceDai BruceDai commented Dec 10, 2025

This PR is to fix #896.
@huningxin @fdwr @reillyeon PTAL, thanks!


Preview | Diff

@BruceDai BruceDai changed the title add minimum data types and rank range for operations [wip]add minimum data types and rank range for operations Dec 11, 2025
Comment thread index.bs
Comment thread index.bs
Comment thread index.bs Outdated
Comment thread index.bs Outdated
@BruceDai BruceDai changed the title [wip]add minimum data types and rank range for operations add minimum data types and rank range for operations Dec 12, 2025
@fdwr
Copy link
Copy Markdown
Collaborator

fdwr commented Dec 12, 2025

I checked the unchanged Line 8987, it seems correct by using current 8 indents for to match front

of also 8 indents. Any suggestions? Thanks!

@BruceDai : Remerge with main. My PR adds an extra blank line that pacifies the build error (and yes, that line was already correct, and nothing changed there for months, but bikeshed changed).

Comment thread index.bs
Comment thread index.bs Outdated
Copy link
Copy Markdown
Member

@reillyeon reillyeon left a comment

Choose a reason for hiding this comment

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

General wording looks good. I have not validated the specific operator limits specified.

Comment thread index.bs Outdated
Comment thread index.bs Outdated
Copy link
Copy Markdown
Collaborator

@fdwr fdwr left a comment

Choose a reason for hiding this comment

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

👀 Thanks for the updates Bruce - I'm sure they were tedious :b.

Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs
Comment thread index.bs
Comment thread index.bs
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs
Comment thread index.bs
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs Outdated
Comment thread index.bs Outdated
<tr>
<td>{{input}}</td>
<td>[=/any data type|any=]</td>
<td>{{MLOperandDataType/"float32"}}, {{MLOperandDataType/"float16"}}, {{MLOperandDataType/"int32"}}</td>
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.

ORT doesn't support int32

Copy link
Copy Markdown
Collaborator

@fdwr fdwr Dec 18, 2025

Choose a reason for hiding this comment

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

🤔 An ONNX BitCast operator could help with cases of pure data movement (since no actual math happens) like this one when the operator supports a different data type of the same bit size (sizeof(int32) == sizeof(uint32) == sizeof(float32)). For example, we could call BitCast(int32input, type=float32) -> Triangular -> BitCast(input, type=int32). I'll comment on that ONNX PR.

(update) BitCast operator is pending: onnx/onnx#7527

Copy link
Copy Markdown
Collaborator

@fdwr fdwr Apr 13, 2026

Choose a reason for hiding this comment

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

(update) BitCast is in ONNX https://onnx.ai/onnx/operators/onnx__BitCast.html, now enabling callers of the ORT backend to support all data types of the same bit size for data movement operators, so long as the EP supports BitCast and at least one data type of a given bit size (e.g. supporting int16 with Gather also enables uint16, float16, bfloat16...).

@BruceDai
Copy link
Copy Markdown
Contributor Author

Thanks @huningxin and @fdwr for review and identifications. 👍
I submitted a new commit to address your comments. Please take another look, thanks!☕

@BruceDai BruceDai force-pushed the minimum_datatype_rankrange branch 2 times, most recently from 949a42f to b6b300f Compare January 16, 2026 09:01
Copy link
Copy Markdown
Collaborator

@fdwr fdwr left a comment

Choose a reason for hiding this comment

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

👍

@BruceDai BruceDai force-pushed the minimum_datatype_rankrange branch from b6b300f to 3f29bff Compare April 13, 2026 13:25
Copy link
Copy Markdown

@mwyrzykowski mwyrzykowski left a comment

Choose a reason for hiding this comment

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

Conflict with the WG meeting, but ✅

Copy link
Copy Markdown
Collaborator

@fdwr fdwr left a comment

Choose a reason for hiding this comment

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

👍

Comment thread index.bs
If an operation supports only a subset of {{MLOperandDataType}}s, the <dfn>allowed data types</dfn> for each of the operation's input operands, including both positional arguments and options, are given as either an explicit list of {{MLOperandDataType}}s, or a constraint that the operand's [=MLOperand/dataType=] must be the <dfn lt="same type as">same as</dfn> the [=MLOperand/dataType=] of another input operand, or <dfn lt="any data type">any</dfn> to allow any {{MLOperandDataType}}.

Implementations may support fewer data types for operands than specified. This can be queried for each operation using the {{MLContext/opSupportLimits()}} method on {{MLContext}} and inspecting the {{MLTensorLimits/dataTypes}} value of the corresponding member for the operation.
Implementations MAY support fewer data types for operands than specified, but MUST support at least the specified <dfn>required data types</dfn>. Support can be queried for each operation using the {{MLContext/opSupportLimits()}} method on {{MLContext}} and inspecting the {{MLTensorLimits/dataTypes}} value of the corresponding member for the operation across DirectML, ONNX Runtime, LiteRT, and CoreML backends in Chromium prototype now.
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.

Chromium impl has removed DirectML backends.

Comment thread index.bs
If an operation requires input operands with a particular [=MLOperand/rank=], the <dfn>allowed ranks</dfn> for each of the operation's input operands, including both positional arguments and options, are given as an explicit rank (e.g. 1), or <dfn lt="any rank">N</dfn> to allow any dimensionality, or the <dfn lt="same rank as">same as</dfn> another operand. More specific constraints are common, such as when an input operand's shape must be [=/unidirectionally broadcastable=] to or [=/bidirectionally broadcastable=] with another input operand; in these cases, the [=/allowed ranks=] are listed as a range, with specific validation given as steps in the operation.

Implementations may impose a more restricted lower bound and/or upper bound on the [=MLOperand/rank=] of operands than specified. This can be queried for each operation using the {{MLContext/opSupportLimits()}} method on {{MLContext}} and inspecting the {{MLTensorLimits/rankRange}}.{{MLRankRange/min}} and {{MLTensorLimits/rankRange}}.{{MLRankRange/max}} values of the corresponding member for the operation.
Implementations MAY impose a more restricted lower bound and/or upper bound on the [=MLOperand/rank=] of operands than specified, but MUST support at least the specified <dfn>required ranks</dfn>. Support can be queried for each operation using the {{MLContext/opSupportLimits()}} method on {{MLContext}} and inspecting the {{MLTensorLimits/rankRange}}.{{MLRankRange/min}} and {{MLTensorLimits/rankRange}}.{{MLRankRange/max}} values of the corresponding member for the operation across DirectML, ONNX Runtime, LiteRT, and CoreML backends in Chromium prototype now.
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.

Same here.

Comment thread index.bs
Comment thread index.bs
<td>{{MLOperandDataType/"uint8"}}</td>
<td>{{MLOperandDataType/"uint8"}}</td>
<td>[=/any rank|N=]</td>
<td>0 to 5</td>
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.

I filed a chromium issue [TFLite] Support the maximum ranks of input for logicalAnd, logicalOr and logicalXor be greater than 4 for it.

@BruceDai , what's your plan for fixing this issue? Generalizing them to 0 to 5D with backend reshapes sounds good to me.

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.

Add minimum data type set and rank range for input, constant, output and each operator into Spec

5 participants