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

Function ImportGraphDef

tensorflow/core/graph/graph_constructor.cc:1464–1535  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1462}
1463
1464Status ImportGraphDef(const ImportGraphDefOptions& opts, const GraphDef& gdef,
1465 Graph* g, ShapeRefiner* refiner,
1466 ImportGraphDefResults* results) {
1467 if (!opts.return_tensors.empty()) {
1468 if (results == nullptr) {
1469 return errors::InvalidArgument(
1470 "results argument to ImportGraphDef() must be non-null if "
1471 "opts.return_tensors is non-empty");
1472 }
1473 }
1474
1475 if (!opts.return_nodes.empty()) {
1476 if (opts.skip_mapped_nodes) {
1477 return errors::InvalidArgument(
1478 "Requesting return_nodes with skip_mapped_nodes set is not currently "
1479 "supported");
1480 }
1481 if (results == nullptr) {
1482 return errors::InvalidArgument(
1483 "results argument to ImportGraphDef() must be non-null if "
1484 "opts.return_nodes is non-empty");
1485 }
1486 }
1487
1488 if (results != nullptr) {
1489 if (!results->return_tensors.empty() || !results->return_nodes.empty() ||
1490 !results->missing_unused_input_map_keys.empty()) {
1491 return errors::InvalidArgument(
1492 "All fields in results argument to ImportGraphDef() must be empty.");
1493 }
1494 }
1495
1496 ShapeRefiner default_refiner(gdef.versions().producer(), g->op_registry());
1497 if (refiner == nullptr) {
1498 refiner = &default_refiner;
1499 } else {
1500 // Log a warning if we are importing a GraphDef at an older
1501 // producer version after already having added non-source/sink
1502 // nodes to the graph in the past.
1503 if (gdef.versions().producer() > 0 &&
1504 gdef.versions().producer() < refiner->graph_def_version() &&
1505 g->num_nodes() > 2) {
1506 LOG(WARNING) << "Importing a graph with a lower producer version "
1507 << gdef.versions().producer()
1508 << " into an existing graph with producer version "
1509 << refiner->graph_def_version() << ". Shape inference will "
1510 << "have run different parts of the graph with different "
1511 << "producer versions.";
1512 }
1513 }
1514
1515 // Set the graph def version of the refiner as the min of the
1516 // current value and the version from the graph we are about to
1517 // import.
1518 //
1519 // Note: to match Run() semantics, we should re-run shape inference
1520 // on the entire graph if the producer version has changed. For now
1521 // we log the warning above.

Callers 14

ExpectErrorMethod · 0.70
ExpectOKMethod · 0.70
TEST_FFunction · 0.70
FromGraphMethod · 0.50
TESTFunction · 0.50
ClusterizeNodesMethod · 0.50
BuildClusterByBorderMethod · 0.50
FuseClusterMethod · 0.50
LoadGraphFromProtoMethod · 0.50

Calls 10

InvalidArgumentFunction · 0.85
set_graph_def_versionMethod · 0.80
minFunction · 0.50
emptyMethod · 0.45
versionsMethod · 0.45
op_registryMethod · 0.45
graph_def_versionMethod · 0.45
num_nodesMethod · 0.45
nodeMethod · 0.45
libraryMethod · 0.45

Tested by 4

ExpectErrorMethod · 0.56
ExpectOKMethod · 0.56
TEST_FFunction · 0.56
TESTFunction · 0.40