'how to disable tensorflow do compute optimize for graph?

tensorflow version: 1.15.2

I got a model, and in graph, there is custom op which will save a file if it runs.

when I sess.run(the_last_op_tensor), it can return correctly.

but some custom ops are not be executed, because there no files are saved for these op.

if I sess.run(the_custom_op) then the file is saved.

I'm sure the output op is dependent on the custom op.

And if set

session_conf.graph_options.rewrite_options.disable_meta_optimizer = True
session_conf.graph_options.optimizer_options.opt_level = -1  # -1 is L0

some custom op that did not run before can be executed

So I guess tensorflow do some optimization before sess.run

What I want to know is, how to disable the optimization



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source