MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / Run

Method Run

tensorflow/tools/optimization/optimization_pass_runner.cc:94–130  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92} // namespace
93
94Status OptimizationPassRunner::Run(absl::string_view pass_to_run,
95 GraphDef input, GraphDef* result) {
96 auto session_options = absl::make_unique<SessionOptions>();
97 session_options->config.mutable_graph_options()
98 ->mutable_optimizer_options()
99 ->set_global_jit_level(jit_level_);
100 FunctionDefLibrary flib;
101 std::unique_ptr<Graph> graph = absl::make_unique<Graph>(OpRegistry::Global());
102
103 GraphOptimizationPassOptions options;
104 options.session_options = session_options.get();
105 options.graph = &graph;
106 std::unique_ptr<FunctionLibraryDefinition> flib_def(
107 new FunctionLibraryDefinition((*options.graph)->op_registry(), flib));
108 options.flib_def = flib_def.get();
109
110 // Grab the data
111 GraphConstructorOptions graph_opts;
112 graph_opts.expect_device_spec = true;
113 graph_opts.allow_internal_ops = true;
114 TF_RETURN_IF_ERROR(ConvertGraphDefToGraph(graph_opts, std::move(input),
115 options.graph->get()));
116
117 // Add all devices that were previously configured with AddDevice.
118 DeviceSet device_set;
119 for (auto& device : devices_) {
120 device_set.AddDevice(device.get());
121 }
122 options.device_set = &device_set;
123
124 GraphOptimizationPass* pass;
125 TF_RETURN_IF_ERROR(FindPassWithName(pass_to_run, &pass));
126 TF_RETURN_IF_ERROR(pass->Run(options));
127
128 options.graph->get()->ToGraphDef(result);
129 return Status::OK();
130}
131
132Status OptimizationPassRunner::SetJitLevel(
133 OptimizerOptions::GlobalJitLevel jit_level) {

Callers 15

InitializeVariablesFunction · 0.45
GetOutputShapesFunction · 0.45
RunBenchmarkFunction · 0.45
RealMainFunction · 0.45
TestConstantFoldingMethod · 0.45
TestFuseResizeAndConvMethod · 0.45
TestFusePadAndConvMethod · 0.45
TestQuantizeWeightsMethod · 0.45

Calls 6

ConvertGraphDefToGraphFunction · 0.85
FindPassWithNameFunction · 0.85
getMethod · 0.45
op_registryMethod · 0.45
AddDeviceMethod · 0.45
ToGraphDefMethod · 0.45