Update save_options.function_aliases docstring.
PiperOrigin-RevId: 341499805 Change-Id: I70b6795d73a50fdf225f5b25bb5ad4ca70c6ab6b
This commit is contained in:
parent
30b69242f8
commit
db1293e895
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user