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# Subdirectory where debugging related files are written. 90DEBUG_DIRECTORY = "debug" 91tf_export( 92 "saved_model.DEBUG_DIRECTORY", 93 v1=[ 94 "saved_model.DEBUG_DIRECTORY", 95 "saved_model.constants.DEBUG_DIRECTORY", 96 ]).export_constant(__name__, "DEBUG_DIRECTORY") 97 98# File name for GraphDebugInfo protocol buffer which corresponds to the 99# SavedModel. 100DEBUG_INFO_FILENAME_PB = "saved_model_debug_info.pb" 101tf_export( 102 "saved_model.DEBUG_INFO_FILENAME_PB", 103 v1=[ 104 "saved_model.DEBUG_INFO_FILENAME_PB", 105 "saved_model.constants.DEBUG_INFO_FILENAME_PB" 106 ]).export_constant(__name__, "DEBUG_INFO_FILENAME_PB") 107 108# File name for json format of SavedModel. 109# Not exported while keras_saved_model is in contrib. 110SAVED_MODEL_FILENAME_JSON = "saved_model.json" 111 112# Subdirectory name containing the variables/checkpoint files. 113VARIABLES_DIRECTORY = "variables" 114tf_export( 115 "saved_model.VARIABLES_DIRECTORY", 116 v1=[ 117 "saved_model.VARIABLES_DIRECTORY", 118 "saved_model.constants.VARIABLES_DIRECTORY" 119 ]).export_constant(__name__, "VARIABLES_DIRECTORY") 120 121# File name used for variables. 122VARIABLES_FILENAME = "variables" 123tf_export( 124 "saved_model.VARIABLES_FILENAME", 125 v1=[ 126 "saved_model.VARIABLES_FILENAME", 127 "saved_model.constants.VARIABLES_FILENAME" 128 ]).export_constant(__name__, "VARIABLES_FILENAME") 129 130# The initialization and train ops for a MetaGraph are stored in the 131# signature def map. The ops are added to the map with the following keys. 132INIT_OP_SIGNATURE_KEY = "__saved_model_init_op" 133TRAIN_OP_SIGNATURE_KEY = "__saved_model_train_op" 134