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

Function _import_graph_def_internal

tensorflow/python/framework/importer.py:415–540  ·  view source on GitHub ↗

Imports the graph from `graph_def` into the current default `Graph`. This function provides a way to import a serialized TensorFlow [`GraphDef`](https://www.tensorflow.org/code/tensorflow/core/framework/graph.proto) protocol buffer, and extract individual objects in the `GraphDef` as `tf.Te

(  # pylint: disable=invalid-name
    graph_def,
    input_map=None,
    return_elements=None,
    validate_colocation_constraints=True,
    name=None,
    op_dict=None,
    producer_op_list=None)

Source from the content-addressed store, hash-verified

413
414
415def _import_graph_def_internal( # pylint: disable=invalid-name
416 graph_def,
417 input_map=None,
418 return_elements=None,
419 validate_colocation_constraints=True,
420 name=None,
421 op_dict=None,
422 producer_op_list=None):
423 """Imports the graph from `graph_def` into the current default `Graph`.
424
425 This function provides a way to import a serialized TensorFlow
426 [`GraphDef`](https://www.tensorflow.org/code/tensorflow/core/framework/graph.proto)
427 protocol buffer, and extract individual objects in the `GraphDef` as
428 `tf.Tensor` and `tf.Operation` objects. Once extracted,
429 these objects are placed into the current default `Graph`. See
430 `tf.Graph.as_graph_def` for a way to create a `GraphDef`
431 proto.
432
433 Args:
434 graph_def: A `GraphDef` proto containing operations to be imported into the
435 default graph.
436 input_map: A dictionary mapping input names (as strings) in `graph_def` to
437 `Tensor` objects. The values of the named input tensors in the imported
438 graph will be re-mapped to the respective `Tensor` values.
439 return_elements: A list of strings containing operation names in `graph_def`
440 that will be returned as `Operation` objects; and/or tensor names in
441 `graph_def` that will be returned as `Tensor` objects.
442 validate_colocation_constraints: Whether to validate colocation constraints.
443 name: (Optional.) A prefix that will be prepended to the names in
444 `graph_def`. Note that this does not apply to imported function names.
445 Defaults to `"import"`.
446 op_dict: (Optional.) Deprecated, do not use.
447 producer_op_list: (Optional.) An `OpList` proto with the (possibly stripped)
448 list of `OpDef`s used by the producer of the graph. If provided,
449 unrecognized attrs for ops in `graph_def` that have their default value
450 according to `producer_op_list` will be removed. This will allow some more
451 `GraphDef`s produced by later binaries to be accepted by earlier binaries.
452
453 Returns:
454 A list of `Operation` and/or `Tensor` objects from the imported graph,
455 corresponding to the names in `return_elements`,
456 and None if `returns_elements` is None.
457
458 Raises:
459 TypeError: If `graph_def` is not a `GraphDef` proto,
460 `input_map` is not a dictionary mapping strings to `Tensor` objects,
461 or `return_elements` is not a list of strings.
462 ValueError: If `input_map`, or `return_elements` contains names that
463 do not appear in `graph_def`, or `graph_def` is not well-formed (e.g.
464 it refers to an unknown tensor).
465 """
466 op_dict = op_def_registry.get_registered_ops()
467
468 graph_def = _ProcessGraphDefParam(graph_def, op_dict)
469 input_map = _ProcessInputMapParam(input_map)
470 return_elements = _ProcessReturnElementsParam(return_elements)
471
472 if producer_op_list is not None:

Callers 2

import_graph_defFunction · 0.85

Calls 14

_ProcessGraphDefParamFunction · 0.85
_ProcessInputMapParamFunction · 0.85
_RemoveDefaultAttrsFunction · 0.85
_ConvertInputMapValuesFunction · 0.85
_ProcessNewOpsFunction · 0.85
_GatherReturnElementsFunction · 0.85
_mutation_lockMethod · 0.80
name_scopeMethod · 0.45
valuesMethod · 0.45
SerializeToStringMethod · 0.45

Tested by

no test coverage detected