1# Experimental Implementation of SavedModel C APIs for TensorFlow. See RFC 2# https://github.com/tensorflow/community/pull/207 3# External clients should not worry about this directory; all contents are implementation details. 4# Code in this directory is intended to form the glue between the C API and the internal C++ 5# implementation by 6# 1. mapping C API calls onto correponding methods of C++ objects 7# 2. mapping opaque C types onto C++ classes 8 9# Note(bmzhao): The *.cc files in this directory form the direct implementation of the 10# C API functions exposed in tf/c/experimental/saved_model/public/. 11 12load("//tensorflow/core/platform:rules_cc.bzl", "cc_library") 13 14# Note(bmzhao): All *type.h files in this directory are the internal definitions of 15# the opaque C types. These headers should only be visible to internal tensorflow 16# implementors. 17load( 18 "//tensorflow:tensorflow.bzl", 19 "tf_cc_test", 20 "tf_copts", 21) 22 23package( 24 licenses = ["notice"], # Apache 2.0 25) 26 27cc_library( 28 name = "concrete_function", 29 srcs = [ 30 "concrete_function.cc", 31 ], 32 hdrs = [ 33 "//tensorflow/c/experimental/saved_model/public:concrete_function.h", 34 ], 35 copts = tf_copts(), 36 visibility = [ 37 "//tensorflow/c/experimental/saved_model/public:__pkg__", 38 ], 39 deps = [ 40 ":concrete_function_type", 41 ":function_metadata", 42 ":function_metadata_type", 43 "//tensorflow/c:c_api_macros", 44 "//tensorflow/c:tf_status_internal", 45 "//tensorflow/c/eager:abstract_tensor_handle", 46 "//tensorflow/c/eager:c_api", 47 "//tensorflow/c/eager:immediate_execution_operation", 48 "//tensorflow/c/eager:tfe_op_internal", 49 "//tensorflow/c/eager:tfe_tensorhandle_internal", 50 "//tensorflow/c/experimental/saved_model/core:concrete_function", 51 "//tensorflow/c/experimental/saved_model/core:function_metadata", 52 "//tensorflow/core:lib", 53 "@com_google_absl//absl/types:span", 54 ], 55) 56 57cc_library( 58 name = "concrete_function_list", 59 srcs = [ 60 "concrete_function_list.cc", 61 ], 62 hdrs = [ 63 "//tensorflow/c/experimental/saved_model/public:concrete_function_list.h", 64 ], 65 copts = tf_copts(), 66 visibility = [ 67 "//tensorflow/c/experimental/saved_model/public:__pkg__", 68 ], 69 deps = [ 70 ":concrete_function", 71 ":concrete_function_list_type", 72 ":concrete_function_type", 73 "//tensorflow/c:c_api_macros", 74 "//tensorflow/c/experimental/saved_model/core:concrete_function", 75 ], 76) 77 78cc_library( 79 name = "concrete_function_list_type", 80 hdrs = [ 81 "concrete_function_list_type.h", 82 ], 83 deps = [ 84 "//tensorflow/c/experimental/saved_model/core:concrete_function", 85 ], 86) 87 88cc_library( 89 name = "concrete_function_type", 90 hdrs = [ 91 "concrete_function_type.h", 92 ], 93 deps = [ 94 "//tensorflow/c:conversion_macros", 95 "//tensorflow/c/experimental/saved_model/core:concrete_function", 96 ], 97) 98 99cc_library( 100 name = "function_metadata", 101 srcs = [ 102 "function_metadata.cc", 103 ], 104 hdrs = [ 105 "//tensorflow/c/experimental/saved_model/public:function_metadata.h", 106 ], 107 copts = tf_copts(), 108 visibility = [ 109 "//tensorflow/c/experimental/saved_model/public:__pkg__", 110 ], 111 deps = [ 112 ":function_metadata_type", 113 "//tensorflow/c:c_api_macros", 114 "//tensorflow/c/experimental/saved_model/core:function_metadata", 115 ], 116) 117 118cc_library( 119 name = "function_metadata_type", 120 hdrs = [ 121 "function_metadata_type.h", 122 ], 123 deps = [ 124 "//tensorflow/c:conversion_macros", 125 "//tensorflow/c/experimental/saved_model/core:function_metadata", 126 ], 127) 128 129cc_library( 130 name = "saved_model_api", 131 srcs = [ 132 "saved_model_api.cc", 133 ], 134 hdrs = [ 135 "//tensorflow/c/experimental/saved_model/public:saved_model_api.h", 136 ], 137 copts = tf_copts(), 138 visibility = [ 139 "//tensorflow/c/experimental/saved_model/public:__pkg__", 140 ], 141 deps = [ 142 ":concrete_function", 143 ":concrete_function_list", 144 ":concrete_function_list_type", 145 ":concrete_function_type", 146 ":saved_model_api_type", 147 ":signature_def_function", 148 ":signature_def_function_type", 149 "//tensorflow/c:c_api_macros", 150 "//tensorflow/c:tf_status", 151 "//tensorflow/c:tf_status_internal", 152 "//tensorflow/c/eager:tfe_context_internal", 153 "//tensorflow/c/experimental/saved_model/core:saved_model_api", 154 "//tensorflow/c/experimental/saved_model/core:tf_saved_model_api", 155 "//tensorflow/core:lib", 156 "//tensorflow/core/common_runtime/eager:context", 157 "@com_google_absl//absl/types:optional", 158 ], 159) 160 161cc_library( 162 name = "saved_model_api_type", 163 hdrs = [ 164 "saved_model_api_type.h", 165 ], 166 deps = [ 167 "//tensorflow/c:conversion_macros", 168 "//tensorflow/c/experimental/saved_model/core:saved_model_api", 169 ], 170) 171 172cc_library( 173 name = "signature_def_function", 174 srcs = [ 175 "signature_def_function.cc", 176 ], 177 hdrs = [ 178 "//tensorflow/c/experimental/saved_model/public:signature_def_function.h", 179 ], 180 copts = tf_copts(), 181 visibility = [ 182 "//tensorflow/c/experimental/saved_model/public:__pkg__", 183 ], 184 deps = [ 185 ":signature_def_function_metadata", 186 ":signature_def_function_metadata_type", 187 ":signature_def_function_type", 188 "//tensorflow/c:c_api_macros", 189 "//tensorflow/c:tf_status_internal", 190 "//tensorflow/c/eager:abstract_tensor_handle", 191 "//tensorflow/c/eager:c_api", 192 "//tensorflow/c/eager:immediate_execution_operation", 193 "//tensorflow/c/eager:tfe_op_internal", 194 "//tensorflow/c/eager:tfe_tensorhandle_internal", 195 "//tensorflow/c/experimental/saved_model/core:signature_def_function", 196 "//tensorflow/c/experimental/saved_model/core:signature_def_function_metadata", 197 "//tensorflow/core:lib", 198 "@com_google_absl//absl/types:span", 199 ], 200) 201 202cc_library( 203 name = "signature_def_function_type", 204 hdrs = [ 205 "signature_def_function_type.h", 206 ], 207 deps = [ 208 "//tensorflow/c:conversion_macros", 209 "//tensorflow/c/experimental/saved_model/core:signature_def_function", 210 ], 211) 212 213cc_library( 214 name = "signature_def_function_metadata", 215 srcs = [ 216 "signature_def_function_metadata.cc", 217 ], 218 hdrs = [ 219 "//tensorflow/c/experimental/saved_model/public:signature_def_function_metadata.h", 220 ], 221 copts = tf_copts(), 222 visibility = [ 223 "//tensorflow/c/experimental/saved_model/public:__pkg__", 224 ], 225 deps = [ 226 ":signature_def_function_metadata_type", 227 ":signature_def_param_list", 228 ":signature_def_param_list_type", 229 "//tensorflow/c:c_api_macros", 230 "//tensorflow/c/experimental/saved_model/core:signature_def_function_metadata", 231 ], 232) 233 234cc_library( 235 name = "signature_def_function_metadata_type", 236 hdrs = [ 237 "signature_def_function_metadata_type.h", 238 ], 239 deps = [ 240 "//tensorflow/c:conversion_macros", 241 "//tensorflow/c/experimental/saved_model/core:signature_def_function_metadata", 242 ], 243) 244 245cc_library( 246 name = "signature_def_param", 247 srcs = [ 248 "signature_def_param.cc", 249 ], 250 hdrs = [ 251 "//tensorflow/c/experimental/saved_model/public:signature_def_param.h", 252 ], 253 copts = tf_copts(), 254 visibility = [ 255 "//tensorflow/c/experimental/saved_model/public:__pkg__", 256 ], 257 deps = [ 258 ":signature_def_param_type", 259 ":tensor_spec", 260 ":tensor_spec_type", 261 "//tensorflow/c:c_api_macros", 262 "//tensorflow/c:tf_shape_internal", 263 "//tensorflow/c/experimental/saved_model/core:signature_def_function_metadata", 264 ], 265) 266 267cc_library( 268 name = "signature_def_param_type", 269 hdrs = [ 270 "signature_def_param_type.h", 271 ], 272 deps = [ 273 "//tensorflow/c:conversion_macros", 274 "//tensorflow/c/experimental/saved_model/core:signature_def_function_metadata", 275 ], 276) 277 278cc_library( 279 name = "signature_def_param_list", 280 srcs = [ 281 "signature_def_param_list.cc", 282 ], 283 hdrs = [ 284 "//tensorflow/c/experimental/saved_model/public:signature_def_param_list.h", 285 ], 286 copts = tf_copts(), 287 visibility = [ 288 "//tensorflow/c/experimental/saved_model/public:__pkg__", 289 ], 290 deps = [ 291 ":signature_def_param", 292 ":signature_def_param_list_type", 293 ":signature_def_param_type", 294 "//tensorflow/c:c_api_macros", 295 ], 296) 297 298cc_library( 299 name = "signature_def_param_list_type", 300 hdrs = [ 301 "signature_def_param_list_type.h", 302 ], 303 deps = [ 304 "//tensorflow/c:conversion_macros", 305 "//tensorflow/c/experimental/saved_model/core:signature_def_function_metadata", 306 ], 307) 308 309cc_library( 310 name = "tensor_spec", 311 srcs = [ 312 "tensor_spec.cc", 313 ], 314 hdrs = [ 315 "//tensorflow/c/experimental/saved_model/public:tensor_spec.h", 316 ], 317 copts = tf_copts(), 318 visibility = [ 319 "//tensorflow/c/experimental/saved_model/public:__pkg__", 320 ], 321 deps = [ 322 ":tensor_spec_type", 323 "//tensorflow/c:c_api_macros", 324 "//tensorflow/c:tf_datatype", 325 "//tensorflow/c:tf_shape", 326 "//tensorflow/c:tf_shape_internal", 327 "//tensorflow/c/experimental/saved_model/core:tensor_spec", 328 ], 329) 330 331cc_library( 332 name = "tensor_spec_type", 333 hdrs = [ 334 "tensor_spec_type.h", 335 ], 336 deps = [ 337 "//tensorflow/c:conversion_macros", 338 "//tensorflow/c:tf_shape_internal", 339 "//tensorflow/c/experimental/saved_model/core:tensor_spec", 340 ], 341) 342 343tf_cc_test( 344 name = "saved_model_api_test", 345 size = "small", 346 srcs = [ 347 "saved_model_api_test.cc", 348 ], 349 data = [ 350 "//tensorflow/c/experimental/saved_model/internal/testdata:saved_models", 351 "//tensorflow/cc/saved_model:saved_model_half_plus_two", 352 ], 353 deps = [ 354 ":saved_model_api_type", 355 "//tensorflow/c:tf_datatype", 356 "//tensorflow/c:tf_shape", 357 "//tensorflow/c:tf_status", 358 "//tensorflow/c:tf_tensor", 359 "//tensorflow/c/eager:c_api", 360 "//tensorflow/c/eager:c_api_experimental", 361 "//tensorflow/c/eager:c_api_test_util", 362 "//tensorflow/c/experimental/saved_model/core:tf_saved_model_api", 363 "//tensorflow/c/experimental/saved_model/public:concrete_function", 364 "//tensorflow/c/experimental/saved_model/public:saved_model_api", 365 "//tensorflow/c/experimental/saved_model/public:signature_def_function", 366 "//tensorflow/c/experimental/saved_model/public:signature_def_function_metadata", 367 "//tensorflow/c/experimental/saved_model/public:signature_def_param", 368 "//tensorflow/c/experimental/saved_model/public:signature_def_param_list", 369 "//tensorflow/c/experimental/saved_model/public:tensor_spec", 370 "//tensorflow/core:lib", 371 "//tensorflow/core:test", 372 "//tensorflow/core:test_main", 373 ], 374) 375