-
Notifications
You must be signed in to change notification settings - Fork 19.7k
Fix histogram op for symbolic inputs #21729
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #21729 +/- ##
=======================================
Coverage 82.59% 82.59%
=======================================
Files 572 572
Lines 58535 58535
Branches 9158 9158
=======================================
Hits 48345 48345
Misses 7853 7853
Partials 2337 2337
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Works with |
Alright, played some ops golf here, and replaced |
|
|
||
| # tf.math.bincount does not work with XLA in this case. So, we use | ||
| # `tensor_scatter_nd_add`. | ||
| bin_counts = tf.tensor_scatter_nd_add( |
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.
It looks like you can just use tf.scatter_nd:
- it creates a new tensor with zeros
- it also sums in the case of duplicate indices
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, done!
Resolves #21708
On the TensorFlow backend,
ops.histogramconverts a tensor to a Python list [here], which won't work in graph mode with symbolic tensors. The current piece of code usestf.raw_ops.Bucketizewhich necessarily requiresboundariesto be a Python list [see documentation].This PR:
tf.raw_ops.Bucketizewithtf.searchsorted;predict;We should probably add a unit test which tests
model.predictfor every op at some point.Note: Skipping the NumPy test for
predict. Seems to be an unrelated issue. We can solve it separately.