| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -40,8 +40,6 @@ tf_cuda_library( | |||
| 40 | 40 | "//tensorflow/core:lib", | |
| 41 | 41 | "//tensorflow/core:lib_internal", | |
| 42 | 42 | "//tensorflow/core:protos_all_cc", | |
| 43 | - # TODO(b/74620627): move this here | ||
| 44 | - "//tensorflow/python:cpp_shape_inference_proto_cc", | ||
| 45 | 43 | ], | |
| 46 | 44 | }) + select({ | |
| 47 | 45 | "//tensorflow:with_xla_support": [ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -48,7 +48,6 @@ limitations under the License. | |||
| 48 | 48 | #include "tensorflow/core/platform/mutex.h" | |
| 49 | 49 | #include "tensorflow/core/platform/thread_annotations.h" | |
| 50 | 50 | #include "tensorflow/core/public/version.h" | |
| 51 | - #include "tensorflow/python/framework/cpp_shape_inference.pb.h" | ||
| 52 | 51 | ||
| 53 | 52 | using tensorflow::int64; | |
| 54 | 53 | using tensorflow::string; | |
@@ -503,62 +502,6 @@ void TFE_ContextExportRunMetadata(TFE_Context* ctx, TF_Buffer* buf, | |||
| 503 | 502 | ctx->context.RunMetadataProto()->Clear(); | |
| 504 | 503 | } | |
| 505 | 504 | ||
| 506 | - void TFE_GetResourceHandleShapeAndType(TF_Graph* graph, TF_Output output, | ||
| 507 | - TF_Buffer* output_proto, | ||
| 508 | - TF_Status* status) { | ||
| 509 | - tensorflow::Node* node = &output.oper->node; | ||
| 510 | - tensorflow::CppShapeInferenceResult::HandleData handle_data; | ||
| 511 | - handle_data.set_is_set(true); | ||
| 512 | - { | ||
| 513 | - tensorflow::mutex_lock l(graph->mu); | ||
| 514 | - tensorflow::shape_inference::InferenceContext* ic = | ||
| 515 | - graph->refiner.GetContext(node); | ||
| 516 | - CHECK(ic != nullptr); | ||
| 517 | - CHECK_LT(output.index, ic->num_outputs()); | ||
| 518 | - const auto* shapes_and_types = | ||
| 519 | - ic->output_handle_shapes_and_types(output.index); | ||
| 520 | - if (shapes_and_types == nullptr) { | ||
| 521 | - output_proto->data = nullptr; | ||
| 522 | - output_proto->length = 0; | ||
| 523 | - output_proto->data_deallocator = nullptr; | ||
| 524 | - return; | ||
| 525 | - } | ||
| 526 | - | ||
| 527 | - for (const auto& p : *shapes_and_types) { | ||
| 528 | - auto* out_shape_and_type = handle_data.add_shape_and_type(); | ||
| 529 | - ic->ShapeHandleToProto(p.shape, out_shape_and_type->mutable_shape()); | ||
| 530 | - out_shape_and_type->set_dtype(p.dtype); | ||
| 531 | - } | ||
| 532 | - } | ||
| 533 | - status->status = MessageToBuffer(handle_data, output_proto); | ||
| 534 | - } | ||
| 535 | - | ||
| 536 | - void TFE_SetResourceHandleShapeAndType(TF_Graph* graph, TF_Output output, | ||
| 537 | - const void* proto, size_t proto_len, | ||
| 538 | - TF_Status* status) { | ||
| 539 | - tensorflow::CppShapeInferenceResult::HandleData handle_data; | ||
| 540 | - if (!handle_data.ParseFromArray(proto, proto_len)) { | ||
| 541 | - status->status = tensorflow::errors::InvalidArgument( | ||
| 542 | - "Couldn't deserialize HandleData proto"); | ||
| 543 | - return; | ||
| 544 | - } | ||
| 545 | - DCHECK(handle_data.is_set()); | ||
| 546 | - | ||
| 547 | - tensorflow::mutex_lock l(graph->mu); | ||
| 548 | - tensorflow::shape_inference::InferenceContext* ic = | ||
| 549 | - graph->refiner.GetContext(&output.oper->node); | ||
| 550 | - | ||
| 551 | - std::vector<tensorflow::shape_inference::ShapeAndType> shapes_and_types; | ||
| 552 | - for (const auto& shape_and_type_proto : handle_data.shape_and_type()) { | ||
| 553 | - tensorflow::shape_inference::ShapeHandle shape; | ||
| 554 | - status->status = | ||
| 555 | - ic->MakeShapeFromShapeProto(shape_and_type_proto.shape(), &shape); | ||
| 556 | - if (status->status.ok()) return; | ||
| 557 | - shapes_and_types.emplace_back(shape, shape_and_type_proto.dtype()); | ||
| 558 | - } | ||
| 559 | - ic->set_output_handle_shapes_and_types(output.index, shapes_and_types); | ||
| 560 | - } | ||
| 561 | - | ||
| 562 | 505 | namespace { | |
| 563 | 506 | TFE_Op* GetFunc(TFE_Context* ctx, const tensorflow::NameAttrList& func, | |
| 564 | 507 | TF_Status* status) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -329,20 +329,6 @@ TF_CAPI_EXPORT extern void TFE_ContextExportRunMetadata(TFE_Context* ctx, | |||
| 329 | 329 | TF_Buffer* buf, | |
| 330 | 330 | TF_Status* status); | |
| 331 | 331 | ||
| 332 | - // Returns the serialized CppShapeInferenceResult::HandleData proto for | ||
| 333 | - // `output` if its a resource tensor, or otherwise returns an empty buffer. | ||
| 334 | - TF_CAPI_EXPORT extern void TFE_GetResourceHandleShapeAndType( | ||
| 335 | - TF_Graph* graph, TF_Output output, TF_Buffer* output_proto, | ||
| 336 | - TF_Status* status); | ||
| 337 | - | ||
| 338 | - // Sets `output` based on `proto`, which should be a serialized | ||
| 339 | - // CppShapeInferenceResult::HandleData proto. | ||
| 340 | - TF_CAPI_EXPORT extern void TFE_SetResourceHandleShapeAndType(TF_Graph* graph, | ||
| 341 | - TF_Output output, | ||
| 342 | - const void* proto, | ||
| 343 | - size_t proto_len, | ||
| 344 | - TF_Status* status); | ||
| 345 | - | ||
| 346 | 332 | #ifdef __cplusplus | |
| 347 | 333 | } /* end extern "C" */ | |
| 348 | 334 | #endif | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -110,7 +110,7 @@ void ExtendSession(TF_Session* session, TF_Status* status) { | |||
| 110 | 110 | session->extend_before_run = false; | |
| 111 | 111 | } | |
| 112 | 112 | ||
| 113 | - std::string ResourceHandleShapeAndType(TF_Graph* graph, TF_Output output) { | ||
| 113 | + std::string GetResourceHandleShapeAndType(TF_Graph* graph, TF_Output output) { | ||
| 114 | 114 | Node* node = &output.oper->node; | |
| 115 | 115 | CppShapeInferenceResult::HandleData handle_data; | |
| 116 | 116 | handle_data.set_is_set(true); | |
@@ -135,4 +135,30 @@ std::string ResourceHandleShapeAndType(TF_Graph* graph, TF_Output output) { | |||
| 135 | 135 | return result; | |
| 136 | 136 | } | |
| 137 | 137 | ||
| 138 | + void SetResourceHandleShapeAndType(TF_Graph* graph, TF_Output output, | ||
| 139 | + const void* proto, size_t proto_len, | ||
| 140 | + TF_Status* status) { | ||
| 141 | + tensorflow::CppShapeInferenceResult::HandleData handle_data; | ||
| 142 | + if (!handle_data.ParseFromArray(proto, proto_len)) { | ||
| 143 | + status->status = tensorflow::errors::InvalidArgument( | ||
| 144 | + "Couldn't deserialize HandleData proto"); | ||
| 145 | + return; | ||
| 146 | + } | ||
| 147 | + DCHECK(handle_data.is_set()); | ||
| 148 | + | ||
| 149 | + tensorflow::mutex_lock l(graph->mu); | ||
| 150 | + tensorflow::shape_inference::InferenceContext* ic = | ||
| 151 | + graph->refiner.GetContext(&output.oper->node); | ||
| 152 | + | ||
| 153 | + std::vector<tensorflow::shape_inference::ShapeAndType> shapes_and_types; | ||
| 154 | + for (const auto& shape_and_type_proto : handle_data.shape_and_type()) { | ||
| 155 | + tensorflow::shape_inference::ShapeHandle shape; | ||
| 156 | + status->status = | ||
| 157 | + ic->MakeShapeFromShapeProto(shape_and_type_proto.shape(), &shape); | ||
| 158 | + if (status->status.ok()) return; | ||
| 159 | + shapes_and_types.emplace_back(shape, shape_and_type_proto.dtype()); | ||
| 160 | + } | ||
| 161 | + ic->set_output_handle_shapes_and_types(output.index, shapes_and_types); | ||
| 162 | + } | ||
| 163 | + | ||
| 138 | 164 | } // namespace tensorflow | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,9 +55,15 @@ void ExtendSession(TF_Session* session, TF_Status* status); | |||
| 55 | 55 | ||
| 56 | 56 | // Returns the serialized CppShapeInferenceResult::HandleData proto for | |
| 57 | 57 | // `output` if its a resource tensor, or otherwise returns the empty string. | |
| 58 | - // TODO(b/74620627): remove when _USE_C_SHAPES is removed | ||
| 59 | - std::string ResourceHandleShapeAndType(TF_Graph* graph, TF_Output output); | ||
| 60 | - | ||
| 58 | + std::string GetResourceHandleShapeAndType(TF_Graph* graph, TF_Output output); | ||
| 59 | + | ||
| 60 | + // Sets `output` based on `proto`, which should be a serialized | ||
| 61 | + // CppShapeInferenceResult::HandleData proto. | ||
| 62 | + // NOTE(skyewm): `proto` is passed a void*/size_t pair instead of a std::string | ||
| 63 | + // because I couldn't get SWIG to work otherwise. | ||
| 64 | + void SetResourceHandleShapeAndType(TF_Graph* graph, TF_Output output, | ||
| 65 | + const void* proto, size_t proto_len, | ||
| 66 | + TF_Status* status); | ||
| 61 | 67 | } // namespace tensorflow | |
| 62 | 68 | ||
| 63 | 69 | #endif // TENSORFLOW_C_PYTHON_API_H_ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -88,9 +88,8 @@ Status CompileGraph(const GraphDef& graph_def, const tf2xla::Config& config, | |||
| 88 | 88 | // Converts the graph into an XLA computation, and compiles the | |
| 89 | 89 | // computation. | |
| 90 | 90 | // TODO(toddw): Should we let the user pick the XLA cpu vs. gpu client? | |
| 91 | - namespace gpu = perftools::gputools; | ||
| 92 | - gpu::Platform* cpu_platform = | ||
| 93 | - gpu::MultiPlatformManager::PlatformWithName("Host").ValueOrDie(); | ||
| 91 | + se::Platform* cpu_platform = | ||
| 92 | + se::MultiPlatformManager::PlatformWithName("Host").ValueOrDie(); | ||
| 94 | 93 | xla::CompileOnlyClient* client = | |
| 95 | 94 | xla::ClientLibrary::GetOrCreateCompileOnlyClient(cpu_platform) | |
| 96 | 95 | .ValueOrDie(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,6 +35,7 @@ limitations under the License. | |||
| 35 | 35 | // clang-format on | |
| 36 | 36 | ||
| 37 | 37 | #include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor" | |
| 38 | + #include "tensorflow/core/platform/byte_order.h" | ||
| 38 | 39 | #include "tensorflow/core/platform/cpu_info.h" | |
| 39 | 40 | #include "tensorflow/core/platform/test.h" | |
| 40 | 41 | #include "tensorflow/core/platform/test_benchmark.h" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -180,6 +180,7 @@ cc_library( | |||
| 180 | 180 | "//tensorflow/core/kernels:no_op", | |
| 181 | 181 | "//tensorflow/core/kernels:sendrecv_ops", | |
| 182 | 182 | "//tensorflow/core/kernels:variable_ops", | |
| 183 | + "@com_google_absl//absl/memory", | ||
| 183 | 184 | ], | |
| 184 | 185 | ) | |
| 185 | 186 | ||
@@ -256,19 +257,6 @@ cc_library( | |||
| 256 | 257 | alwayslink = 1, | |
| 257 | 258 | ) | |
| 258 | 259 | ||
| 259 | - cc_library( | ||
| 260 | - name = "graph_to_functiondef", | ||
| 261 | - srcs = ["graph_to_functiondef.cc"], | ||
| 262 | - hdrs = ["graph_to_functiondef.h"], | ||
| 263 | - visibility = [":friends"], | ||
| 264 | - deps = [ | ||
| 265 | - "//tensorflow/core:core_cpu", | ||
| 266 | - "//tensorflow/core:framework", | ||
| 267 | - "//tensorflow/core:lib", | ||
| 268 | - "//tensorflow/core:protos_all_cc", | ||
| 269 | - ], | ||
| 270 | - ) | ||
| 271 | - | ||
| 272 | 260 | cc_library( | |
| 273 | 261 | name = "create_xla_launch_op", | |
| 274 | 262 | srcs = [ | |
@@ -299,7 +287,6 @@ cc_library( | |||
| 299 | 287 | ], | |
| 300 | 288 | deps = [ | |
| 301 | 289 | ":common", | |
| 302 | - ":graph_to_functiondef", | ||
| 303 | 290 | ":shape_inference_helpers", | |
| 304 | 291 | ":union_find", | |
| 305 | 292 | "//tensorflow/compiler/jit/graphcycles", | |
@@ -346,28 +333,6 @@ tf_cc_test( | |||
| 346 | 333 | ], | |
| 347 | 334 | ) | |
| 348 | 335 | ||
| 349 | - tf_cc_test( | ||
| 350 | - name = "graph_to_functiondef_test", | ||
| 351 | - size = "small", | ||
| 352 | - srcs = [ | ||
| 353 | - "graph_to_functiondef_test.cc", | ||
| 354 | - ], | ||
| 355 | - deps = [ | ||
| 356 | - ":graph_to_functiondef", | ||
| 357 | - "//tensorflow/cc:cc_ops", | ||
| 358 | - "//tensorflow/cc:cc_ops_internal", | ||
| 359 | - "//tensorflow/cc:function_ops", | ||
| 360 | - "//tensorflow/cc:ops", | ||
| 361 | - "//tensorflow/compiler/tf2xla:xla_compiler", | ||
| 362 | - "//tensorflow/compiler/tf2xla/kernels:xla_ops", | ||
| 363 | - "//tensorflow/core:core_cpu", | ||
| 364 | - "//tensorflow/core:framework_internal", | ||
| 365 | - "//tensorflow/core:test", | ||
| 366 | - "//tensorflow/core:test_main", | ||
| 367 | - "//tensorflow/core:testlib", | ||
| 368 | - ], | ||
| 369 | - ) | ||
| 370 | - | ||
| 371 | 336 | tf_cc_test( | |
| 372 | 337 | name = "compilation_passes_test", | |
| 373 | 338 | size = "small", | |
@@ -378,7 +343,6 @@ tf_cc_test( | |||
| 378 | 343 | deps = [ | |
| 379 | 344 | ":common", | |
| 380 | 345 | ":compilation_passes", | |
| 381 | - ":graph_to_functiondef", | ||
| 382 | 346 | "//tensorflow/cc:cc_ops", | |
| 383 | 347 | "//tensorflow/cc:cc_ops_internal", | |
| 384 | 348 | "//tensorflow/cc:function_ops", | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,7 +22,6 @@ limitations under the License. | |||
| 22 | 22 | #include <unordered_map> | |
| 23 | 23 | #include <vector> | |
| 24 | 24 | ||
| 25 | - #include "tensorflow/compiler/jit/graph_to_functiondef.h" | ||
| 26 | 25 | #include "tensorflow/compiler/jit/graphcycles/graphcycles.h" | |
| 27 | 26 | #include "tensorflow/compiler/jit/legacy_flags/encapsulate_subgraphs_pass_flags.h" | |
| 28 | 27 | #include "tensorflow/compiler/jit/mark_for_compilation_pass.h" | |
@@ -35,6 +34,7 @@ limitations under the License. | |||
| 35 | 34 | #include "tensorflow/core/common_runtime/shape_refiner.h" | |
| 36 | 35 | #include "tensorflow/core/framework/function.h" | |
| 37 | 36 | #include "tensorflow/core/framework/graph_def_util.h" | |
| 37 | + #include "tensorflow/core/framework/graph_to_functiondef.h" | ||
| 38 | 38 | #include "tensorflow/core/framework/node_def_builder.h" | |
| 39 | 39 | #include "tensorflow/core/framework/node_def_util.h" | |
| 40 | 40 | #include "tensorflow/core/graph/algorithm.h" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,8 +20,8 @@ limitations under the License. | |||
| 20 | 20 | ||
| 21 | 21 | #include "tensorflow/cc/framework/ops.h" | |
| 22 | 22 | #include "tensorflow/cc/ops/standard_ops.h" | |
| 23 | - #include "tensorflow/compiler/jit/graph_to_functiondef.h" | ||
| 24 | 23 | #include "tensorflow/core/framework/function_testlib.h" | |
| 24 | + #include "tensorflow/core/framework/graph_to_functiondef.h" | ||
| 25 | 25 | #include "tensorflow/core/graph/graph_constructor.h" | |
| 26 | 26 | #include "tensorflow/core/graph/graph_def_builder.h" | |
| 27 | 27 | #include "tensorflow/core/lib/core/status_test_util.h" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments