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

Function TransformGraph

tensorflow/tools/graph_transforms/transform_graph.cc:303–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

301}
302
303Status TransformGraph(const std::vector<string>& inputs,
304 const std::vector<string>& outputs,
305 const TransformParameters& transform_params,
306 GraphDef* graph_def) {
307 TransformRegistry* transform_registry = GetTransformRegistry();
308 for (const auto& transform_info : transform_params) {
309 const string& transform_name = transform_info.first;
310 if (transform_name.empty()) {
311 continue;
312 }
313 if (!transform_registry->count(transform_name)) {
314 return errors::InvalidArgument("Transform '", transform_name,
315 "' not recognized.");
316 }
317 LOG(INFO) << "Applying " << transform_name;
318 const TransformFunc& transform_func =
319 transform_registry->at(transform_name);
320 TransformFuncContext context;
321 context.input_names = inputs;
322 context.output_names = outputs;
323 context.params = transform_info.second;
324 bool ignore_errors;
325 TF_RETURN_IF_ERROR(
326 ShouldIgnoreErrors(transform_info.second, &ignore_errors));
327 GraphDef transformed_graph_def;
328 Status transform_result =
329 transform_func(*graph_def, context, &transformed_graph_def);
330 if (!transform_result.ok()) {
331 if (ignore_errors) {
332 LOG(ERROR) << transform_name << ": Ignoring error "
333 << transform_result.error_message();
334 transformed_graph_def = *graph_def;
335 } else {
336 return transform_result;
337 }
338 }
339 // Copy over the library from the original input graph.
340 *transformed_graph_def.mutable_library() = graph_def->library();
341 TF_RETURN_IF_ERROR(IsGraphValid(transformed_graph_def));
342
343 *graph_def = transformed_graph_def;
344 }
345 return Status::OK();
346}
347} // namespace graph_transforms
348} // namespace tensorflow

Callers 1

Calls 9

GetTransformRegistryFunction · 0.85
InvalidArgumentFunction · 0.85
ShouldIgnoreErrorsFunction · 0.85
IsGraphValidFunction · 0.85
emptyMethod · 0.45
countMethod · 0.45
atMethod · 0.45
okMethod · 0.45
libraryMethod · 0.45

Tested by

no test coverage detected