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

@tf.function doesn't compile functions specified as parameters to other functions #26793

Closed
hjfreyer opened this issue Mar 16, 2019 · 3 comments
Assignees
Labels
comp:autograph Autograph related issues TF 2.0 Issues relating to TensorFlow 2.0 type:bug Bug WIP

Comments

@hjfreyer
Copy link

hjfreyer commented Mar 16, 2019

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): No.
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Colab.
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
  • TensorFlow installed from (source or binary): Binary
  • TensorFlow version (use command below): 2.0.0-alpha0
  • Python version: 3.6.7 (default, Oct 22 2018, 11:32:17) \n[GCC 8.2.0]
  • Bazel version (if compiling from source): N/A
  • GCC/Compiler version (if compiling from source): N/A
  • CUDA/cuDNN version: ??
  • GPU model and memory: ??

Describe the current behavior

Code annotated with @tf.function behaves differently depending on whether functions are called and captured as variables, or called and passed directly to other functions.

In particular, it seems the autograph magic doesn't get applied to functions that are only called within the parameter list of other functions.

I may be misinterpreting what exactly is going wrong, but certainly the behavior shown in the colab below is incorrect.

Describe the expected behavior

Capturing via an intermediate variable should never change code behavior.

Code to reproduce the issue

https://colab.research.google.com/drive/1CcWfHnGkFehUN8LYsbODf_fNSsQncE0G

@ymodak ymodak self-assigned this Mar 19, 2019
@ymodak ymodak added 2.0.0-alpha0 comp:autograph Autograph related issues type:bug Bug labels Mar 19, 2019
@ymodak ymodak assigned mdanatg and unassigned ymodak Mar 19, 2019
@ymodak ymodak added the stat:awaiting tensorflower Status - Awaiting response from tensorflower label Mar 19, 2019
@mdanatg
Copy link

mdanatg commented Mar 19, 2019

Thank you for the nice repro! Yes, that is definitely a bug.

@mdanatg mdanatg added WIP and removed stat:awaiting tensorflower Status - Awaiting response from tensorflower labels Mar 19, 2019
@tensorflow-bot
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@tensorflow-bot
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

@lvenugopalan lvenugopalan added the TF 2.0 Issues relating to TensorFlow 2.0 label Apr 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:autograph Autograph related issues TF 2.0 Issues relating to TensorFlow 2.0 type:bug Bug WIP
Projects
None yet
Development

No branches or pull requests

4 participants