Tensorflow take ages for tf.cond and eval() - python code (sorry but i asked on Stackoverflow but none answer me)
The reason why tf.tensordot(), tf.math.argmax() doesn't change running regardless of the input size is because they don't make the operations, but rather declare it.
It is similar to passing a partial function using functools.partial, the function is not really executed, it just determines it's inputs (or part of it).
from functools import partial
def tensordot(a,b):
    return partial(lambda a,b: a*b,a,b)

While running eval will run the previously mounted model
dot = tensordot(a,b) #dot here is a function
dot() # &lt;- done inside eval

Actually, on tensorflow these &quot;partials&quot; are objects and when you eval one of then, the previously declared objects that it depends of will be evaluated