-
Notifications
You must be signed in to change notification settings - Fork 330
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
vectorize KPLS: tf.vectorized_map
fallback cause
#291
Comments
Just for reference I copy-paste the current
|
I want to add an example picking the first fallback in the list that has already a registered converter: WARNING tensorflow:pfor.py:1082 Using a while_loop for converting AdjustHue cause Input "delta" of op 'AdjustHue' expected to be loop invariant. This is the converter: @RegisterPFor("AdjustHue")
def _convert_adjust_hue(pfor_input):
images = pfor_input.stacked_input(0)
delta = pfor_input.unstacked_input(1)
return wrap(gen_image_ops.adjust_hue(images, delta), True) So we cannot supersed the limit of the original design of def adjust_hue(image, delta, name=None):
....
....
Args:
image: RGB image or images. The size of the last dimension must be 3.
delta: float. How much to add to the hue channel. IMHO this is going to point again to the original topic related to what kind of empiric evidence we are going to sustain within batch randomization, with the current native ops set we have in TF, vs other alternative solutions like #146 (comment) at least as a workaround to not generate a random augmentation for each sample in the batch for each op. |
As |
Do you have talked about this internally between teams? Any action item? |
We (the TF core team) don't monitor keras-team/keras-cv . The issue needs to be reposted to tensorflow/tensorflow to be under our radar. |
@wangpengmit I understand but this is really a boundary topic. What kind of ticket do you want for TF (core)? Just for the missing converters? |
It can be just a title and a link to this one. TF has a system for alerting TF developers of tensorflow/tensorflow issues. |
Ok let see what we can do in TF at tensorflow/tensorflow#55639 and what we need to change in Keras-cv |
…e conversions. Reference issues: keras-team/keras-cv#264, keras-team/keras-cv#291 PiperOrigin-RevId: 443809170
I update the fallback list on the current master b542921: WARNING tensorflow:pfor.py:1082 Using a while_loop for converting AdjustContrastv2 cause Input "contrast_factor" of op 'AdjustContrastv2' expected to be loop invariant.
WARNING tensorflow:pfor.py:1082 Using a while_loop for converting AdjustHue cause Input "delta" of op 'AdjustHue' expected to be loop invariant.
WARNING tensorflow:pfor.py:1082 Using a while_loop for converting AdjustSaturation cause Input "scale" of op 'AdjustSaturation' expected to be loop invariant.
WARNING tensorflow:pfor.py:1082 Using a while_loop for converting Bitcast cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1082 Using a while_loop for converting DepthwiseConv2dNative cause Input "filter" of op 'DepthwiseConv2dNative' expected to be not loop invariant.
WARNING tensorflow:pfor.py:1082 Using a while_loop for converting DynamicPartition cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1082 Using a while_loop for converting DynamicStitch cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1082 Using a while_loop for converting HistogramFixedWidth cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1082 Using a while_loop for converting ImageProjectiveTransformV3 cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1082 Using a while_loop for converting RandomShuffle cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1082 Using a while_loop for converting RngReadAndSkip cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1082 Using a while_loop for converting StatelessRandomGetKeyCounter cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1082 Using a while_loop for converting StatelessRandomUniformFullIntV2 cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1082 Using a while_loop for converting StatelessRandomUniformV2 cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1082 Using a while_loop for converting StridedSlice cause Input "input" of op 'StridedSlice' expected to be not loop invariant. |
@qlzh727 Just an extra note, as you have already seen in tensorflow/tensorflow#56242 We need to extend this analysis also to the Keras repo for: |
Ack. Will take a look later this week. |
We could write a script to iterate the symbols in the keras_cv.layers.preprocessing namespace. That should cover all KPLs from keras core and keras cv as we alias the core ones there |
Yes, I used some quick and dirty bash command locally to produce these "reports".
This also would be nice to have later when we have the mentioned API in Keras master. |
CCing @ishark . |
Does this problem still exist? |
Yes, this is the updated list today only for the preprocessing layers
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting AdjustContrastv2
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting AdjustHue
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting AdjustSaturation
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting Bitcast
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting CropAndResize
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting DecodeJpeg
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting DepthwiseConv2dNative
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting EncodeJpegVariableQuality
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting HistogramFixedWidth
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting ImageProjectiveTransformV3
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting RandomShuffle
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting RngReadAndSkip
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting StatelessRandomGetKeyCounter
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting StatelessRandomUniformFullIntV2
WARNING tensorflow:pfor.py:1081 Using a while_loop for converting StatelessRandomUniformV2 |
If you, like me, is still facing this issue, my "workaround" is:
|
Hey @Mirandatz - we rolled back changes to the KPLs in the most recent keras release, and we'll be fixing them forwards in KerasCV! Sorry for any inconvenience. |
I tried the most recent version of TensorFlow, using the docker image they provide, and the issue still there.
|
tf.vectorized_map
fallback causetf.vectorized_map
fallback cause
x
latest release should fix this in keras core, working on a fix in KerasCV |
@bhack any way to produce a list of files generating these warnings? I will open tickets for these when we find all of the ones that need to be vectorized (like #1378) |
Mhh, is the warning I have introduced in Tensorflow still controllable now? If yes It seems that you need to enable the warn param and re-execute Keras-CV tests |
About the filename you need to play with the regular expression to keep also the filename as it was in the output (in the case you want to automate that summary). |
Awesome, yeah we can find layers we need to vectorize and disable the warning for layers that we can’t. |
It would be nice if you will update/post the full list to have an complete fresh overview. As I think Pfor converters are quite trivial/fast to contribute. Then we will disabled the warning. |
The updated list on master is: WARNING tensorflow:pfor.py:1084 Using a while_loop for converting Bitcast cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1084 Using a while_loop for converting CropAndResize cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1084 Using a while_loop for converting DecodeJpeg cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1084 Using a while_loop for converting EncodeJpegVariableQuality cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1084 Using a while_loop for converting ImageProjectiveTransformV3 cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1084 Using a while_loop for converting RandomShuffle cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1084 Using a while_loop for converting RngReadAndSkip cause there is no registered converter for this op.
WARNING tensorflow:pfor.py:1084 Using a while_loop for converting StatelessRandomUniformV2 cause there is no registered converter for this op. |
I don't know why but something was suppressed with only the Here the list of params we to randomize over the batch but the op API has no support for the specific batched argument: Here are the pfor conversion stack traces: Input "contrast_factor" of op 'AdjustContrastv2' expected to be loop invariant.
Here are the pfor conversion stack traces: Input "delta" of op 'AdjustHue' expected to be loop invariant.
Here are the pfor conversion stack traces: Input "filter" of op 'DepthwiseConv2dNative' expected to be not loop invariant.
Here are the pfor conversion stack traces: Input "scale" of op 'AdjustSaturation' expected to be loop invariant. |
It seems like this list can be reproduced by just running: Here is an analysis of each layer in
There might be more layers if uncovered by |
You can hack a file in your TF installation dir to check, if covering the converter, it doesn't trigger new issues https://github.com/tensorflow/tensorflow/blob/fc4ae9328b54a71da4954aa8ff75792f0352f1a7/tensorflow/python/ops/parallel_for/pfor.py#L1725:L1726 |
thanks for the comprehensive list! Do you want to open issues to manually vectorize the remaining layers? if you do please link a template PR (any of the previous ones with a benchmark test should suffice) If not I’m happy to do so! |
I won't be able to contribute to this in the nearest time :( |
Sounds good - I’ll open a list for the remaining layers. Thanks for your hard work on the is effort @sebastian-sz! |
I'm willing to vectorize some of the remaining layers. |
Some updates (based on @sebastian-sz #291 (comment))
I will try to vectorize some of them when I'm available |
Woop woop - @james77777778 you've absolutely crushed this issue! Thanks for your hard work on this! |
This is the current list of fallback we have on master with the related cause for our KPLs
(it needs tensorflow/tensorflow#55562 or tf-nightly when merged):pytest -rP keras_cv/layers/preprocessing/ | grep while_loop | sort | uniq
You can find exactly which test is involed running:
pytest -rP keras_cv/layers/preprocessing/
Some of these could be fixed with a refactor in our code, others need a contribution (trivial or not) for a registered converter (e.g. See #259 (comment))
I think that we could care about this:
jit_compile
when we have our compile API readyThe text was updated successfully, but these errors were encountered: