Hi,
Please consider the following code snippet.
import tensorflow as tf
@tf.function
def f(n):
while (n>0):
print("Trace: ", n)
tf.print("execution:" , n)
n = n -1
Case 1: When we call the above function with TF-Objects arguments, the following is the output.
f(tf.constant(3))
print("next")
f(tf.constant(3))
Trace: Tensor("while/Placeholder:0", shape=(), dtype=int32)
execution: 3
execution: 2
execution: 1
next
execution: 3
execution: 2
execution: 1
Case 2: When we call the above function with Python Object, the following is the output.
f(3)
print("next")
f(3)
Trace: 3
Trace: 2
Trace: 1
execution: 3
execution: 2
execution: 1
next
execution: 3
execution: 2
execution: 1
In case 2, behavior is almost similar to case 1. Why?
In case 2 with Python-Object call, There is no tracing print for the second call. Why is that?