deepr.jobs.OptimizeSavedModel

class deepr.jobs.OptimizeSavedModel(path_saved_model, path_optimized_model, graph_name, feeds, fetch, new_names=<factory>, blacklisted_variables=<factory>)[source]

Converts SavedModel into an optimized protobuf for inference

This job reads the input SavedModel, rename some nodes using the new_names argument (raises an error if some renames cannot be found), create placeholders given by feeds (and removes all other placeholders not in this list), and finally freezes the sub graph that produces the output tensor fetch.

When creating the original SavedModel, it is recommended to use tf.identity operators to mark some tensors as future feeds or fetches.

WARNING: successful completion of this job is no guarantee that the exported Graph is correct. It is recommended to test the export in a separate job.

path_saved_model

Path to directory containing SavedModel exports to convert

Type:

str

path_optimized_model

Path to directory that will contain the export

Type:

str

graph_name

Name of the output graph (name of the protobuf file)

Type:

str

new_names

Mapping old names (SavedModel nodes) -> new names (export)

Type:

Dict[str, str]

blacklisted_variables

List of variable names not to include in the export

Type:

Union[str, List[str]]

feeds

List of nodes to use as inputs, or comma separated string.

Type:

Union[str, List[str]]

fetch

List of nodes to use as output, or comma separated string.

Type:

Union[str, List[str]]

__init__(path_saved_model, path_optimized_model, graph_name, feeds, fetch, new_names=<factory>, blacklisted_variables=<factory>)

Methods

__init__(path_saved_model, ...[, new_names, ...])

run()

Run Job

Attributes

path_saved_model

path_optimized_model

graph_name

feeds

fetch

new_names

blacklisted_variables