1# Experimental extensions to the C API for eager execution of kernels. 2licenses(["notice"]) # Apache 2.0 3 4load( 5 "//tensorflow:tensorflow.bzl", 6 "tf_copts", 7 "tf_cuda_cc_test", 8 "tf_cuda_library", 9 "tfe_xla_copts", 10) 11load( 12 "//tensorflow/core:platform/default/build_config.bzl", 13 "tf_additional_device_tracer_test_flags", 14 "tf_kernel_tests_linkstatic", 15) 16load( 17 "//tensorflow/core:platform/default/build_config_root.bzl", 18 "tf_cuda_tests_tags", 19) 20 21tf_cuda_library( 22 name = "c_api", 23 srcs = [ 24 "c_api.cc", 25 "c_api_debug.cc", 26 "c_api_internal.h", 27 ], 28 hdrs = ["c_api.h"], 29 copts = tf_copts() + tfe_xla_copts(), 30 visibility = ["//visibility:public"], 31 deps = select({ 32 "//tensorflow:android": [ 33 "//tensorflow/core:android_tensorflow_lib_lite", 34 ], 35 "//conditions:default": [ 36 "//tensorflow/c:c_api", 37 "//tensorflow/c:c_api_internal", 38 "//tensorflow/core:core_cpu", 39 "//tensorflow/core/common_runtime/eager:attr_builder", 40 "//tensorflow/core/common_runtime/eager:context", 41 "//tensorflow/core/common_runtime/eager:eager_executor", 42 "//tensorflow/core/common_runtime/eager:execute", 43 "//tensorflow/core/common_runtime/eager:kernel_and_device", 44 "//tensorflow/core/common_runtime/eager:tensor_handle", 45 "//tensorflow/core/common_runtime/eager:copy_to_device_node", 46 "//tensorflow/core:core_cpu_internal", 47 "//tensorflow/core:framework", 48 "//tensorflow/core:framework_internal", 49 "//tensorflow/core:lib", 50 "//tensorflow/core:lib_internal", 51 "//tensorflow/core:protos_all_cc", 52 ], 53 }) + select({ 54 "//tensorflow:with_xla_support": [ 55 "//tensorflow/compiler/tf2xla:xla_compiler", 56 "//tensorflow/compiler/jit", 57 "//tensorflow/compiler/jit:xla_device", 58 ], 59 "//conditions:default": [], 60 }) + [ 61 "@com_google_absl//absl/memory", 62 "//tensorflow/core/common_runtime/eager:eager_operation", 63 "//tensorflow/core/distributed_runtime/eager:eager_client", 64 "//tensorflow/core/distributed_runtime/rpc/eager:grpc_eager_client", 65 "//tensorflow/core/distributed_runtime/rpc:grpc_channel", 66 "//tensorflow/core/distributed_runtime/rpc:grpc_server_lib", 67 "//tensorflow/core/distributed_runtime/rpc:grpc_worker_cache", 68 "//tensorflow/core/distributed_runtime/rpc:grpc_worker_service", 69 "//tensorflow/core/distributed_runtime/rpc:rpc_rendezvous_mgr", 70 "//tensorflow/core/distributed_runtime:remote_device", 71 "//tensorflow/core/distributed_runtime:server_lib", 72 "//tensorflow/core/distributed_runtime:worker_env", 73 "//tensorflow/core/profiler/lib:profiler_session", 74 "//tensorflow/core:gpu_runtime", 75 ], 76) 77 78tf_cuda_library( 79 name = "c_api_internal", 80 hdrs = ["c_api_internal.h"], 81 visibility = [ 82 "//learning/deepmind/courier:__subpackages__", 83 "//tensorflow:internal", 84 ], 85 deps = [ 86 ":c_api", 87 "//tensorflow/c:c_api", 88 "//tensorflow/c:c_api_internal", 89 "//tensorflow/core:core_cpu", 90 "//tensorflow/core:core_cpu_lib", 91 "//tensorflow/core:framework", 92 "//tensorflow/core:framework_internal", 93 "//tensorflow/core:framework_lite", 94 "//tensorflow/core:lib", 95 "//tensorflow/core:lib_internal", 96 "//tensorflow/core/common_runtime/eager:attr_builder", 97 "//tensorflow/core/common_runtime/eager:context", 98 "//tensorflow/core/common_runtime/eager:eager_executor", 99 "//tensorflow/core/common_runtime/eager:eager_operation", 100 "//tensorflow/core/common_runtime/eager:kernel_and_device", 101 "//tensorflow/core/common_runtime/eager:tensor_handle", 102 "//tensorflow/core/distributed_runtime:remote_device", 103 "//tensorflow/core/distributed_runtime:server_lib", 104 "//tensorflow/core/distributed_runtime:worker_env", 105 "//tensorflow/core/distributed_runtime/eager:eager_client", 106 "//tensorflow/core/distributed_runtime/eager:remote_tensor_handle", 107 "//tensorflow/core/distributed_runtime/rpc:grpc_channel", 108 "//tensorflow/core/distributed_runtime/rpc:grpc_server_lib", 109 "//tensorflow/core/distributed_runtime/rpc:grpc_worker_cache", 110 "//tensorflow/core/distributed_runtime/rpc:grpc_worker_service", 111 "//tensorflow/core/distributed_runtime/rpc:rpc_rendezvous_mgr", 112 "//tensorflow/core/distributed_runtime/rpc/eager:grpc_eager_client", 113 "//tensorflow/core/profiler/lib:profiler_session", 114 ], 115) 116 117tf_cuda_library( 118 name = "c_api_test_util", 119 testonly = 1, 120 srcs = ["c_api_test_util.cc"], 121 hdrs = ["c_api_test_util.h"], 122 visibility = [ 123 "//learning/brain:__subpackages__", 124 "//tensorflow:__subpackages__", 125 ], 126 deps = [ 127 ":c_api", 128 "//tensorflow/c:c_test_util", 129 "//tensorflow/core:framework", 130 "//tensorflow/core:lib", 131 "//tensorflow/core:protos_all_cc", 132 "//tensorflow/core:test", 133 ], 134) 135 136tf_cuda_cc_test( 137 name = "c_api_test", 138 size = "small", 139 srcs = [ 140 "c_api_debug_test.cc", 141 "c_api_test.cc", 142 ], 143 extra_copts = tfe_xla_copts(), 144 tags = [ 145 "guitar", 146 "multi_gpu", 147 ], 148 deps = [ 149 ":c_api", 150 ":c_api_internal", 151 ":c_api_test_util", 152 "//tensorflow/c:c_test_util", 153 "//tensorflow/core:lib", 154 "//tensorflow/core:protos_all_cc", 155 "//tensorflow/core:test", 156 "//tensorflow/core:test_main", 157 "//tensorflow/core/distributed_runtime/rpc:grpc_server_lib", 158 "@com_google_absl//absl/strings", 159 ], 160) 161 162tf_cuda_library( 163 name = "c_api_experimental", 164 srcs = [ 165 "c_api_experimental.cc", 166 ], 167 hdrs = ["c_api_experimental.h"], 168 copts = tf_copts() + tfe_xla_copts(), 169 visibility = ["//visibility:public"], 170 deps = select({ 171 "//tensorflow:android": [ 172 "//tensorflow/core:android_tensorflow_lib_lite", 173 ], 174 "//conditions:default": [ 175 ":c_api", 176 ":c_api_internal", 177 "//tensorflow/c:c_api", 178 "//tensorflow/c:c_api_internal", 179 "//tensorflow/core:core_cpu", 180 "//tensorflow/core/common_runtime/eager:attr_builder", 181 "//tensorflow/core/common_runtime/eager:context", 182 "//tensorflow/core/common_runtime/eager:eager_executor", 183 "//tensorflow/core/common_runtime/eager:execute", 184 "//tensorflow/core/common_runtime/eager:kernel_and_device", 185 "//tensorflow/core/common_runtime/eager:tensor_handle", 186 "//tensorflow/core/common_runtime/eager:copy_to_device_node", 187 "//tensorflow/core:core_cpu_internal", 188 "//tensorflow/core:framework", 189 "//tensorflow/core:framework_internal", 190 "//tensorflow/core:lib", 191 "//tensorflow/core:lib_internal", 192 "//tensorflow/core:protos_all_cc", 193 ], 194 }) + select({ 195 "//tensorflow:with_xla_support": [ 196 "//tensorflow/compiler/tf2xla:xla_compiler", 197 "//tensorflow/compiler/jit", 198 "//tensorflow/compiler/jit:xla_device", 199 ], 200 "//conditions:default": [], 201 }) + [ 202 "@com_google_absl//absl/memory", 203 "//tensorflow/core/common_runtime/eager:eager_operation", 204 "//tensorflow/core/distributed_runtime/eager:eager_client", 205 "//tensorflow/core/distributed_runtime/rpc/eager:grpc_eager_client", 206 "//tensorflow/core/distributed_runtime/rpc:grpc_channel", 207 "//tensorflow/core/distributed_runtime/rpc:grpc_server_lib", 208 "//tensorflow/core/distributed_runtime/rpc:grpc_worker_cache", 209 "//tensorflow/core/distributed_runtime/rpc:grpc_worker_service", 210 "//tensorflow/core/distributed_runtime/rpc:rpc_rendezvous_mgr", 211 "//tensorflow/core/distributed_runtime:remote_device", 212 "//tensorflow/core/distributed_runtime:server_lib", 213 "//tensorflow/core/distributed_runtime:worker_env", 214 "//tensorflow/core/profiler/rpc:profiler_server", 215 "//tensorflow/core/profiler/rpc/client:capture_profile", 216 "//tensorflow/core:gpu_runtime", 217 ], 218) 219 220tf_cuda_cc_test( 221 name = "c_api_experimental_test", 222 size = "small", 223 srcs = [ 224 "c_api_experimental_test.cc", 225 ], 226 args = 227 ["--heap_check=local"] + tf_additional_device_tracer_test_flags(), 228 linkstatic = tf_kernel_tests_linkstatic(), 229 tags = tf_cuda_tests_tags() + ["nomac"], 230 deps = [ 231 ":c_api_experimental", 232 ":c_api_test_util", 233 "//tensorflow/c:c_test_util", 234 "//tensorflow/cc/profiler", 235 "//tensorflow/core:lib", 236 "//tensorflow/core:protos_all_cc", 237 "//tensorflow/core:test", 238 "//tensorflow/core:test_main", 239 "//tensorflow/core/profiler:protos_all_cc", 240 "@com_google_absl//absl/strings", 241 ], 242) 243 244cc_library( 245 name = "tape", 246 hdrs = ["tape.h"], 247 visibility = ["//tensorflow:internal"], 248 deps = [ 249 "//tensorflow/core:framework", 250 "//tensorflow/core:lib", 251 ], 252) 253 254filegroup( 255 name = "headers", 256 srcs = ["c_api.h"], 257 visibility = ["//tensorflow:__subpackages__"], 258) 259