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

Inconsistent eager/tf.function behavior for rank 0 shape in tf.reshape #51241

Open
jonas-eschle opened this issue Aug 5, 2021 · 6 comments
Open
Assignees
Labels
comp:ops OPs related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.9 Issues found in the TF 2.9 release (or RCs) type:bug Bug

Comments

@jonas-eschle
Copy link
Contributor

jonas-eschle commented Aug 5, 2021

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 20.04
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 2.5.0
  • Python version: 3.8

Describe the current behavior

The eager version of tf.reshape takes a rank 0 tensor as a shape parameter while the jitted (tf.function decorated) does not.

Describe the expected behavior

It should be consistent, either fail in both or allow in both. To be consistent with other methods, I think it should fail in both.

Contributing

  • Do you want to contribute a PR? (yes/no): maybe
  • Briefly describe your candidate solution(if contributing): raise an error, such as done in other methods like tf.random.uniform

Standalone code to reproduce the issue
executable example here

import tensorflow as tf

def func():
    return tf.reshape([[42]], 1)


func_jit = tf.function(func=func)

func()  # works
func_jit()  # fails
@jonas-eschle jonas-eschle added the type:bug Bug label Aug 5, 2021
@kumariko kumariko assigned kumariko and unassigned saikumarchalla Aug 6, 2021
@kumariko kumariko added comp:ops OPs related issues TF 2.5 Issues related to TF 2.5 labels Aug 6, 2021
@kumariko
Copy link

kumariko commented Aug 6, 2021

I am able to reproduce the error in tensorflow v2.11.0-dev20220829.

Please find the gist for your reference here. Thanks!

@kumariko kumariko assigned Saduf2019 and unassigned kumariko Aug 6, 2021
@Saduf2019
Copy link
Contributor

@mayou36
Can you please confirm the jit compilation is enabled.

@Saduf2019 Saduf2019 added the stat:awaiting response Status - Awaiting response from author label Aug 9, 2021
@jonas-eschle jonas-eschle changed the title Inconsistent eager/jit behavior for rank 0 shape in tf.reshape Inconsistent eager/tf.function behavior for rank 0 shape in tf.reshape Aug 9, 2021
@jonas-eschle
Copy link
Contributor Author

By "jit" I mean "tf.function" decorated (jitted), not XLA compiled. So it works in eager, but not inside a tf.function.

It seems to happen with and without jit_compiled on, both.

@tensorflowbutler tensorflowbutler removed the stat:awaiting response Status - Awaiting response from author label Aug 11, 2021
@Saduf2019
Copy link
Contributor

@jonas-eschle
Please confirm if this is still an issue.

@Saduf2019 Saduf2019 added the stat:awaiting response Status - Awaiting response from author label Oct 13, 2021
@jonas-eschle
Copy link
Contributor Author

It is. I've updated the gist and it is still broken, even with TF-nightly

@tensorflowbutler tensorflowbutler removed the stat:awaiting response Status - Awaiting response from author label Oct 15, 2021
@sachinprasadhs sachinprasadhs added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Nov 4, 2021
@bgdax
Copy link

bgdax commented Nov 4, 2021

Thank you for raising this issue. We are discussing internally the available options, and we'll update with the result.

@tilakrayal tilakrayal added TF 2.9 Issues found in the TF 2.9 release (or RCs) and removed TF 2.5 Issues related to TF 2.5 labels Aug 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:ops OPs related issues stat:awaiting tensorflower Status - Awaiting response from tensorflower TF 2.9 Issues found in the TF 2.9 release (or RCs) type:bug Bug
Projects
None yet
Development

No branches or pull requests

8 participants