Disabling `@tf.function` decorators for debugging?

You could use tf.config.experimental_run_functions_eagerly(True).

See here: https://www.tensorflow.org/beta/guide/autograph#debugging.


You could use a global boolean variable DEBUG and apply it to the autograph argument in @tf.function like this:

import tensorflow as tf
DEBUG = False

@tf.function(autograph=not DEBUG)
def foo(x):
    return x + 1

Otherwise, since it is autograph=True by default, not sure whether it is possible without modification of source code.