问题
In TensorFlow Eager, I can use Python's profiler to profile code that operates purely in eager mode. However, if I "compile" a python function to a graph function using tf.function
or tf.contrib.eager.defun
, that function becomes opaque to python - the profiler cannot enter it.
I have found out how to profile a TF graph in graph mode, but I don't know how to do it with a graph function in eager mode.
Specifically, if I construct a function like this,
tf.enable_v2_behavior()
@tf.function
def myfunc(x):
y = op1(x)
z = op2(y, z)
return z
how do I figure out how much time is spent in op1
and op2
when I execute myfunc?
来源:https://stackoverflow.com/questions/56693208/how-can-i-profile-graph-functions-in-tensorflow-eager