Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Tensorflow: configure grappler
// Tensorflow session
tensorflow::SessionOptions session_opts;
tensorflow::OptimizerOptions* options = session_opts.config.mutable_graph_options()->mutable_optimizer_options();
// Disable optimizations
options->set_opt_level(tensorflow::OptimizerOptions::L0);
// Grappler related optimizations
auto config = session_opts.config.mutable_graph_options()->mutable_rewrite_options();
config->set_layout_optimizer(tensorflow::RewriterConfig::OFF);
config->set_disable_model_pruning(true);
config->set_function_optimization(tensorflow::RewriterConfig::OFF);
config->set_arithmetic_optimization(tensorflow::RewriterConfig::OFF);
config->set_loop_optimization(tensorflow::RewriterConfig::OFF);
config->set_dependency_optimization(tensorflow::RewriterConfig::OFF);
config->set_constant_folding(tensorflow::RewriterConfig::OFF);
config->set_memory_optimization(tensorflow::RewriterConfig::NO_MEM_OPT);
config->set_shape_optimization(tensorflow::RewriterConfig::OFF);
config->set_remapping(tensorflow::RewriterConfig::OFF);
config->set_pin_to_host_optimization(tensorflow::RewriterConfig::OFF);
config->mutable_auto_parallel()->set_enable(false);
config->clear_optimizers();
// Create tensorflow session with customized options
std::unique_ptr<tensorflow::Session> tf_session(tensorflow::NewSession(session_opts));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment