1 # Description: 2 # TensorFlow Debugger (tfdbg). 3 # 4 # Public target(s): 5 # 6 # ":debug" - Depending on this target causes a concrete implementation of 7 # DebuggerState to be constructed at initialization time, enabling 8 # TensorFlow Debugger (tfdbg) support. For details, please see 9 # core/common_runtime/debugger_state_interface.h. 10 # ":debug_callback_registry" - Depending on this target exposes a global 11 # callback registry that will be used to record any observed tensors matching 12 # a watch state. 13 # ":debug_node_key" - Defines a struct used for tracking tensors. 14 15 package( 16 default_visibility = ["//tensorflow:internal"], 17 ) 18 19 licenses(["notice"]) # Apache 2.0 20 21 load( 22 "//tensorflow:tensorflow.bzl", 23 "check_deps", 24 "tf_copts", 25 "tf_cc_test", 26 "tf_cuda_library", 27 ) 28 29 # For platform specific build config 30 load( 31 "//tensorflow/core:platform/default/build_config.bzl", 32 "tf_kernel_tests_linkstatic", 33 "tf_proto_library", 34 "tf_proto_library_cc", 35 "tf_additional_all_protos", 36 ) 37 load( 38 "//tensorflow/core:platform/default/build_config_root.bzl", 39 "tf_cuda_tests_tags", 40 ) 41 42 # Check that tensorflow/core:tensorflow does not depend on grpc. 43 check_deps( 44 name = "core_tensorflow_check_deps", 45 disallowed_deps = ["@grpc//:grpc++_unsecure"], 46 deps = ["//tensorflow/core:tensorflow"], 47 ) 48 49 tf_proto_library( 50 name = "debug_service_proto", 51 srcs = [ 52 "debug_service.proto", 53 ], 54 has_services = 1, 55 cc_api_version = 2, 56 cc_grpc_version = 1, 57 protodeps = [ 58 ":debugger_event_metadata_proto", 59 "//tensorflow/core/profiler:protos_all", 60 ] + tf_additional_all_protos(), 61 visibility = ["//tensorflow:__subpackages__"], 62 ) 63 64 tf_proto_library( 65 name = "debugger_event_metadata_proto", 66 srcs = ["debugger_event_metadata.proto"], 67 cc_api_version = 2, 68 ) 69 70 cc_library( 71 name = "debug", 72 srcs = ["debug.cc"], 73 copts = tf_copts(), 74 linkstatic = 1, 75 visibility = ["//visibility:public"], 76 deps = [ 77 ":debugger_state_impl", 78 "//tensorflow/core:core_cpu_internal", 79 "//tensorflow/core:debug_ops_op_lib", 80 ], 81 alwayslink = 1, 82 ) 83 84 tf_cuda_library( 85 name = "debug_gateway_internal", 86 srcs = ["debug_gateway.cc"], 87 hdrs = ["debug_gateway.h"], 88 copts = tf_copts(), 89 linkstatic = 1, 90 deps = [ 91 ":debug", 92 "//tensorflow/core:core_cpu_internal", 93 "//tensorflow/core:device_tracer", 94 "//tensorflow/core:direct_session_internal", 95 "//tensorflow/core:framework", 96 "//tensorflow/core:lib", 97 "//tensorflow/core:lib_internal", 98 "//tensorflow/core:proto_text", 99 "//tensorflow/core:protos_all_cc", 100 ], 101 alwayslink = 1, 102 ) 103 104 tf_cuda_library( 105 name = "debugger_state_impl", 106 srcs = ["debugger_state_impl.cc"], 107 hdrs = ["debugger_state_impl.h"], 108 copts = tf_copts(), 109 linkstatic = 1, 110 deps = [ 111 ":debug_graph_utils", 112 ":debug_io_utils", 113 "//tensorflow/core:core_cpu_internal", 114 ], 115 alwayslink = 1, 116 ) 117 118 tf_cuda_library( 119 name = "debug_graph_utils", 120 srcs = ["debug_graph_utils.cc"], 121 hdrs = ["debug_graph_utils.h"], 122 copts = tf_copts(), 123 linkstatic = 1, 124 deps = [ 125 "//tensorflow/core:core_cpu_internal", 126 "//tensorflow/core:framework", 127 "//tensorflow/core:graph", 128 "//tensorflow/core:lib", 129 "//tensorflow/core:lib_internal", 130 "//tensorflow/core:proto_text", 131 "//tensorflow/core:protos_all_cc", 132 ], 133 alwayslink = 1, 134 ) 135 136 tf_cuda_library( 137 name = "debug_io_utils", 138 srcs = ["debug_io_utils.cc"], 139 hdrs = ["debug_io_utils.h"], 140 copts = tf_copts(), 141 linkstatic = 1, 142 deps = [ 143 ":debug_callback_registry", 144 ":debug_node_key", 145 ":debug_service_proto_cc", 146 ":debugger_event_metadata_proto_cc", 147 "//tensorflow/core:core_cpu_internal", 148 "//tensorflow/core:framework", 149 "//tensorflow/core:graph", 150 "//tensorflow/core:lib", 151 "//tensorflow/core:lib_internal", 152 "//tensorflow/core:proto_text", 153 "//tensorflow/core:protos_all_cc", 154 "@grpc//:grpc++_unsecure", 155 ], 156 alwayslink = 1, 157 ) 158 159 tf_cuda_library( 160 name = "debug_grpc_testlib", 161 srcs = ["debug_grpc_testlib.cc"], 162 hdrs = ["debug_grpc_testlib.h"], 163 copts = tf_copts(), 164 linkstatic = 1, 165 deps = [ 166 ":debug_graph_utils", 167 ":debug_io_utils", 168 ":debug_service_proto_cc", 169 ":debugger_event_metadata_proto_cc", 170 "//tensorflow/core:framework", 171 "//tensorflow/core:lib", 172 "//tensorflow/core:lib_internal", 173 "//tensorflow/core:protos_all_cc", 174 "@grpc//:grpc++_unsecure", 175 ], 176 alwayslink = 1, 177 ) 178 179 tf_cuda_library( 180 name = "debug_node_key", 181 srcs = ["debug_node_key.cc"], 182 hdrs = ["debug_node_key.h"], 183 copts = tf_copts(), 184 linkstatic = 1, 185 visibility = ["//visibility:public"], 186 deps = [ 187 "//tensorflow/core:lib", 188 ], 189 ) 190 191 # TODO(cais): Fix flakiness on GPU and change this back to a tf_cc_test_gpu. 192 # See b/34081273. 193 tf_cc_test( 194 name = "debug_gateway_test", 195 size = "small", 196 srcs = ["debug_gateway_test.cc"], 197 args = ["--heap_check=local"], 198 linkstatic = tf_kernel_tests_linkstatic(), 199 tags = [ 200 "no_cuda_on_cpu_tap", 201 "no_gpu", 202 ], 203 deps = [ 204 ":debug", 205 ":debug_gateway_internal", 206 ":debug_graph_utils", 207 "//tensorflow/cc:cc_ops", 208 "//tensorflow/core:all_kernels", 209 "//tensorflow/core:core_cpu", 210 "//tensorflow/core:core_cpu_internal", 211 "//tensorflow/core:direct_session", 212 "//tensorflow/core:direct_session_internal", 213 "//tensorflow/core:framework", 214 "//tensorflow/core:framework_internal", 215 "//tensorflow/core:gpu_runtime", 216 "//tensorflow/core:lib", 217 "//tensorflow/core:lib_internal", 218 "//tensorflow/core:protos_all_cc", 219 "//tensorflow/core:test", 220 "//tensorflow/core:test_main", 221 "//tensorflow/core:testlib", 222 "//tensorflow/core/kernels:debug_ops", 223 "//tensorflow/core/kernels:ops_util", 224 ], 225 ) 226 227 tf_cc_test( 228 name = "debug_io_utils_test", 229 size = "small", 230 srcs = ["debug_io_utils_test.cc"], 231 linkstatic = tf_kernel_tests_linkstatic(), 232 deps = [ 233 ":debug_callback_registry", 234 ":debug_grpc_testlib", 235 ":debug_io_utils", 236 ":debug_node_key", 237 ":debug_service_proto_cc", 238 ":debugger_event_metadata_proto_cc", 239 "//tensorflow/core:core_cpu", 240 "//tensorflow/core:core_cpu_internal", 241 "//tensorflow/core:framework", 242 "//tensorflow/core:framework_internal", 243 "//tensorflow/core:lib", 244 "//tensorflow/core:lib_internal", 245 "//tensorflow/core:protos_all_cc", 246 "//tensorflow/core:test", 247 "//tensorflow/core:test_main", 248 "//tensorflow/core:testlib", 249 "//tensorflow/core/platform/default/build_config:platformlib", 250 ], 251 ) 252 253 tf_cc_test( 254 name = "debug_graph_utils_test", 255 size = "small", 256 srcs = ["debug_graph_utils_test.cc"], 257 linkstatic = tf_kernel_tests_linkstatic(), 258 deps = [ 259 ":debug_graph_utils", 260 "//tensorflow/core:lib", 261 "//tensorflow/core:lib_internal", 262 "//tensorflow/core:test", 263 "//tensorflow/core:test_main", 264 "//tensorflow/core:testlib", 265 ], 266 ) 267 268 tf_cc_test( 269 name = "grpc_session_debug_test", 270 size = "medium", 271 srcs = ["grpc_session_debug_test.cc"], 272 linkstatic = tf_kernel_tests_linkstatic(), 273 tags = [ 274 "no_oss", # b/62956105: port conflicts. 275 "nomac", # b/38276817 276 ], 277 deps = [ 278 ":debug_grpc_testlib", 279 ":debug_io_utils", 280 "//tensorflow/core:core_cpu", 281 "//tensorflow/core:framework", 282 "//tensorflow/core:lib", 283 "//tensorflow/core:master_proto_cc", 284 "//tensorflow/core:protos_all_cc", 285 "//tensorflow/core:test", 286 "//tensorflow/core:test_main", 287 "//tensorflow/core:testlib", 288 "//tensorflow/core/distributed_runtime/rpc:grpc_server_lib", 289 "//tensorflow/core/distributed_runtime/rpc:grpc_session", 290 "//tensorflow/core/distributed_runtime/rpc:grpc_testlib", 291 "//tensorflow/core/kernels:constant_op", 292 "//tensorflow/core/kernels:matmul_op", 293 ], 294 ) 295 296 tf_cc_test( 297 name = "debug_grpc_io_utils_test", 298 size = "small", 299 srcs = ["debug_grpc_io_utils_test.cc"], 300 linkstatic = tf_kernel_tests_linkstatic(), 301 deps = [ 302 ":debug_graph_utils", 303 ":debug_grpc_testlib", 304 ":debug_io_utils", 305 "//tensorflow/core:core_cpu_internal", 306 "//tensorflow/core:framework_internal", 307 "//tensorflow/core:lib", 308 "//tensorflow/core:lib_internal", 309 "//tensorflow/core:protos_all_cc", 310 "//tensorflow/core:test", 311 "//tensorflow/core:test_main", 312 ], 313 ) 314 315 cc_library( 316 name = "debug_callback_registry", 317 srcs = ["debug_callback_registry.cc"], 318 hdrs = ["debug_callback_registry.h"], 319 visibility = ["//visibility:public"], 320 deps = [ 321 ":debug_node_key", 322 "//tensorflow/core:framework", 323 "//tensorflow/core:lib", 324 "//tensorflow/core:protos_all_cc", 325 ], 326 ) 327 328 # TODO(cais): Add the following back in when tfdbg is supported on Android. 329 # filegroup( 330 # name = "android_srcs", 331 # srcs = [ 332 # "debug_graph_utils.cc", 333 # "debug_graph_utils.h", 334 # "debug_io_utils.cc", 335 # "debug_io_utils.h", 336 # ], 337 # visibility = ["//visibility:public"], 338 # ) 339 340 # ----------------------------------------------------------------------------- 341 # Google-internal targets. These must be at the end for syncrepo. 342 343 filegroup( 344 name = "all_files", 345 srcs = glob( 346 ["**/*"], 347 exclude = [ 348 "**/METADATA", 349 "**/OWNERS", 350 ], 351 ), 352 visibility = ["//tensorflow:__subpackages__"], 353 ) 354