• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2016 The TensorFlow Authors. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# ==============================================================================
15"""Constants for SavedModel save and restore operations.
16
17"""
18from __future__ import absolute_import
19from __future__ import division
20from __future__ import print_function
21
22from tensorflow.python.util.tf_export import tf_export
23
24# Subdirectory name containing the asset files.
25ASSETS_DIRECTORY = "assets"
26tf_export(
27    "saved_model.ASSETS_DIRECTORY",
28    v1=[
29        "saved_model.ASSETS_DIRECTORY", "saved_model.constants.ASSETS_DIRECTORY"
30    ]).export_constant(__name__, "ASSETS_DIRECTORY")
31
32# Subdirectory name containing unmanaged files from higher-level APIs.
33EXTRA_ASSETS_DIRECTORY = "assets.extra"
34
35# CollectionDef key containing SavedModel assets.
36ASSETS_KEY = "saved_model_assets"
37tf_export(
38    "saved_model.ASSETS_KEY",
39    v1=["saved_model.ASSETS_KEY",
40        "saved_model.constants.ASSETS_KEY"]).export_constant(
41            __name__, "ASSETS_KEY")
42
43# CollectionDef key for the legacy init op.
44LEGACY_INIT_OP_KEY = "legacy_init_op"
45tf_export(
46    v1=[
47        "saved_model.LEGACY_INIT_OP_KEY",
48        "saved_model.constants.LEGACY_INIT_OP_KEY"
49    ]).export_constant(__name__, "LEGACY_INIT_OP_KEY")
50
51# CollectionDef key for the SavedModel main op.
52MAIN_OP_KEY = "saved_model_main_op"
53tf_export(
54    v1=["saved_model.MAIN_OP_KEY",
55        "saved_model.constants.MAIN_OP_KEY"]).export_constant(
56            __name__, "MAIN_OP_KEY")
57
58# CollectionDef key for the SavedModel train op.
59# Not exported while export_all_saved_models is experimental.
60TRAIN_OP_KEY = "saved_model_train_op"
61
62# Schema version for SavedModel.
63SAVED_MODEL_SCHEMA_VERSION = 1
64tf_export(
65    "saved_model.SAVED_MODEL_SCHEMA_VERSION",
66    v1=[
67        "saved_model.SAVED_MODEL_SCHEMA_VERSION",
68        "saved_model.constants.SAVED_MODEL_SCHEMA_VERSION"
69    ]).export_constant(__name__, "SAVED_MODEL_SCHEMA_VERSION")
70
71# File name for SavedModel protocol buffer.
72SAVED_MODEL_FILENAME_PB = "saved_model.pb"
73tf_export(
74    "saved_model.SAVED_MODEL_FILENAME_PB",
75    v1=[
76        "saved_model.SAVED_MODEL_FILENAME_PB",
77        "saved_model.constants.SAVED_MODEL_FILENAME_PB"
78    ]).export_constant(__name__, "SAVED_MODEL_FILENAME_PB")
79
80# File name for text version of SavedModel protocol buffer.
81SAVED_MODEL_FILENAME_PBTXT = "saved_model.pbtxt"
82tf_export(
83    "saved_model.SAVED_MODEL_FILENAME_PBTXT",
84    v1=[
85        "saved_model.SAVED_MODEL_FILENAME_PBTXT",
86        "saved_model.constants.SAVED_MODEL_FILENAME_PBTXT"
87    ]).export_constant(__name__, "SAVED_MODEL_FILENAME_PBTXT")
88
89# File name for json format of SavedModel.
90# Not exported while keras_saved_model is in contrib.
91SAVED_MODEL_FILENAME_JSON = "saved_model.json"
92
93# Subdirectory name containing the variables/checkpoint files.
94VARIABLES_DIRECTORY = "variables"
95tf_export(
96    "saved_model.VARIABLES_DIRECTORY",
97    v1=[
98        "saved_model.VARIABLES_DIRECTORY",
99        "saved_model.constants.VARIABLES_DIRECTORY"
100    ]).export_constant(__name__, "VARIABLES_DIRECTORY")
101
102# File name used for variables.
103VARIABLES_FILENAME = "variables"
104tf_export(
105    "saved_model.VARIABLES_FILENAME",
106    v1=[
107        "saved_model.VARIABLES_FILENAME",
108        "saved_model.constants.VARIABLES_FILENAME"
109    ]).export_constant(__name__, "VARIABLES_FILENAME")
110
111# The initialization and train ops for a MetaGraph are stored in the
112# signature def map. The ops are added to the map with the following keys.
113INIT_OP_SIGNATURE_KEY = "__saved_model_init_op"
114TRAIN_OP_SIGNATURE_KEY = "__saved_model_train_op"
115