Open khatchad opened 2 years ago
I just did some test with this in my local computer. The last tf.function
is the only one that is taken into account.
For example:
import tensorflow as tf
@tf.function(experimental_follow_type_hints=True)
@tf.function(autograph=False)
def f(x: tf.Tensor):
if x == 0:
tf.print('x is zero')
print("Tracing")
return x
f(1)
We would get the following error:
OperatorNotAllowedInGraphError: Using a symbolic `tf.Tensor` as a Python `bool` is not allowed: AutoGraph is disabled in this function. Try decorating it directly with @tf.function.
But if we changed the order of the decorators:
import tensorflow as tf
@tf.function(autograph=False)
@tf.function(experimental_follow_type_hints=True)
def f(x: tf.Tensor):
if x == 0:
tf.print('x is zero')
print("Tracing")
return x
f(1)
We wouldn't get the error, which means that it is not taking the autograph=False
into account only tf.function(experimental_follow_type_hints=True)
. Also, we see that tf.function(experimental_follow_type_hints=True)
is working as intended.
It takes the last one.
Our code should take the last one.
@khatchad I believe we have already done this in #37
This is a specific case of #30, which we closed. Therefore, I believe we can close this issue.
In fact, the issue description doesn't mention parameters at all.
I see a test for multiple decorators but not multiple tf.function
decorators.
Actually, I see it in testComputeParameters12
.
And, that is the only one.
And, the code for that case doesn't check that the function is hybrid.
And, it's only the call case.
@tatianacv Please add two test cases for this; one for the call and one for the non-call case.
What happens when there's multiple tf.function decorators for the same function?