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

Function _generate_signatures

tensorflow/python/saved_model/save.py:426–469  ·  view source on GitHub ↗

Validates and calls `signature_functions` in the default graph. Args: signature_functions: A dictionary mapping string keys to concrete TensorFlow functions (e.g. from `signature_serialization.canonicalize_signatures`) which will be used to generate SignatureDefs. resource_map

(signature_functions, resource_map)

Source from the content-addressed store, hash-verified

424
425
426def _generate_signatures(signature_functions, resource_map):
427 """Validates and calls `signature_functions` in the default graph.
428
429 Args:
430 signature_functions: A dictionary mapping string keys to concrete TensorFlow
431 functions (e.g. from `signature_serialization.canonicalize_signatures`)
432 which will be used to generate SignatureDefs.
433 resource_map: A dictionary mapping from resource tensors in the eager
434 context to resource tensors in the Graph being exported. This dictionary
435 is used to re-bind resources captured by functions to tensors which will
436 exist in the SavedModel.
437
438 Returns:
439 Each function in the `signature_functions` dictionary is called with
440 placeholder Tensors, generating a function call operation and output
441 Tensors. The placeholder Tensors, the function call operation, and the
442 output Tensors from the function call are part of the default Graph.
443
444 This function then returns a dictionary with the same structure as
445 `signature_functions`, with the concrete functions replaced by SignatureDefs
446 implicitly containing information about how to call each function from a
447 TensorFlow 1.x Session / the C++ Loader API. These SignatureDefs reference
448 the generated placeholders and Tensor outputs by name.
449
450 The caller is expected to include the default Graph set while calling this
451 function as a MetaGraph in a SavedModel, including the returned
452 SignatureDefs as part of that MetaGraph.
453 """
454 signatures = {}
455 for signature_key, function in sorted(signature_functions.items()):
456 if function.graph.captures:
457 argument_inputs = function.graph.inputs[:-len(function.graph.captures)]
458 else:
459 argument_inputs = function.graph.inputs
460 mapped_inputs, exterior_argument_placeholders = (
461 _map_function_arguments_to_created_inputs(
462 argument_inputs, signature_key, function.name))
463 outputs = _call_function_with_mapped_captures(
464 function, mapped_inputs, resource_map)
465 signatures[signature_key] = signature_def_utils.build_signature_def(
466 _tensor_dict_to_tensorinfo(exterior_argument_placeholders),
467 _tensor_dict_to_tensorinfo(outputs),
468 method_name=signature_constants.PREDICT_METHOD_NAME)
469 return signatures
470
471
472def _trace_resource_initializers(accessible_objects):

Callers 1

_fill_meta_graph_defFunction · 0.85

Tested by

no test coverage detected