Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upCount number of times `tf.function` is traced #37323
Comments
|
One thing I could do is check |
|
Indeed, you should avoid using private fields - they may change at any moment. The easiest and most robust way is to use a global Python counter, like so:
|
|
This only works for certain cases, and doesn't seem scalable to every function everywhere. I'd have to have a different global variable for each function. What if my function is written in one file, and I wrap it in |
|
I missed that this was a feature request. Sounds reasonable to me. |
|
Any suggestions on how this can be implemented? I would like to give a try if we have any pointers |
|
A simple solution would be to just add a public method to the I'm not sure of the implications of this though, as |
|
Fields are kept private by default, and we only expose public methods if there is a need for one. This helps keep the API clean - once a method is made public, it's extremely difficult to remove it. So for now, I recommend naming the method/property with the |
|
I'd like to give this a shot. Can I submit a PR for this? |
|
can i work on this? @ammirato |
|
@ammirato, can I work on this and submit a PR |
|
How about a static variable in the function class? |
|
import my_function
#is it right....? |
|
Is this issue closed? or is it open for contributions? I see that the PR is closed. Thanks |
|
PR has been closed in unmerged state |
|
If I got the issue correctly you want to save the state of your graph so you can use lru cache, I tested both inside tensorflow library and only combination of @tf.function and @lru_cache in my main.py and both worked fine but actually i was testing a simple graph with one plus, I don't know the side effects |
|
Is this feature still needed? I can see previous PR was closed in an unmerged state. Thanks. |
|
if hv mentioned the right one...... |
|
HI I am new to the open source community , |
I too am new... can anyone help by letting us know on how to pick issues to work on and start contributing? I mean can multiple people work on the same issue or does someone lock or book an issue to start work. |


Please make sure that this is a feature request. As per our GitHub Policy, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:feature_template
System information
Describe the feature and the current behavior/state.
I would like to be able to check, inside a function wrapped by
tf.function, when this function is being retraced. This is useful for testing my functions are compatible withtf.function, and will make use of the speed up (and not just make a new graph every time they are called).An example, with the requested feature would be inserted in
REQUEST:Will this change the current api? How?
I'm not sure, maybe just add a function, maybe it already exists.
Who will benefit with this feature?
Anyone debugging.
Any Other info.