Skip to content
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

Fix crash of tf.image.extract_glimpse with negative input #51658

Merged

Conversation

yongtang
Copy link
Member

This PR tries to fix the issue raised in #51618 where
tf.image.extract_glimpse will crash in case of negative input.

This PR adds additional checking to allow graceful error message.

This PR fixes #51618.

Signed-off-by: Yong Tang yong.tang.github@outlook.com

@google-ml-butler google-ml-butler bot added the size:S CL Change Size: Small label Aug 24, 2021
@google-cla google-cla bot added the cla: yes label Aug 24, 2021
@google-ml-butler google-ml-butler bot added the awaiting review Pull request awaiting review label Aug 24, 2021
@gbaned gbaned self-assigned this Aug 25, 2021
@gbaned gbaned added comp:core issues related to core part of tensorflow prtype:bugfix PR to fix a bug labels Aug 25, 2021
@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation Aug 25, 2021
@gbaned gbaned requested a review from jpienaar September 7, 2021 14:40
Copy link
Member

@jpienaar jpienaar left a comment

Choose a reason for hiding this comment

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

Nice, thanks!

@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Sep 7, 2021
PR Queue automation moved this from Assigned Reviewer to Approved by Reviewer Sep 7, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Sep 7, 2021
@google-ml-butler google-ml-butler bot added the kokoro:force-run Tests on submitted change label Sep 7, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Sep 7, 2021
@gbaned gbaned added ready to pull PR ready for merge process and removed awaiting review Pull request awaiting review ready to pull PR ready for merge process labels Sep 8, 2021
@gbaned
Copy link
Contributor

gbaned commented Sep 14, 2021

Here are the internal errors, @yongtang can you please verify ? Thanks!

Traceback (most recent call last):
File "/tensorflow/python/framework/ops.py", line 1926, in _create_c_op
c_op = pywrap_tf_session.TF_FinishOperation(op_desc)
google3.third_party.tensorflow.python.framework.errors_impl.InvalidArgumentError: Shape must be rank 2 but is rank 1 for '{{node ExtractGlimpseV2}} = ExtractGlimpseV2[centered=false, noise="uniform", normalized=false, uniform_noise=false](ExtractGlimpseV2/input, ExtractGlimpseV2/size, ExtractGlimpseV2/offsets)' with input shapes: [1,3,3,1], [2], [2].

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/tensorflow/python/kernel_tests/attention_ops_test.py", line 314, in testGlimpseNegativeInput
normalized=False)
File "/tensorflow/python/util/traceback_utils.py", line 141, in error_handler
return fn(*args, **kwargs)
File "/tensorflow/python/util/dispatch.py", line 1048, in op_dispatch_handler
return dispatch_target(*args, **kwargs)
File "/tensorflow/python/ops/image_ops_impl.py", line 4945, in extract_glimpse_v2
name=name)
File "/tensorflow/python/ops/gen_image_ops.py", line 2015, in extract_glimpse_v2
name=name)
File "/tensorflow/python/framework/op_def_library.py", line 751, in _apply_op_helper
attrs=attr_protos, op_def=op_def)
File "/tensorflow/python/framework/ops.py", line 3695, in _create_op_internal
op_def=op_def)
File "/tensorflow/python/framework/ops.py", line 2088, in init
control_input_ops, op_def)
File "/tensorflow/python/util/traceback_utils.py", line 141, in error_handler
return fn(*args, **kwargs)
File "/tensorflow/python/framework/ops.py", line 1929, in _create_c_op
raise ValueError(e.message)
ValueError: Shape must be rank 2 but is rank 1 for '{{node ExtractGlimpseV2}} = ExtractGlimpseV2[centered=false, noise="uniform", normalized=false, uniform_noise=false](ExtractGlimpseV2/input, ExtractGlimpseV2/size, ExtractGlimpseV2/offsets)' with input shapes: [1,3,3,1], [2], [2].

This PR tries to fix the issue raised in 51618 where
tf.image.extract_glimpse will crash in case of negative input.

This PR adds additional checking to allow graceful error message.

This PR fixes 51618.

Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
Signed-off-by: Yong Tang <yong.tang.github@outlook.com>
@yongtang yongtang force-pushed the 51618-tf.image.extract_glimpse branch from b0c1d1a to ad799ad Compare September 14, 2021 17:34
@google-ml-butler google-ml-butler bot removed the ready to pull PR ready for merge process label Sep 14, 2021
@yongtang
Copy link
Member Author

Thanks @mihaimaruseac @gbaned, I have updated the PR with additional exceptions captured. Please give it a try.

@google-ml-butler google-ml-butler bot added the awaiting review Pull request awaiting review label Sep 15, 2021
@google-ml-butler google-ml-butler bot added the kokoro:force-run Tests on submitted change label Oct 4, 2021
@google-ml-butler google-ml-butler bot added the ready to pull PR ready for merge process label Oct 4, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Oct 4, 2021
@tensorflowbutler tensorflowbutler removed the awaiting review Pull request awaiting review label Oct 6, 2021
@gbaned gbaned removed the ready to pull PR ready for merge process label Oct 6, 2021
@google-ml-butler google-ml-butler bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Oct 6, 2021
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Oct 6, 2021
@copybara-service copybara-service bot merged commit a871989 into tensorflow:master Oct 6, 2021
@google-ml-butler google-ml-butler bot removed the ready to pull PR ready for merge process label Oct 6, 2021
@yongtang yongtang deleted the 51618-tf.image.extract_glimpse branch October 6, 2021 16:16
mihaimaruseac added a commit that referenced this pull request Oct 28, 2021
…fb4f0e5c5b62fbc19edf-on-r2.4

Merge pull request #51658 from yongtang:51618-tf.image.extract_glimpse
mihaimaruseac added a commit that referenced this pull request Oct 28, 2021
…fb4f0e5c5b62fbc19edf-on-r2.5

Merge pull request #51658 from yongtang:51618-tf.image.extract_glimpse
mihaimaruseac added a commit that referenced this pull request Oct 28, 2021
…fb4f0e5c5b62fbc19edf-on-r2.6

Merge pull request #51658 from yongtang:51618-tf.image.extract_glimpse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes comp:core issues related to core part of tensorflow prtype:bugfix PR to fix a bug size:S CL Change Size: Small
Projects
PR Queue
  
Approved by Reviewer
Development

Successfully merging this pull request may close these issues.

tf.image.extract_glimpse crashes with negative input
6 participants