From db1293e8956cac48ada1b4a976470461bfa2a7e3 Mon Sep 17 00:00:00 2001 From: Monica Song Date: Mon, 9 Nov 2020 15:37:57 -0800 Subject: [PATCH] Update save_options.function_aliases docstring. PiperOrigin-RevId: 341499805 Change-Id: I70b6795d73a50fdf225f5b25bb5ad4ca70c6ab6b --- tensorflow/python/saved_model/save_options.py | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/tensorflow/python/saved_model/save_options.py b/tensorflow/python/saved_model/save_options.py index f6330848441..30795ac7929 100644 --- a/tensorflow/python/saved_model/save_options.py +++ b/tensorflow/python/saved_model/save_options.py @@ -126,26 +126,22 @@ class SaveOptions(object): by a single tf.function you can use the `function_aliases` argument to store a map from the alias name to all concrete function names. E.g. - ```python - class MyModel: - @tf.function - def func(): - ... - @tf.function - def serve(): - ... - func() + >>> class Adder(tf.Module): + ... @tf.function + ... def double(self, x): + ... return x + x + + >>> model = Adder() + >>> model.double.get_concrete_function( + ... tf.TensorSpec(shape=[], dtype=tf.float32, name="float_input")) + >>> model.double.get_concrete_function( + ... tf.TensorSpec(shape=[], dtype=tf.string, name="string_input")) + + >>> options = tf.saved_model.SaveOptions( + ... function_aliases={'double': model.double}) + >>> tf.saved_model.save(model, '/tmp/adder', options=options) - model = MyModel() - signatures = { - 'serving_default': model.serve.get_concrete_function(), - } - options = tf.saved_model.SaveOptions(function_aliases={ - 'my_func': func, - }) - tf.saved_model.save(model, export_dir, signatures, options) - ``` experimental_io_device: string. Applies in a distributed setting. Tensorflow device to use to access the filesystem. If `None` (default) then for each variable the filesystem is accessed from the CPU:0 device