Skip to content

Commit

Permalink
Prepare to remove a bunch of proto.h includes from tensorflow/core he…
Browse files Browse the repository at this point in the history
…aders

The goal is to make kernels mostly independent of proto headers, which will let
us lock down our .so imports.  This CL does not remove any actual headers, but
changes a bunch of files so that header removal is possible in a followup CL.
It also marks the headers that will be removed with

    // TODO(b/62899350): Remove

RELNOTES: n/a
PiperOrigin-RevId: 160552878
  • Loading branch information
girving authored and tensorflower-gardener committed Jun 29, 2017
1 parent 9b11f45 commit e85d3df
Show file tree
Hide file tree
Showing 150 changed files with 555 additions and 240 deletions.
1 change: 1 addition & 0 deletions tensorflow/c/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ tf_cuda_library(
"//tensorflow/cc:scope_internal",
"//tensorflow/core:core_cpu",
"//tensorflow/core:framework",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:lib",
],
}),
Expand Down
11 changes: 11 additions & 0 deletions tensorflow/c/c_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ limitations under the License.
#endif
#include "tensorflow/c/c_api_internal.h"
#include "tensorflow/core/common_runtime/shape_refiner.h"
#include "tensorflow/core/framework/allocation_description.pb.h"
#include "tensorflow/core/framework/log_memory.h"
#include "tensorflow/core/framework/node_def_util.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/partial_tensor_shape.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tensor_shape.h"
#include "tensorflow/core/framework/tensor_shape.pb.h"
#include "tensorflow/core/framework/versions.pb.h"
#include "tensorflow/core/graph/graph.h"
#include "tensorflow/core/graph/graph_constructor.h"
#include "tensorflow/core/graph/node_builder.h"
Expand Down Expand Up @@ -1587,6 +1590,14 @@ void TF_OperationToNodeDef(TF_Operation* oper, TF_Buffer* output_node_def,

// TF_Graph functions ---------------------------------------------------------

TF_Graph::TF_Graph()
: graph(tensorflow::OpRegistry::Global()),
refiner(graph.versions().producer(), graph.op_registry()),
num_sessions(0),
delete_requested(false),
parent(nullptr),
parent_inputs(nullptr) {}

TF_Graph* TF_NewGraph() { return new TF_Graph; }

void TF_DeleteGraph(TF_Graph* g) {
Expand Down
9 changes: 2 additions & 7 deletions tensorflow/c/c_api_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,8 @@ struct TF_Library {
};

struct TF_Graph {
TF_Graph()
: graph(tensorflow::OpRegistry::Global()),
refiner(graph.versions().producer(), graph.op_registry()),
num_sessions(0),
delete_requested(false),
parent(nullptr),
parent_inputs(nullptr) {}
TF_Graph();

tensorflow::mutex mu;
tensorflow::Graph graph GUARDED_BY(mu);

Expand Down
1 change: 1 addition & 0 deletions tensorflow/c/c_api_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ limitations under the License.
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/partial_tensor_shape.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tensor.pb.h"
#include "tensorflow/core/framework/tensor_shape.pb.h"
#include "tensorflow/core/framework/types.pb.h"
#include "tensorflow/core/graph/tensor_id.h"
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/cc/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ tf_cc_test(
"//tensorflow/core:all_kernels",
"//tensorflow/core:framework",
"//tensorflow/core:framework_internal",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
"//tensorflow/core:testlib",
Expand Down Expand Up @@ -432,6 +433,7 @@ cc_library_with_android_deps(
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:op_gen_lib",
"//tensorflow/core:op_gen_overrides_proto_cc",
"//tensorflow/core:proto_text",
"//tensorflow/core:protos_all_cc",
],
Expand Down
4 changes: 4 additions & 0 deletions tensorflow/cc/framework/cc_op_gen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ limitations under the License.
#include <vector>

#include "tensorflow/cc/framework/cc_op_gen.h"
#include "tensorflow/core/framework/attr_value.pb.h"
#include "tensorflow/core/framework/attr_value_util.h"
#include "tensorflow/core/framework/op_gen_lib.h"
#include "tensorflow/core/framework/op_gen_overrides.pb.h"
#include "tensorflow/core/framework/tensor.pb.h"
#include "tensorflow/core/framework/tensor_shape.pb.h"
#include "tensorflow/core/framework/types.pb_text.h"
#include "tensorflow/core/lib/gtl/map_util.h"
#include "tensorflow/core/lib/gtl/stl_util.h"
Expand Down
1 change: 1 addition & 0 deletions tensorflow/cc/framework/gradients_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
#include "tensorflow/cc/framework/grad_op_registry.h"
#include "tensorflow/cc/framework/testutil.h"
#include "tensorflow/cc/ops/standard_ops.h"
#include "tensorflow/core/framework/graph.pb.h"
#include "tensorflow/core/framework/node_def_util.h"
#include "tensorflow/core/framework/tensor_testutil.h"
#include "tensorflow/core/lib/core/status_test_util.h"
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/cc/framework/scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Scope::Impl::Impl(const std::shared_ptr<Graph>& graph,
Scope Scope::NewRootScope() {
Graph* graph = new Graph(OpRegistry::Global());
ShapeRefiner* refiner =
new ShapeRefiner(graph->versions().producer(), graph->op_registry());
new ShapeRefiner(graph->versions(), graph->op_registry());
return Scope(new Impl(graph, new Status, new Impl::NameMap, refiner));
}

Expand Down
1 change: 1 addition & 0 deletions tensorflow/compiler/aot/compile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ limitations under the License.
#include "tensorflow/core/framework/graph_def_util.h"
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/tensor_shape.h"
#include "tensorflow/core/framework/versions.pb.h"
#include "tensorflow/core/graph/algorithm.h"
#include "tensorflow/core/graph/graph.h"
#include "tensorflow/core/graph/graph_constructor.h"
Expand Down
1 change: 1 addition & 0 deletions tensorflow/compiler/jit/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ cc_library(
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core:lib_internal",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:stream_executor_no_cuda",
"//tensorflow/core:tensorflow_opensource",
"//tensorflow/core/kernels:constant_op",
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/compiler/jit/xla_device.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@ limitations under the License.
#include "tensorflow/core/framework/allocator.h"
#include "tensorflow/core/framework/device_base.h"
#include "tensorflow/core/framework/function.h"
#include "tensorflow/core/framework/kernel_def.pb.h"
#include "tensorflow/core/framework/node_def_builder.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tensor.pb.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/graph/graph_constructor.h"
#include "tensorflow/core/lib/core/notification.h"
Expand Down
1 change: 1 addition & 0 deletions tensorflow/compiler/tf2xla/kernels/const_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
#include "tensorflow/compiler/tf2xla/xla_op_kernel.h"
#include "tensorflow/compiler/tf2xla/xla_op_registry.h"
#include "tensorflow/core/framework/kernel_def_builder.h"
#include "tensorflow/core/framework/tensor.pb.h"

namespace tensorflow {
namespace {
Expand Down
1 change: 1 addition & 0 deletions tensorflow/compiler/tf2xla/test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ limitations under the License.
#include <vector>

#include "tensorflow/core/framework/function.h"
#include "tensorflow/core/framework/graph.pb.h"
#include "tensorflow/core/graph/graph.h"
#include "tensorflow/core/lib/core/status.h"

Expand Down
1 change: 1 addition & 0 deletions tensorflow/compiler/tf2xla/xla_op_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ limitations under the License.
#include "tensorflow/core/common_runtime/device_factory.h"
#include "tensorflow/core/common_runtime/local_device.h"
#include "tensorflow/core/framework/device_base.h"
#include "tensorflow/core/framework/kernel_def.pb.h"
#include "tensorflow/core/framework/node_def.pb.h"
#include "tensorflow/core/platform/mem.h"
#include "tensorflow/core/platform/stream_executor_no_cuda.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ class SingleImageRandomDotStereogramsOp : public OpKernel {
float normalize_min;
float border_level;
int number_colors;
::tensorflow::TensorShapeProto output_image_shape;
::tensorflow::TensorShapeProto output_data_window;
::tensorflow::PartialTensorShape output_image_shape;
::tensorflow::PartialTensorShape output_data_window;

uint8 Cblack = 0;
uint8 Cwhite = 255;
Expand Down Expand Up @@ -109,15 +109,15 @@ class SingleImageRandomDotStereogramsOp : public OpKernel {
input_Yvalue =
input_tensor.shape().dim_size(0); // Y value is the number of rows

output_Ximage = output_image_shape.dim(0).size();
output_Yimage = output_image_shape.dim(1).size();
output_Cimage = output_image_shape.dim(2).size();
output_Ximage = output_image_shape.dim_size(0);
output_Yimage = output_image_shape.dim_size(1);
output_Cimage = output_image_shape.dim_size(2);

if (number_colors > 256) // Go to full color image
output_Cimage = 3;

int data_Xwindow = output_data_window.dim(0).size();
int data_Ywindow = output_data_window.dim(1).size();
int data_Xwindow = output_data_window.dim_size(0);
int data_Ywindow = output_data_window.dim_size(1);

int deltaX_border_image = output_Ximage - data_Xwindow;
int deltaY_border_image = output_Yimage - data_Ywindow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ limitations under the License.
#include "tensorflow/core/framework/tensor_shape.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/platform/fingerprint.h"
#include "tensorflow/core/util/work_sharder.h"

Expand Down
8 changes: 2 additions & 6 deletions tensorflow/contrib/tpu/ops/infeed_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,8 @@ REGISTER_OP("InfeedDequeue")
.SetShapeFn([](InferenceContext* c) {
PartialTensorShape shape;
TF_RETURN_IF_ERROR(c->GetAttr("shape", &shape));
TensorShapeProto shape_proto;
shape.AsProto(&shape_proto);
ShapeHandle out;
TF_RETURN_IF_ERROR(c->MakeShapeFromShapeProto(shape_proto, &out));
TF_RETURN_IF_ERROR(c->MakeShapeFromPartialTensorShape(shape, &out));
c->set_output(0, out);
return Status::OK();
})
Expand Down Expand Up @@ -87,10 +85,8 @@ REGISTER_OP("InfeedDequeueTuple")
std::vector<PartialTensorShape> shapes;
TF_RETURN_IF_ERROR(c->GetAttr("shapes", &shapes));
for (int i = 0; i < shapes.size(); ++i) {
TensorShapeProto shape_proto;
shapes[i].AsProto(&shape_proto);
ShapeHandle out;
TF_RETURN_IF_ERROR(c->MakeShapeFromShapeProto(shape_proto, &out));
TF_RETURN_IF_ERROR(c->MakeShapeFromPartialTensorShape(shapes[i], &out));
c->set_output(i, out);
}
return Status::OK();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ limitations under the License.
#include "tensorflow/contrib/util/convert_graphdef_memmapped_format_lib.h"

#include <unordered_set>
#include "tensorflow/core/framework/attr_value.pb.h"
#include "tensorflow/core/framework/graph.pb.h"
#include "tensorflow/core/framework/node_def.pb.h"
#include "tensorflow/core/framework/register_types.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tensor.pb.h"
#include "tensorflow/core/framework/tensor_shape.pb.h"
#include "tensorflow/core/framework/types.pb.h"
#include "tensorflow/core/kernels/immutable_constant_op.h"
#include "tensorflow/core/platform/env.h"
Expand Down
8 changes: 7 additions & 1 deletion tensorflow/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,6 @@ cc_library(
# Generates library per group of ops.
tf_gen_op_libs(
op_lib_names = [
"array_ops",
"bitwise_ops",
"candidate_sampling_ops",
"control_flow_ops",
Expand Down Expand Up @@ -534,6 +533,13 @@ tf_gen_op_libs(
],
)

tf_gen_op_libs(
op_lib_names = [
"array_ops",
],
deps = [":protos_all_cc"],
)

tf_gen_op_libs(
op_lib_names = [
"audio_ops",
Expand Down
1 change: 1 addition & 0 deletions tensorflow/core/common_runtime/direct_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ limitations under the License.
#include "tensorflow/core/framework/log_memory.h"
#include "tensorflow/core/framework/node_def.pb.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/versions.pb.h"
#include "tensorflow/core/graph/algorithm.h"
#include "tensorflow/core/graph/graph.h"
#include "tensorflow/core/graph/graph_constructor.h"
Expand Down
1 change: 1 addition & 0 deletions tensorflow/core/common_runtime/function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ limitations under the License.
#include "tensorflow/core/framework/node_def_util.h"
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/versions.pb.h"
#include "tensorflow/core/graph/algorithm.h"
#include "tensorflow/core/graph/gradients.h"
#include "tensorflow/core/graph/graph_constructor.h"
Expand Down
1 change: 1 addition & 0 deletions tensorflow/core/common_runtime/function_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ limitations under the License.
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/tensor_testutil.h"
#include "tensorflow/core/framework/versions.pb.h"
#include "tensorflow/core/graph/graph_constructor.h"
#include "tensorflow/core/lib/core/notification.h"
#include "tensorflow/core/lib/core/status.h"
Expand Down
1 change: 1 addition & 0 deletions tensorflow/core/common_runtime/gpu/gpu_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ limitations under the License.
#include "tensorflow/core/common_runtime/gpu/process_state.h"
#include "tensorflow/core/common_runtime/gpu_device_context.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/tensor.pb.h"
#include "tensorflow/core/framework/tensor_reference.h"
#include "tensorflow/core/framework/types.h"
#include "tensorflow/core/lib/core/errors.h"
Expand Down
1 change: 1 addition & 0 deletions tensorflow/core/common_runtime/graph_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ limitations under the License.
#include "tensorflow/core/framework/log_memory.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/tensor_util.h"
#include "tensorflow/core/framework/versions.pb.h"
#include "tensorflow/core/graph/algorithm.h"
#include "tensorflow/core/graph/graph_constructor.h"
#include "tensorflow/core/graph/node_builder.h"
Expand Down
1 change: 1 addition & 0 deletions tensorflow/core/common_runtime/kernel_benchmark_testlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ limitations under the License.
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/op_kernel.h"
#include "tensorflow/core/framework/op_segment.h"
#include "tensorflow/core/framework/versions.pb.h"
#include "tensorflow/core/graph/graph.h"
#include "tensorflow/core/kernels/ops_util.h"
#include "tensorflow/core/lib/core/notification.h"
Expand Down
5 changes: 5 additions & 0 deletions tensorflow/core/common_runtime/shape_refiner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ limitations under the License.

#include "tensorflow/core/framework/common_shape_fns.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/framework/versions.pb.h"
#include "tensorflow/core/kernels/bounds_check.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/gtl/stl_util.h"
Expand All @@ -39,6 +40,10 @@ ShapeRefiner::ShapeRefiner(int graph_def_version,
ops_registry_(ops),
graph_runner_(Env::Default()) {}

ShapeRefiner::ShapeRefiner(const VersionDef& versions,
const OpRegistryInterface* ops)
: ShapeRefiner(versions.producer(), ops) {}

ShapeRefiner::~ShapeRefiner() {
// The lifetime of the tensors are bound to the GraphRunner, so the tensors
// should be deleted before it.
Expand Down
4 changes: 4 additions & 0 deletions tensorflow/core/common_runtime/shape_refiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class GraphProperties;
class ShapeRefiner {
public:
ShapeRefiner(int graph_def_version, const OpRegistryInterface* ops);

// Same as ShapeRefiner(versions.producer(), ops)
ShapeRefiner(const VersionDef& versions, const OpRegistryInterface* ops);

~ShapeRefiner();

// Performs validation of 'node' and runs 'node's shape function,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ limitations under the License.
#include "tensorflow/core/framework/graph.pb_text.h"
#include "tensorflow/core/framework/graph_def_util.h"
#include "tensorflow/core/framework/node_def.pb.h"
#include "tensorflow/core/framework/versions.pb.h"
#include "tensorflow/core/graph/graph.h"
#include "tensorflow/core/graph/graph_constructor.h"
#include "tensorflow/core/graph/subgraph.h"
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/core/common_runtime/step_stats_collector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ limitations under the License.

#include "tensorflow/core/common_runtime/step_stats_collector.h"
#include "tensorflow/core/common_runtime/costmodel_manager.h"
#include "tensorflow/core/framework/allocation_description.pb.h"
#include "tensorflow/core/framework/step_stats.pb.h"
#include "tensorflow/core/framework/tensor_description.pb.h"
#include "tensorflow/core/graph/costmodel.h"
#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/strings/scanner.h"
Expand Down
1 change: 1 addition & 0 deletions tensorflow/core/debug/debug_io_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ limitations under the License.
#endif

#include "tensorflow/core/debug/debugger_event_metadata.pb.h"
#include "tensorflow/core/framework/graph.pb.h"
#include "tensorflow/core/framework/summary.pb.h"
#include "tensorflow/core/lib/hash/hash.h"
#include "tensorflow/core/lib/io/path.h"
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/core/distributed_runtime/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ cc_library(
"//tensorflow/core:core_cpu_internal",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:worker_proto_cc",
],
)
Expand Down Expand Up @@ -205,6 +206,7 @@ cc_test(
"//tensorflow/core:core_cpu",
"//tensorflow/core:framework",
"//tensorflow/core:lib",
"//tensorflow/core:protos_all_cc",
"//tensorflow/core:tensor_testutil",
"//tensorflow/core:test",
"//tensorflow/core:test_main",
Expand Down
1 change: 1 addition & 0 deletions tensorflow/core/distributed_runtime/executor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ limitations under the License.
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/framework/rendezvous.h"
#include "tensorflow/core/framework/step_stats.pb.h"
#include "tensorflow/core/framework/versions.pb.h"
#include "tensorflow/core/graph/graph_constructor.h"
#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/lib/random/simple_philox.h"
Expand Down
1 change: 1 addition & 0 deletions tensorflow/core/distributed_runtime/graph_mgr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ limitations under the License.
#include "tensorflow/core/framework/log_memory.h"
#include "tensorflow/core/framework/node_def.pb.h"
#include "tensorflow/core/framework/node_def_util.h"
#include "tensorflow/core/framework/versions.pb.h"
#include "tensorflow/core/graph/graph.h"
#include "tensorflow/core/graph/graph_constructor.h"
#include "tensorflow/core/graph/graph_partition.h"
Expand Down
Loading

0 comments on commit e85d3df

Please sign in to comment.