-
Notifications
You must be signed in to change notification settings - Fork 53
add minimum data types and rank range for operations #910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
add minimum data types and rank range for operations #910
Conversation
| <tr> | ||
| <td>{{input}}</td> | ||
| <td>specified as part of operation steps</td> | ||
| <td></td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to @fdwr's comments on #278 (comment), l2Pool2d is still not implemented in TFLite backend yet, so here I just followed @huningxin's comments on #853.
"l2Pool2d": {
"input": {
"dataTypes": [],
"rankRange": {}
},
"output": {
"dataTypes": []
}
},
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That TFLite l2Pool2d issue has been pending since 2022-06-30 😳. The Chromium backend that calls TFLite could just emulate it for now to unblock us. e.g.:
powResult = pow(input, exponent)
poolSumResult = poolSum(powResult, axes, windowDimensions, padding, strides, dilations)
// where poolSum can be emulated via poolAverage(input * product(windowDimensions)...)
// or by convolution with a filter of 1's.
result = root(poolSumResult, exponent)
(no action expected in this PR - resolve me)
@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). |
reillyeon
left a comment
There was a problem hiding this 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.
fdwr
left a comment
There was a problem hiding this 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.
| <td>[=/any data type|any=]</td> | ||
| <td>{{MLOperandDataType/"float32"}}, {{MLOperandDataType/"float16"}}, {{MLOperandDataType/"int32"}}</td> | ||
| <td>[=/any rank|N=]</td> | ||
| <td>0 to 4</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which ML API is the outlier for pow being 0 to 4 instead of 0 to 5? It will be problematic for callers if mul/div/pow have inconsistent ranks from each other, as certain substitution operations might expect that they can safely chain these or switch from one to another (e.g. mul(a,a) == pow(a,2)) without surprise. I propose the outlier API fix this in their Chromium backend with flanking reshapes (flatten to 1D if > 4D, pow, then back to the original shape). Then pow can be remerged back with the rest above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which ML API is the outlier for pow being 0 to 4 instead of 0 to 5?
It's limited by TFLite backend.
Please refer to https://source.chromium.org/chromium/chromium/src/+/main:services/webnn/tflite/graph_builder_tflite.cc;l=568
// Limited to 4D when broadcasting is required:
// https://source.chromium.org/chromium/chromium/src/+/main:third_party/tflite/src/tensorflow/lite/kernels/pow.cc
/*pow_input=*/{kFloat16To32AndInt32, SupportedRanks::UpTo(4)},There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we open a TFLite issue? Alternately we open a Chromium issue to {reshape, expand if needed, pow} until TFLite can address it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed a Chromium issue - https://issues.chromium.org/issues/471017637.
| <tr> | ||
| <td>{{input}}</td> | ||
| <td>specified as part of operation steps</td> | ||
| <td></td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That TFLite l2Pool2d issue has been pending since 2022-06-30 😳. The Chromium backend that calls TFLite could just emulate it for now to unblock us. e.g.:
powResult = pow(input, exponent)
poolSumResult = poolSum(powResult, axes, windowDimensions, padding, strides, dilations)
// where poolSum can be emulated via poolAverage(input * product(windowDimensions)...)
// or by convolution with a filter of 1's.
result = root(poolSumResult, exponent)
(no action expected in this PR - resolve me)
| <tr> | ||
| <td>{{input}}</td> | ||
| <td>[=/any data type|any=]</td> | ||
| <td>{{MLOperandDataType/"float32"}}, {{MLOperandDataType/"float16"}}, {{MLOperandDataType/"int32"}}, {{MLOperandDataType/"int8"}}, {{MLOperandDataType/"uint8"}}</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gatherElements includes int8/uint8, but its symmetric counterpart scatterElements does not 😳 I don't know which API has this surprising inconsistency, but I'd rather restrict gatherElements's required data types to exclude int8/uint8 than introduce this asymmetry.
| </thead> | ||
| <tr> | ||
| <td>{{input}}</td> | ||
| <td>specified as part of operation steps</td> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we reflect allowed data types in table?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@huningxin In operation steps, the input of averagePool2d supports "float32", "float16" two data types, and the input of maxPool2d supports any data types, so I keep pervious descriptions here.
index.bs
Outdated
| <tr> | ||
| <td>{{input}}</td> | ||
| <td>[=/any data type|any=]</td> | ||
| <td>{{MLOperandDataType/"float32"}}, {{MLOperandDataType/"float16"}}, {{MLOperandDataType/"int32"}}</td> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
|
Thanks @huningxin and @fdwr for review and identifications. 👍 |
This PR is to fix #896.
@huningxin @fdwr @reillyeon PTAL, thanks!
Preview | Diff