aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tensorflow/c/c_api.cc4
-rw-r--r--tensorflow/cc/framework/cc_op_gen.cc2
-rw-r--r--tensorflow/cc/saved_model/loader.h2
-rw-r--r--tensorflow/cc/training/coordinator.cc4
-rw-r--r--tensorflow/cc/training/coordinator_test.cc30
-rw-r--r--tensorflow/cc/training/queue_runner.cc4
-rw-r--r--tensorflow/cc/training/queue_runner_test.cc8
-rw-r--r--tensorflow/compiler/jit/encapsulate_subgraphs_pass_test.cc10
-rw-r--r--tensorflow/compiler/jit/graph_to_functiondef.cc8
-rw-r--r--tensorflow/compiler/jit/graph_to_functiondef_test.cc2
-rw-r--r--tensorflow/compiler/jit/mark_for_compilation_pass_test.cc20
-rw-r--r--tensorflow/compiler/tf2xla/kernels/retval_op.cc4
-rw-r--r--tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc16
-rw-r--r--tensorflow/contrib/cudnn_rnn/ops/cudnn_rnn_ops.cc2
-rw-r--r--tensorflow/contrib/ffmpeg/decode_audio_op.cc2
-rw-r--r--tensorflow/contrib/rnn/kernels/lstm_ops.cc2
-rw-r--r--tensorflow/contrib/session_bundle/bundle_shim.cc2
-rw-r--r--tensorflow/contrib/session_bundle/bundle_shim_test.cc22
-rw-r--r--tensorflow/contrib/session_bundle/session_bundle.h2
-rw-r--r--tensorflow/core/common_runtime/device_factory.cc4
-rw-r--r--tensorflow/core/common_runtime/direct_session.cc2
-rw-r--r--tensorflow/core/common_runtime/direct_session_test.cc12
-rw-r--r--tensorflow/core/common_runtime/executor.cc13
-rw-r--r--tensorflow/core/common_runtime/gpu/gpu_stream_util_test.cc4
-rw-r--r--tensorflow/core/common_runtime/kernel_benchmark_testlib.cc8
-rw-r--r--tensorflow/core/common_runtime/optimization_registry_test.cc3
-rw-r--r--tensorflow/core/debug/debug_graph_utils.cc6
-rw-r--r--tensorflow/core/debug/debug_grpc_io_utils_test.cc12
-rw-r--r--tensorflow/core/debug/debug_grpc_testlib.cc3
-rw-r--r--tensorflow/core/debug/debug_io_utils.cc7
-rw-r--r--tensorflow/core/debug/debug_io_utils_test.cc6
-rw-r--r--tensorflow/core/distributed_runtime/graph_mgr.cc3
-rw-r--r--tensorflow/core/distributed_runtime/master.cc4
-rw-r--r--tensorflow/core/distributed_runtime/message_wrappers_test.cc31
-rw-r--r--tensorflow/core/distributed_runtime/rpc/grpc_channel_test.cc7
-rw-r--r--tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc2
-rw-r--r--tensorflow/core/distributed_runtime/rpc/grpc_tensorflow_server.cc6
-rw-r--r--tensorflow/core/distributed_runtime/rpc/grpc_testlib_server.cc4
-rw-r--r--tensorflow/core/distributed_runtime/rpcbench_test.cc4
-rw-r--r--tensorflow/core/distributed_runtime/worker.cc2
-rw-r--r--tensorflow/core/example/example_parser_configuration_test.cc7
-rw-r--r--tensorflow/core/framework/node_def_builder_test.cc3
-rw-r--r--tensorflow/core/framework/op_kernel.cc2
-rw-r--r--tensorflow/core/framework/op_registration_test.cc10
-rw-r--r--tensorflow/core/framework/shape_inference.cc3
-rw-r--r--tensorflow/core/graph/equal_graph_def_test.cc5
-rw-r--r--tensorflow/core/graph/graph_constructor_test.cc4
-rw-r--r--tensorflow/core/graph/graph_partition_test.cc6
-rw-r--r--tensorflow/core/kernels/adjust_contrast_op_benchmark_test.cc8
-rw-r--r--tensorflow/core/kernels/cloud/bigquery_table_accessor_test.cc4
-rw-r--r--tensorflow/core/kernels/control_flow_ops_test.cc6
-rw-r--r--tensorflow/core/kernels/conv_grad_ops.cc3
-rw-r--r--tensorflow/core/kernels/decode_csv_op.cc2
-rw-r--r--tensorflow/core/kernels/example_parsing_ops.cc29
-rw-r--r--tensorflow/core/kernels/fifo_queue.cc14
-rw-r--r--tensorflow/core/kernels/hexagon/graph_transfer_utils.cc2
-rw-r--r--tensorflow/core/kernels/hexagon/graph_transferer.cc6
-rw-r--r--tensorflow/core/kernels/padding_fifo_queue.cc8
-rw-r--r--tensorflow/core/kernels/priority_queue.cc13
-rw-r--r--tensorflow/core/kernels/quantize_and_dequantize_op_test.cc2
-rw-r--r--tensorflow/core/kernels/random_shuffle_queue_op.cc14
-rw-r--r--tensorflow/core/kernels/reader_base.cc2
-rw-r--r--tensorflow/core/kernels/remote_fused_graph_execute_op.cc3
-rw-r--r--tensorflow/core/kernels/save_op_test.cc2
-rw-r--r--tensorflow/core/kernels/save_restore_v2_ops.cc8
-rw-r--r--tensorflow/core/kernels/scatter_nd_op.cc3
-rw-r--r--tensorflow/core/kernels/sdca_internal.cc14
-rw-r--r--tensorflow/core/kernels/sdca_ops.cc3
-rw-r--r--tensorflow/core/kernels/spacetobatch_benchmark_test.cc20
-rw-r--r--tensorflow/core/kernels/summary_image_op.cc6
-rw-r--r--tensorflow/core/kernels/tf_record_reader_op.cc3
-rw-r--r--tensorflow/core/lib/core/status.cc4
-rw-r--r--tensorflow/core/lib/core/status.h5
-rw-r--r--tensorflow/core/lib/io/buffered_inputstream.cc2
-rw-r--r--tensorflow/core/lib/io/buffered_inputstream_test.cc23
-rw-r--r--tensorflow/core/lib/io/inputbuffer_test.cc19
-rw-r--r--tensorflow/core/lib/io/random_inputstream_test.cc6
-rw-r--r--tensorflow/core/lib/io/record_reader_writer_test.cc8
-rw-r--r--tensorflow/core/ops/nn_ops.cc8
-rw-r--r--tensorflow/core/ops/resource_variable_ops.cc8
-rw-r--r--tensorflow/core/ops/sdca_ops.cc5
-rw-r--r--tensorflow/core/platform/cloud/gcs_file_system.cc7
-rw-r--r--tensorflow/core/platform/cloud/http_request_test.cc10
-rw-r--r--tensorflow/core/platform/cloud/retrying_file_system.cc2
-rw-r--r--tensorflow/core/platform/env_test.cc7
-rw-r--r--tensorflow/core/platform/hadoop/hadoop_file_system.cc2
-rw-r--r--tensorflow/core/util/events_writer.cc2
-rw-r--r--tensorflow/core/util/events_writer_test.cc8
-rw-r--r--tensorflow/core/util/example_proto_helper.cc9
-rw-r--r--tensorflow/core/util/example_proto_helper_test.cc21
-rw-r--r--tensorflow/core/util/memmapped_file_system_test.cc2
-rw-r--r--tensorflow/core/util/tensor_bundle/tensor_bundle.cc24
-rw-r--r--tensorflow/core/util/tensor_bundle/tensor_bundle_test.cc54
-rw-r--r--tensorflow/core/util/tensor_slice_reader_test.cc2
-rw-r--r--tensorflow/core/util/tensor_slice_set_test.cc2
-rw-r--r--tensorflow/core/util/tensor_slice_writer.cc2
-rw-r--r--tensorflow/core/util/tensor_slice_writer_test.cc7
-rw-r--r--tensorflow/python/util/kernel_registry.cc3
-rw-r--r--tensorflow/stream_executor/cuda/cuda_platform.cc3
-rw-r--r--tensorflow/tools/benchmark/benchmark_model.cc6
-rw-r--r--tensorflow/tools/graph_transforms/freeze_requantization_ranges.cc5
-rw-r--r--tensorflow/tools/graph_transforms/insert_logging.cc6
-rw-r--r--tensorflow/tools/graph_transforms/quantize_nodes.cc21
-rw-r--r--tensorflow/tools/graph_transforms/remove_nodes.cc5
-rw-r--r--tensorflow/tools/graph_transforms/transform_graph_test.cc14
-rw-r--r--tensorflow/tools/graph_transforms/transform_utils.cc4
106 files changed, 459 insertions, 361 deletions
diff --git a/tensorflow/c/c_api.cc b/tensorflow/c/c_api.cc
index 5fc5674790..9335a69905 100644
--- a/tensorflow/c/c_api.cc
+++ b/tensorflow/c/c_api.cc
@@ -715,7 +715,7 @@ TF_Buffer* TF_GetAllOpList() {
*(op_list.add_op()) = op;
}
TF_Buffer* ret = TF_NewBuffer();
- MessageToBuffer(op_list, ret);
+ TF_CHECK_OK(MessageToBuffer(op_list, ret));
return ret;
}
@@ -1166,7 +1166,7 @@ static TF_Operation* TF_FinishOperationLocked(TF_OperationDescription* desc,
// TODO(b/28152992): Enable returning the result of this
// code-path once we have converted all python shape functions
// to call their C++ versions.
- desc->graph->refiner.AddNode(ret);
+ desc->graph->refiner.AddNode(ret).IgnoreError();
// Add the node to the name-to-node mapping.
desc->graph->name_map[ret->name()] = ret;
diff --git a/tensorflow/cc/framework/cc_op_gen.cc b/tensorflow/cc/framework/cc_op_gen.cc
index 2d52aa18b8..5894244c1d 100644
--- a/tensorflow/cc/framework/cc_op_gen.cc
+++ b/tensorflow/cc/framework/cc_op_gen.cc
@@ -920,7 +920,7 @@ void WriteCCOps(const OpList& ops, const string& dot_h_fname,
// Load the override map.
OpGenOverrideMap override_map;
if (!overrides_fnames.empty()) {
- override_map.LoadFileList(env, overrides_fnames);
+ TF_CHECK_OK(override_map.LoadFileList(env, overrides_fnames));
}
// Write the initial boilerplate to the .h and .cc files.
diff --git a/tensorflow/cc/saved_model/loader.h b/tensorflow/cc/saved_model/loader.h
index 9b9abdbb1f..3d634dd515 100644
--- a/tensorflow/cc/saved_model/loader.h
+++ b/tensorflow/cc/saved_model/loader.h
@@ -36,7 +36,7 @@ struct SavedModelBundle {
/// resource leaks, we explicitly call Close on Sessions that we create.
~SavedModelBundle() {
if (session) {
- session->Close();
+ session->Close().IgnoreError();
}
}
diff --git a/tensorflow/cc/training/coordinator.cc b/tensorflow/cc/training/coordinator.cc
index 53a566db95..0ec3c5edd6 100644
--- a/tensorflow/cc/training/coordinator.cc
+++ b/tensorflow/cc/training/coordinator.cc
@@ -31,8 +31,8 @@ Coordinator::Coordinator(const std::vector<error::Code>& clean_stop_errors)
}
Coordinator::~Coordinator() {
- RequestStop();
- Join();
+ RequestStop().IgnoreError();
+ Join().IgnoreError();
}
Status Coordinator::RegisterRunner(std::unique_ptr<RunnerInterface> runner) {
diff --git a/tensorflow/cc/training/coordinator_test.cc b/tensorflow/cc/training/coordinator_test.cc
index 5e4a696690..79f2a955d5 100644
--- a/tensorflow/cc/training/coordinator_test.cc
+++ b/tensorflow/cc/training/coordinator_test.cc
@@ -46,7 +46,7 @@ TEST(CoordinatorTest, TestStopAndWaitOnStop) {
Env::Default()->SleepForMicroseconds(10000000);
EXPECT_EQ(stopped, false);
- coord.RequestStop();
+ TF_EXPECT_OK(coord.RequestStop());
done.WaitForNotification();
EXPECT_EQ(stopped, true);
EXPECT_EQ(coord.ShouldStop(), true);
@@ -98,7 +98,7 @@ class MockQueueRunner : public RunnerInterface {
(*counter)++;
Env::Default()->SleepForMicroseconds(100000);
}
- coord_->RequestStop();
+ coord_->RequestStop().IgnoreError();
}
void SetStatusThread(const Status& status, BlockingCounter* counter) {
Env::Default()->SleepForMicroseconds(100000);
@@ -118,16 +118,16 @@ TEST(CoordinatorTest, TestRealStop) {
std::unique_ptr<MockQueueRunner> qr1(new MockQueueRunner(&coord));
qr1->StartCounting(&counter, 100);
- coord.RegisterRunner(std::move(qr1));
+ TF_ASSERT_OK(coord.RegisterRunner(std::move(qr1)));
std::unique_ptr<MockQueueRunner> qr2(new MockQueueRunner(&coord));
qr2->StartCounting(&counter, 100);
- coord.RegisterRunner(std::move(qr2));
+ TF_ASSERT_OK(coord.RegisterRunner(std::move(qr2)));
// Wait until the counting has started
while (counter.load() == 0)
;
- coord.RequestStop();
+ TF_EXPECT_OK(coord.RequestStop());
int temp_counter = counter.load();
Env::Default()->SleepForMicroseconds(10000000);
@@ -142,7 +142,7 @@ TEST(CoordinatorTest, TestRequestStop) {
for (int i = 0; i < 10; i++) {
qr.reset(new MockQueueRunner(&coord));
qr->StartCounting(&counter, 10);
- coord.RegisterRunner(std::move(qr));
+ TF_ASSERT_OK(coord.RegisterRunner(std::move(qr)));
}
coord.WaitForStop();
@@ -156,12 +156,12 @@ TEST(CoordinatorTest, TestJoin) {
int join_counter = 0;
std::unique_ptr<MockQueueRunner> qr1(
new MockQueueRunner(&coord, &join_counter));
- coord.RegisterRunner(std::move(qr1));
+ TF_ASSERT_OK(coord.RegisterRunner(std::move(qr1)));
std::unique_ptr<MockQueueRunner> qr2(
new MockQueueRunner(&coord, &join_counter));
- coord.RegisterRunner(std::move(qr2));
+ TF_ASSERT_OK(coord.RegisterRunner(std::move(qr2)));
- coord.RequestStop();
+ TF_EXPECT_OK(coord.RequestStop());
TF_EXPECT_OK(coord.Join());
EXPECT_EQ(join_counter, 2);
}
@@ -172,25 +172,25 @@ TEST(CoordinatorTest, StatusReporting) {
std::unique_ptr<MockQueueRunner> qr1(new MockQueueRunner(&coord));
qr1->StartSettingStatus(Status(Code::CANCELLED, ""), &counter);
- coord.RegisterRunner(std::move(qr1));
+ TF_ASSERT_OK(coord.RegisterRunner(std::move(qr1)));
std::unique_ptr<MockQueueRunner> qr2(new MockQueueRunner(&coord));
qr2->StartSettingStatus(Status(Code::INVALID_ARGUMENT, ""), &counter);
- coord.RegisterRunner(std::move(qr2));
+ TF_ASSERT_OK(coord.RegisterRunner(std::move(qr2)));
std::unique_ptr<MockQueueRunner> qr3(new MockQueueRunner(&coord));
qr3->StartSettingStatus(Status(Code::OUT_OF_RANGE, ""), &counter);
- coord.RegisterRunner(std::move(qr3));
+ TF_ASSERT_OK(coord.RegisterRunner(std::move(qr3)));
counter.Wait();
- coord.RequestStop();
+ TF_EXPECT_OK(coord.RequestStop());
EXPECT_EQ(coord.Join().code(), Code::INVALID_ARGUMENT);
}
TEST(CoordinatorTest, JoinWithoutStop) {
Coordinator coord;
std::unique_ptr<MockQueueRunner> qr(new MockQueueRunner(&coord));
- coord.RegisterRunner(std::move(qr));
+ TF_ASSERT_OK(coord.RegisterRunner(std::move(qr)));
EXPECT_EQ(coord.Join().code(), Code::FAILED_PRECONDITION);
}
@@ -198,7 +198,7 @@ TEST(CoordinatorTest, JoinWithoutStop) {
TEST(CoordinatorTest, AllRunnersStopped) {
Coordinator coord;
MockQueueRunner* qr = new MockQueueRunner(&coord);
- coord.RegisterRunner(std::unique_ptr<RunnerInterface>(qr));
+ TF_ASSERT_OK(coord.RegisterRunner(std::unique_ptr<RunnerInterface>(qr)));
EXPECT_FALSE(coord.AllRunnersStopped());
qr->Stop();
diff --git a/tensorflow/cc/training/queue_runner.cc b/tensorflow/cc/training/queue_runner.cc
index cd6cc67327..1f6794cce2 100644
--- a/tensorflow/cc/training/queue_runner.cc
+++ b/tensorflow/cc/training/queue_runner.cc
@@ -77,7 +77,7 @@ Status QueueRunner::Init(const QueueRunnerDef& queue_runner_def) {
QueueRunner::~QueueRunner() {
// Cannot run Stop() here because the session might already be closed or
// destroyed.
- Join();
+ Join().IgnoreError();
}
Status QueueRunner::Start(Session* sess) { return Start(sess, 0); }
@@ -175,7 +175,7 @@ void QueueRunner::Run(Session* sess, const string& enqueue_op) {
} else if (!status.ok()) {
UpdateStatus(status);
if (coord_) {
- coord_->RequestStop();
+ coord_->RequestStop().IgnoreError();
}
}
}
diff --git a/tensorflow/cc/training/queue_runner_test.cc b/tensorflow/cc/training/queue_runner_test.cc
index 1661c5c91b..27c302ab28 100644
--- a/tensorflow/cc/training/queue_runner_test.cc
+++ b/tensorflow/cc/training/queue_runner_test.cc
@@ -293,7 +293,7 @@ TEST(QueueRunnerTest, StartTimeout) {
// This will timeout since queue0 is not fed and queue1 is fetching data from
// queue0.
EXPECT_EQ(qr->Start(session.get(), 1).code(), Code::DEADLINE_EXCEEDED);
- session->Close();
+ TF_EXPECT_OK(session->Close());
}
TEST(QueueRunnerTest, TestCoordinatorStop) {
@@ -317,8 +317,8 @@ TEST(QueueRunnerTest, TestCoordinatorStop) {
TF_EXPECT_OK(QueueRunner::New(queue_runner1, &coord, &qr1));
TF_CHECK_OK(qr1->Start(session.get()));
- coord.RegisterRunner(std::move(qr0));
- coord.RegisterRunner(std::move(qr1));
+ TF_EXPECT_OK(coord.RegisterRunner(std::move(qr0)));
+ TF_EXPECT_OK(coord.RegisterRunner(std::move(qr1)));
std::vector<Tensor> dq;
TF_EXPECT_OK(session->Run({}, {kDequeueOp1}, {}, &dq));
@@ -340,7 +340,7 @@ TEST(QueueRunnerTest, CallbackCalledOnError) {
bool error_caught = false;
qr->AddErrorCallback([&error_caught](const Status&) { error_caught = true; });
TF_EXPECT_OK(qr->Start(session.get()));
- qr->Join();
+ EXPECT_FALSE(qr->Join().ok());
EXPECT_TRUE(error_caught);
}
diff --git a/tensorflow/compiler/jit/encapsulate_subgraphs_pass_test.cc b/tensorflow/compiler/jit/encapsulate_subgraphs_pass_test.cc
index c85882e0d7..86c1903054 100644
--- a/tensorflow/compiler/jit/encapsulate_subgraphs_pass_test.cc
+++ b/tensorflow/compiler/jit/encapsulate_subgraphs_pass_test.cc
@@ -168,7 +168,7 @@ TEST(EncapsulateSubgraphsTest, NoFunctions) {
GraphDef graphdef_in;
FunctionDefLibrary library_in;
- builder.ToGraphDef(&graphdef_in);
+ TF_EXPECT_OK(builder.ToGraphDef(&graphdef_in));
*library_in.add_function() = test::function::XTimesTwo();
GraphDef graphdef_out = graphdef_in;
@@ -195,7 +195,7 @@ TEST(EncapsulateSubgraphsTest, OneFunction) {
Node* d = Binary(b, c, b1.opts().WithName("c").WithControlInput(c).WithAttr(
"_encapsulate", "F1"));
Binary(a, d, b1.opts().WithName("E"));
- b1.ToGraphDef(&graphdef);
+ TF_EXPECT_OK(b1.ToGraphDef(&graphdef));
}
TF_EXPECT_OK(Encapsulate(&graphdef, &library));
@@ -224,7 +224,7 @@ TEST(EncapsulateSubgraphsTest, OneFunction) {
Node* call = b2.opts().FinalizeBuilder(&node_builder);
Binary(a, call, b2.opts().WithName("E"));
- b2.ToGraphDef(&graphdef_expected);
+ TF_EXPECT_OK(b2.ToGraphDef(&graphdef_expected));
}
// If there are no marked nodes, funcification should be a no-op.
@@ -251,7 +251,7 @@ TEST(EncapsulateSubgraphsTest, TwoFunctions) {
Binary(b, c, b1.opts().WithName("D").WithControlInput(control).WithAttr(
"_encapsulate", "F2"));
Binary(a, d, b1.opts().WithName("E"));
- b1.ToGraphDef(&graphdef);
+ TF_EXPECT_OK(b1.ToGraphDef(&graphdef));
}
TF_EXPECT_OK(Encapsulate(&graphdef, &library));
@@ -290,7 +290,7 @@ TEST(EncapsulateSubgraphsTest, TwoFunctions) {
Node* call2 = b2.opts().FinalizeBuilder(&nb2);
Binary(a, call2, b2.opts().WithName("E"));
- b2.ToGraphDef(&graphdef_expected);
+ TF_EXPECT_OK(b2.ToGraphDef(&graphdef_expected));
}
// If there are no marked nodes, funcification should be a no-op.
diff --git a/tensorflow/compiler/jit/graph_to_functiondef.cc b/tensorflow/compiler/jit/graph_to_functiondef.cc
index f5b99226ac..d4482c87ff 100644
--- a/tensorflow/compiler/jit/graph_to_functiondef.cc
+++ b/tensorflow/compiler/jit/graph_to_functiondef.cc
@@ -126,8 +126,8 @@ Status GraphToFunctionDef(const Graph& graph, const string& name,
if (node->type_string() == kArgOp) {
int index;
DataType type;
- GetNodeAttr(node->def(), "T", &type);
- GetNodeAttr(node->def(), "index", &index);
+ TF_RETURN_IF_ERROR(GetNodeAttr(node->def(), "T", &type));
+ TF_RETURN_IF_ERROR(GetNodeAttr(node->def(), "index", &index));
while (fdef->signature().input_arg_size() <= index) {
fdef->mutable_signature()->add_input_arg();
}
@@ -143,8 +143,8 @@ Status GraphToFunctionDef(const Graph& graph, const string& name,
if (node->type_string() == kRetValOp) {
int index;
DataType type;
- GetNodeAttr(node->def(), "T", &type);
- GetNodeAttr(node->def(), "index", &index);
+ TF_RETURN_IF_ERROR(GetNodeAttr(node->def(), "T", &type));
+ TF_RETURN_IF_ERROR(GetNodeAttr(node->def(), "index", &index));
while (fdef->signature().output_arg_size() <= index) {
fdef->mutable_signature()->add_output_arg();
}
diff --git a/tensorflow/compiler/jit/graph_to_functiondef_test.cc b/tensorflow/compiler/jit/graph_to_functiondef_test.cc
index 04b2385c9c..63d91ceab8 100644
--- a/tensorflow/compiler/jit/graph_to_functiondef_test.cc
+++ b/tensorflow/compiler/jit/graph_to_functiondef_test.cc
@@ -54,7 +54,7 @@ TEST(GraphToFunctionDefTest, Basics) {
auto h = ops::_Retval(root.WithOpName("H"), g, 0);
GraphDef graph_def;
- root.ToGraphDef(&graph_def);
+ TF_EXPECT_OK(root.ToGraphDef(&graph_def));
std::unique_ptr<Graph> graph(new Graph(OpRegistry::Global()));
GraphConstructorOptions options;
diff --git a/tensorflow/compiler/jit/mark_for_compilation_pass_test.cc b/tensorflow/compiler/jit/mark_for_compilation_pass_test.cc
index 61b2031a36..47991b0222 100644
--- a/tensorflow/compiler/jit/mark_for_compilation_pass_test.cc
+++ b/tensorflow/compiler/jit/mark_for_compilation_pass_test.cc
@@ -77,7 +77,7 @@ TEST(XlaCompilationTest, Chains) {
ops::UnaryOp("UncompilableUnary", c, builder.opts().WithName("D"));
Node* e = ops::UnaryOp("Relu", d, builder.opts().WithName("E"));
ops::UnaryOp("Relu", e, builder.opts().WithName("F"));
- builder.ToGraph(graph.get());
+ TF_EXPECT_OK(builder.ToGraph(graph.get()));
}
MarkForCompilation(&graph);
@@ -102,7 +102,7 @@ TEST(XlaCompilationTest, UncompilableCycles) {
Node* b =
ops::UnaryOp("UncompilableUnary", a, builder.opts().WithName("B"));
ops::BinaryOp("MatMul", a, b, builder.opts().WithName("C"));
- builder.ToGraph(graph.get());
+ TF_EXPECT_OK(builder.ToGraph(graph.get()));
}
MarkForCompilation(&graph);
@@ -122,7 +122,7 @@ TEST(XlaCompilationTest, CompilableCycles) {
.WithAttr("value", Tensor()));
Node* b = ops::UnaryOp("Relu", a, builder.opts().WithName("B"));
ops::BinaryOp("MatMul", a, b, builder.opts().WithName("C"));
- builder.ToGraph(graph.get());
+ TF_EXPECT_OK(builder.ToGraph(graph.get()));
}
MarkForCompilation(&graph);
@@ -145,7 +145,7 @@ TEST(XlaCompilationTest, UnsupportedTypes) {
.WithAttr("value", Tensor(DT_COMPLEX64, TensorShape())));
Node* b = ops::UnaryOp("Neg", a, builder.opts().WithName("B"));
ops::BinaryOp("MatMul", a, b, builder.opts().WithName("C"));
- builder.ToGraph(graph.get());
+ TF_EXPECT_OK(builder.ToGraph(graph.get()));
}
MarkForCompilation(&graph);
@@ -174,7 +174,7 @@ TEST(XlaCompilationTest, ConcatWithConstArg) {
concat_builder.Input(dim).Input({a, a}).Attr("N", 2);
builder.opts().FinalizeBuilder(&concat_builder);
- builder.ToGraph(graph.get());
+ TF_EXPECT_OK(builder.ToGraph(graph.get()));
}
MarkForCompilation(&graph);
@@ -201,7 +201,7 @@ TEST(XlaCompilationTest, FunctionCalls) {
Node* b = ops::BinaryOp("CompilableFn", a, a, builder.opts().WithName("B"));
Node* c = ops::UnaryOp("Relu", b, builder.opts().WithName("C"));
ops::UnaryOp("UncompilableFn", c, builder.opts().WithName("D"));
- builder.ToGraph(graph.get());
+ TF_EXPECT_OK(builder.ToGraph(graph.get()));
}
MarkForCompilation(&graph, &flib_def);
@@ -231,8 +231,8 @@ TEST(XlaCompilationTest, MetadataOpsDontStartClusters) {
Node* b = ops::UnaryOp("Shape", a, builder.opts().WithName("B"));
Node* c = ops::UnaryOp("Rank", b, builder.opts().WithName("C"));
Node* d = ops::UnaryOp("Size", c, builder.opts().WithName("D"));
- ops::UnaryOp("Shape", d, builder.opts().WithName("C"));
- builder.ToGraph(graph.get());
+ ops::UnaryOp("Shape", d, builder.opts().WithName("E"));
+ TF_EXPECT_OK(builder.ToGraph(graph.get()));
}
MarkForCompilation(&graph);
auto clusters = GetClusters(*graph);
@@ -318,7 +318,7 @@ TEST(XlaCompilationTest, SymbolicGradients) {
d_builder.Input({c, c});
builder.opts().FinalizeBuilder(&d_builder);
- builder.ToGraph(graph.get());
+ TF_EXPECT_OK(builder.ToGraph(graph.get()));
}
MarkForCompilation(&graph);
@@ -344,7 +344,7 @@ TEST(XlaCompilationTest, Loops) {
auto d = ops::Add(root.WithOpName("D"), c, exit);
std::unique_ptr<Graph> graph(new Graph(OpRegistry::Global()));
- root.ToGraph(graph.get());
+ TF_EXPECT_OK(root.ToGraph(graph.get()));
MarkForCompilation(&graph);
auto clusters = GetClusters(*graph);
diff --git a/tensorflow/compiler/tf2xla/kernels/retval_op.cc b/tensorflow/compiler/tf2xla/kernels/retval_op.cc
index 87d11a38d4..680c286206 100644
--- a/tensorflow/compiler/tf2xla/kernels/retval_op.cc
+++ b/tensorflow/compiler/tf2xla/kernels/retval_op.cc
@@ -43,7 +43,7 @@ class RetvalOp : public XlaOpKernel {
if (frame) {
// If 'frame' is non-null, this is an inner function call inside a JIT
// compilation.
- frame->SetRetval(index_, input);
+ OP_REQUIRES_OK(ctx, frame->SetRetval(index_, input));
} else {
xla::ComputationDataHandle input = ctx->Input(0);
const TensorShape input_shape = ctx->InputShape(0);
@@ -58,7 +58,7 @@ class RetvalOp : public XlaOpKernel {
if (input_shape.num_elements() == 0 || is_constant.ValueOrDie()) {
xla::Literal literal;
OP_REQUIRES_OK(ctx, ctx->ConstantInput(0, &literal));
- tc.AddConstRetval(index_, dtype_, literal);
+ OP_REQUIRES_OK(ctx, tc.AddConstRetval(index_, dtype_, literal));
} else {
tc.AddRetval(index_, input);
}
diff --git a/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc b/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc
index 862b243018..901737563b 100644
--- a/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc
+++ b/tensorflow/compiler/xla/service/gpu/ir_emitter_unnested.cc
@@ -276,20 +276,19 @@ Status IrEmitterUnnested::HandleFusion(HloInstruction* fusion) {
TF_RETURN_IF_ERROR(root->Accept(&fused_emitter));
Shape input_shape = root->operand(0)->shape();
- // EmitRedutionToVector requires the input shape to have a layout, but
+ // EmitReductionToVector requires the input shape to have a layout, but
// fused instructions don't have one. So we determine its layout from
// the fusion's operands. The choice of the layout only affects
// performance but not correctness.
auto choose_input_layout = [](
tensorflow::gtl::ArraySlice<const HloInstruction*> operands,
- Shape* input_shape) {
+ Shape* input_shape) -> Status {
// Prefer the layout of an operand whose shape is compatible with
// input_shape.
for (const HloInstruction* operand : operands) {
if (ShapeUtil::Compatible(*input_shape, operand->shape())) {
- LayoutUtil::CopyLayoutBetweenShapes(operand->shape(),
- input_shape);
- return;
+ return LayoutUtil::CopyLayoutBetweenShapes(operand->shape(),
+ input_shape);
}
}
// If no operand has a compatible shape, prefer an operand that has
@@ -300,19 +299,20 @@ Status IrEmitterUnnested::HandleFusion(HloInstruction* fusion) {
// Do not use CopyLayoutBetweenShapes because input_shape and
// operand->shape() may be incompatible.
*input_shape->mutable_layout() = operand->shape().layout();
- return;
+ return Status::OK();
}
}
// When all the above fails, which is rare, set the default layout.
LayoutUtil::SetToDefaultLayout(input_shape);
+ return Status::OK();
};
- choose_input_layout(fusion->operands(), &input_shape);
+ TF_RETURN_IF_ERROR(
+ choose_input_layout(fusion->operands(), &input_shape));
return EmitReductionToVector(
root, input_shape, fused_emitter.GetGenerator(root->operand(0)),
fused_emitter.GetGenerator(root->operand(1)), root->dimensions(),
root->to_apply());
- break;
}
default:
LOG(FATAL) << "Bad opcode for input fusion: "
diff --git a/tensorflow/contrib/cudnn_rnn/ops/cudnn_rnn_ops.cc b/tensorflow/contrib/cudnn_rnn/ops/cudnn_rnn_ops.cc
index b5c2390de1..58025f7b1a 100644
--- a/tensorflow/contrib/cudnn_rnn/ops/cudnn_rnn_ops.cc
+++ b/tensorflow/contrib/cudnn_rnn/ops/cudnn_rnn_ops.cc
@@ -232,7 +232,7 @@ REGISTER_OP("CudnnRNNParamsToCanonical")
ShapeHandle unused;
TF_RETURN_IF_ERROR(c->WithRank(c->input(3), 1, &unused));
int num_params;
- c->GetAttr("num_params", &num_params);
+ TF_RETURN_IF_ERROR(c->GetAttr("num_params", &num_params));
// Set shape for weight matrices
for (int i = 0; i < num_params; i++) {
c->set_output(i,
diff --git a/tensorflow/contrib/ffmpeg/decode_audio_op.cc b/tensorflow/contrib/ffmpeg/decode_audio_op.cc
index 15a31f9d31..a6a945094b 100644
--- a/tensorflow/contrib/ffmpeg/decode_audio_op.cc
+++ b/tensorflow/contrib/ffmpeg/decode_audio_op.cc
@@ -53,7 +53,7 @@ class FileDeleter {
explicit FileDeleter(const string& filename) : filename_(filename) {}
~FileDeleter() {
Env& env = *Env::Default();
- env.DeleteFile(filename_);
+ env.DeleteFile(filename_).IgnoreError();
}
private:
diff --git a/tensorflow/contrib/rnn/kernels/lstm_ops.cc b/tensorflow/contrib/rnn/kernels/lstm_ops.cc
index 2cebcd8fb3..6256ec1bf2 100644
--- a/tensorflow/contrib/rnn/kernels/lstm_ops.cc
+++ b/tensorflow/contrib/rnn/kernels/lstm_ops.cc
@@ -596,7 +596,7 @@ class SliceHelper {
CHECK(aligned.shape().IsSameSize(t.shape()));
CHECK_EQ(aligned.dtype(), t.dtype());
} else { // allocate a new temporary tensor
- ctx_->allocate_temp(t.dtype(), t.shape(), &aligned);
+ TF_CHECK_OK(ctx_->allocate_temp(t.dtype(), t.shape(), &aligned));
pool_.emplace(name, std::make_pair(aligned, true));
}
functor::TensorCopyUnaligned<Device, T>()(device_, t.unaligned_flat<T>(),
diff --git a/tensorflow/contrib/session_bundle/bundle_shim.cc b/tensorflow/contrib/session_bundle/bundle_shim.cc
index 81b37b1cf2..c369e3e108 100644
--- a/tensorflow/contrib/session_bundle/bundle_shim.cc
+++ b/tensorflow/contrib/session_bundle/bundle_shim.cc
@@ -319,7 +319,7 @@ Status BuildTensorNameToDtypeMap(
// Converts SessionBundle signatures to SavedModel signature-defs.
Status ConvertSignaturesToSignatureDefs(MetaGraphDef* meta_graph_def) {
Signatures signatures;
- GetSignatures(*meta_graph_def, &signatures);
+ GetSignatures(*meta_graph_def, &signatures).IgnoreError();
// Build a map of tensor-names to the corresponding tensor-info with `name`
// and `dtype` fields.
diff --git a/tensorflow/contrib/session_bundle/bundle_shim_test.cc b/tensorflow/contrib/session_bundle/bundle_shim_test.cc
index ac2acfe870..77265bffa5 100644
--- a/tensorflow/contrib/session_bundle/bundle_shim_test.cc
+++ b/tensorflow/contrib/session_bundle/bundle_shim_test.cc
@@ -144,7 +144,7 @@ TEST(BundleShimTest, AddOutputToSignatureDef) {
TEST(BundleShimTest, DefaultSignatureMissing) {
MetaGraphDef meta_graph_def;
// Signatures signatures;
- ConvertSignaturesToSignatureDefs(&meta_graph_def);
+ TF_EXPECT_OK(ConvertSignaturesToSignatureDefs(&meta_graph_def));
EXPECT_EQ(0, meta_graph_def.signature_def_size());
}
@@ -158,7 +158,7 @@ TEST(BundleShimTest, DefaultSignatureEmpty) {
.mutable_any_list()
->add_value()
->PackFrom(signatures);
- ConvertSignaturesToSignatureDefs(&meta_graph_def);
+ TF_EXPECT_OK(ConvertSignaturesToSignatureDefs(&meta_graph_def));
EXPECT_EQ(0, meta_graph_def.signature_def_size());
}
@@ -174,7 +174,7 @@ TEST(BundleShimTest, DefaultSignatureRegression) {
.mutable_any_list()
->add_value()
->PackFrom(signatures);
- ConvertSignaturesToSignatureDefs(&meta_graph_def);
+ TF_EXPECT_OK(ConvertSignaturesToSignatureDefs(&meta_graph_def));
EXPECT_EQ(1, meta_graph_def.signature_def_size());
const auto actual_signature_def =
meta_graph_def.signature_def().find(kDefaultServingSignatureDefKey);
@@ -202,7 +202,7 @@ TEST(BundleShimTest, DefaultSignatureClassification) {
.mutable_any_list()
->add_value()
->PackFrom(signatures);
- ConvertSignaturesToSignatureDefs(&meta_graph_def);
+ TF_EXPECT_OK(ConvertSignaturesToSignatureDefs(&meta_graph_def));
EXPECT_EQ(1, meta_graph_def.signature_def_size());
const auto actual_signature_def =
meta_graph_def.signature_def().find(kDefaultServingSignatureDefKey);
@@ -237,7 +237,7 @@ TEST(BundleShimTest, DefaultSignatureGeneric) {
.mutable_any_list()
->add_value()
->PackFrom(signatures);
- ConvertSignaturesToSignatureDefs(&meta_graph_def);
+ TF_EXPECT_OK(ConvertSignaturesToSignatureDefs(&meta_graph_def));
EXPECT_EQ(0, meta_graph_def.signature_def_size());
}
@@ -261,7 +261,7 @@ TEST(BundleShimTest, NamedRegressionSignatures) {
.mutable_any_list()
->add_value()
->PackFrom(signatures);
- ConvertSignaturesToSignatureDefs(&meta_graph_def);
+ TF_EXPECT_OK(ConvertSignaturesToSignatureDefs(&meta_graph_def));
ASSERT_EQ(2, meta_graph_def.signature_def_size());
ValidateSignatureDef(meta_graph_def, "foo",
@@ -315,7 +315,7 @@ TEST(BundleShimTest, NamedClassificationSignatures) {
.mutable_any_list()
->add_value()
->PackFrom(signatures);
- ConvertSignaturesToSignatureDefs(&meta_graph_def);
+ TF_EXPECT_OK(ConvertSignaturesToSignatureDefs(&meta_graph_def));
ASSERT_EQ(2, meta_graph_def.signature_def_size());
ValidateSignatureDef(meta_graph_def, "foo",
@@ -374,7 +374,7 @@ TEST(BundleShimTest, NamedSignatureGenericInputsAndOutputs) {
.mutable_any_list()
->add_value()
->PackFrom(signatures);
- ConvertSignaturesToSignatureDefs(&meta_graph_def);
+ TF_EXPECT_OK(ConvertSignaturesToSignatureDefs(&meta_graph_def));
EXPECT_EQ(1, meta_graph_def.signature_def_size());
const auto actual_signature_def =
meta_graph_def.signature_def().find(kDefaultServingSignatureDefKey);
@@ -413,7 +413,7 @@ TEST(BundleShimTest, NamedSignatureGenericNoInputsOrOutputs) {
.mutable_any_list()
->add_value()
->PackFrom(signatures);
- ConvertSignaturesToSignatureDefs(&meta_graph_def);
+ TF_EXPECT_OK(ConvertSignaturesToSignatureDefs(&meta_graph_def));
EXPECT_EQ(0, meta_graph_def.signature_def_size());
}
@@ -434,7 +434,7 @@ TEST(BundleShimTest, NamedSignatureGenericOnlyInput) {
.mutable_any_list()
->add_value()
->PackFrom(signatures);
- ConvertSignaturesToSignatureDefs(&meta_graph_def);
+ TF_EXPECT_OK(ConvertSignaturesToSignatureDefs(&meta_graph_def));
EXPECT_EQ(0, meta_graph_def.signature_def_size());
}
@@ -473,7 +473,7 @@ TEST(BundleShimTest, DefaultAndNamedSignatureWithPredict) {
.mutable_any_list()
->add_value()
->PackFrom(signatures);
- ConvertSignaturesToSignatureDefs(&meta_graph_def);
+ TF_EXPECT_OK(ConvertSignaturesToSignatureDefs(&meta_graph_def));
EXPECT_EQ(2, meta_graph_def.signature_def_size());
// Verify that the default regression signature is converted to a
diff --git a/tensorflow/contrib/session_bundle/session_bundle.h b/tensorflow/contrib/session_bundle/session_bundle.h
index 5e37d3bb99..2ff258411d 100644
--- a/tensorflow/contrib/session_bundle/session_bundle.h
+++ b/tensorflow/contrib/session_bundle/session_bundle.h
@@ -50,7 +50,7 @@ struct SessionBundle {
// resource leaks, we explicitly call Close on Sessions that we create.
~SessionBundle() {
if (session) {
- session->Close();
+ session->Close().IgnoreError();
}
}
diff --git a/tensorflow/core/common_runtime/device_factory.cc b/tensorflow/core/common_runtime/device_factory.cc
index 108a9c0d91..fa12c48fb9 100644
--- a/tensorflow/core/common_runtime/device_factory.cc
+++ b/tensorflow/core/common_runtime/device_factory.cc
@@ -99,7 +99,7 @@ Status DeviceFactory::AddDevices(const SessionOptions& options,
"CPU Factory not registered. Did you link in threadpool_device?");
}
size_t init_size = devices->size();
- cpu_factory->CreateDevices(options, name_prefix, devices);
+ TF_RETURN_IF_ERROR(cpu_factory->CreateDevices(options, name_prefix, devices));
if (devices->size() == init_size) {
return errors::NotFound("No CPU devices are available in this process");
}
@@ -126,7 +126,7 @@ Device* DeviceFactory::NewDevice(const string& type,
SessionOptions opt = options;
(*opt.config.mutable_device_count())[type] = 1;
std::vector<Device*> devices;
- device_factory->CreateDevices(opt, name_prefix, &devices);
+ TF_CHECK_OK(device_factory->CreateDevices(opt, name_prefix, &devices));
CHECK_EQ(devices.size(), size_t{1});
return devices[0];
}
diff --git a/tensorflow/core/common_runtime/direct_session.cc b/tensorflow/core/common_runtime/direct_session.cc
index f00f5ffd8f..d696ed2a71 100644
--- a/tensorflow/core/common_runtime/direct_session.cc
+++ b/tensorflow/core/common_runtime/direct_session.cc
@@ -271,7 +271,7 @@ DirectSession::DirectSession(const SessionOptions& options,
}
DirectSession::~DirectSession() {
- if (!closed_) Close();
+ if (!closed_) Close().IgnoreError();
for (auto& it : partial_runs_) {
it.second.reset(nullptr);
}
diff --git a/tensorflow/core/common_runtime/direct_session_test.cc b/tensorflow/core/common_runtime/direct_session_test.cc
index 0ff93f91dc..76576b64b3 100644
--- a/tensorflow/core/common_runtime/direct_session_test.cc
+++ b/tensorflow/core/common_runtime/direct_session_test.cc
@@ -762,7 +762,7 @@ TEST(DirectSessionTest, TimeoutSession) {
// Verifies that the error code is DEADLINE_EXCEEDED.
Status s = session->Run({}, {}, {"fifo_queue_Dequeue"}, nullptr);
ASSERT_EQ(error::DEADLINE_EXCEEDED, s.code());
- session->Close();
+ TF_ASSERT_OK(session->Close());
// Creates a session with no operation_timeout_in_ms.
session.reset(CreateSession());
@@ -774,7 +774,7 @@ TEST(DirectSessionTest, TimeoutSession) {
Status s2 = session->Run(run_options, {}, {}, {"fifo_queue_Dequeue"}, nullptr,
nullptr);
ASSERT_EQ(error::DEADLINE_EXCEEDED, s2.code());
- session->Close();
+ TF_ASSERT_OK(session->Close());
}
// Accesses the cancellation manager for the step after the step has been
@@ -827,7 +827,7 @@ TEST(DirectSessionTest, TestTimeoutCleanShutdown) {
// Verify that the op ran to completion.
ASSERT_TRUE(CancellationMgrPollingOp::notification.HasBeenNotified());
- session->Close();
+ TF_ASSERT_OK(session->Close());
}
class BlockingOpState {
@@ -1058,7 +1058,7 @@ TEST(DirectSessionTest, TestDirectSessionRunClose) {
outputs.clear();
// Close the session.
- session->Close();
+ TF_ASSERT_OK(session->Close());
// Run the read on the variable to get an error.
Status s = session->Run({} /* inputs */, {},
@@ -1105,7 +1105,7 @@ TEST(DirectSessionTest, TestDirectSessionPRunClose) {
value_22.scalar<float>()() = 22.0;
// Close the session.
- session->Close();
+ TF_ASSERT_OK(session->Close());
// Feed first_const, fetch first_identity
s = session->PRun(handle, {{first_const->name(), value_11}},
@@ -1142,7 +1142,7 @@ TEST(DirectSessionTest, TestDirectSessionReset) {
outputs.clear();
// Reset the containers.
- Reset(options, {});
+ TF_EXPECT_OK(Reset(options, {}));
// Run the read on the variable to get an error.
// TODO(suharshs): This test only works because we close the Session in Reset.
diff --git a/tensorflow/core/common_runtime/executor.cc b/tensorflow/core/common_runtime/executor.cc
index 2261396819..6b7b3f16f7 100644
--- a/tensorflow/core/common_runtime/executor.cc
+++ b/tensorflow/core/common_runtime/executor.cc
@@ -557,7 +557,7 @@ Status ExecutorImpl::Initialize() {
// Build the information about frames in this subgraph.
ControlFlowInfo cf_info;
- BuildControlFlowInfo(graph_, &cf_info);
+ TF_RETURN_IF_ERROR(BuildControlFlowInfo(graph_, &cf_info));
// Cache this value so we make this virtual function call once, rather
// that O(# steps * # nodes per step) times.
@@ -1747,7 +1747,8 @@ Status ExecutorState::ProcessOutputs(const NodeItem& item, OpKernelContext* ctx,
if (item.num_outputs == 0 && impl_->params_.node_outputs_cb != nullptr) {
// If the node has no output, invoke the callback with output slot set to
// -1, signifying that this is a no-output node.
- impl_->params_.node_outputs_cb(item.node->name(), -1, nullptr, false, ctx);
+ s.Update(impl_->params_.node_outputs_cb(item.node->name(), -1, nullptr,
+ false, ctx));
}
for (int i = 0; i < item.num_outputs; ++i) {
@@ -1792,8 +1793,8 @@ Status ExecutorState::ProcessOutputs(const NodeItem& item, OpKernelContext* ctx,
// Experimental: debugger (tfdb) access to intermediate node outputs.
if (impl_->params_.node_outputs_cb != nullptr) {
- impl_->params_.node_outputs_cb(item.node->name(), i, out->ref, true,
- ctx);
+ s.Update(impl_->params_.node_outputs_cb(item.node->name(), i,
+ out->ref, true, ctx));
}
} else {
// NOTE that std::move is used here, so val.tensor goes to
@@ -1809,8 +1810,8 @@ Status ExecutorState::ProcessOutputs(const NodeItem& item, OpKernelContext* ctx,
// Experimental: debugger access to intermediate node outputs.
if (impl_->params_.node_outputs_cb != nullptr) {
- impl_->params_.node_outputs_cb(item.node->name(), i, out->val.get(),
- false, ctx);
+ s.Update(impl_->params_.node_outputs_cb(
+ item.node->name(), i, out->val.get(), false, ctx));
}
}
} else {
diff --git a/tensorflow/core/common_runtime/gpu/gpu_stream_util_test.cc b/tensorflow/core/common_runtime/gpu/gpu_stream_util_test.cc
index b186c9d88c..a8bad5b94d 100644
--- a/tensorflow/core/common_runtime/gpu/gpu_stream_util_test.cc
+++ b/tensorflow/core/common_runtime/gpu/gpu_stream_util_test.cc
@@ -36,7 +36,7 @@ class GpuStreamUtilTest : public OpsTestBase {
TEST_F(GpuStreamUtilTest, BogusOpts) {
auto root = Scope::NewRootScope().ExitOnError();
Graph g(OpRegistry::Global());
- root.ToGraph(&g);
+ TF_ASSERT_OK(root.ToGraph(&g));
std::unordered_map<int, int> node_to_stream_id;
gpu_stream_util::AssignStreamsOpts opts;
Status status;
@@ -56,7 +56,7 @@ TEST_F(GpuStreamUtilTest, BogusOpts) {
TEST_F(GpuStreamUtilTest, EmptyGraph) {
auto root = Scope::NewRootScope().ExitOnError();
Graph g(OpRegistry::Global());
- root.ToGraph(&g);
+ TF_ASSERT_OK(root.ToGraph(&g));
std::unordered_map<int, int> node_to_stream_id;
gpu_stream_util::AssignStreamsOpts opts;
TF_ASSERT_OK(gpu_stream_util::AssignStreams(&g, opts, &node_to_stream_id));
diff --git a/tensorflow/core/common_runtime/kernel_benchmark_testlib.cc b/tensorflow/core/common_runtime/kernel_benchmark_testlib.cc
index eef32e799e..72bc37d435 100644
--- a/tensorflow/core/common_runtime/kernel_benchmark_testlib.cc
+++ b/tensorflow/core/common_runtime/kernel_benchmark_testlib.cc
@@ -144,13 +144,13 @@ void Benchmark::RunWithArgs(
for (const auto& p : in) {
Rendezvous::ParsedKey parsed;
TF_CHECK_OK(Rendezvous::ParseKey(p.first, &parsed));
- rendez_->Send(parsed, Rendezvous::Args(), p.second, false);
+ TF_CHECK_OK(rendez_->Send(parsed, Rendezvous::Args(), p.second, false));
}
TF_CHECK_OK(exec_->Run(args));
for (const string& key : out) {
Rendezvous::ParsedKey parsed;
TF_CHECK_OK(Rendezvous::ParseKey(key, &parsed));
- rendez_->Recv(parsed, Rendezvous::Args(), &unused, &is_dead);
+ TF_CHECK_OK(rendez_->Recv(parsed, Rendezvous::Args(), &unused, &is_dead));
}
}
TF_CHECK_OK(device_->Sync());
@@ -161,13 +161,13 @@ void Benchmark::RunWithArgs(
for (const auto& p : in) {
Rendezvous::ParsedKey parsed;
TF_CHECK_OK(Rendezvous::ParseKey(p.first, &parsed));
- rendez_->Send(parsed, Rendezvous::Args(), p.second, false);
+ TF_CHECK_OK(rendez_->Send(parsed, Rendezvous::Args(), p.second, false));
}
TF_CHECK_OK(exec_->Run(args));
for (const string& key : out) {
Rendezvous::ParsedKey parsed;
TF_CHECK_OK(Rendezvous::ParseKey(key, &parsed));
- rendez_->Recv(parsed, Rendezvous::Args(), &unused, &is_dead);
+ TF_CHECK_OK(rendez_->Recv(parsed, Rendezvous::Args(), &unused, &is_dead));
}
}
diff --git a/tensorflow/core/common_runtime/optimization_registry_test.cc b/tensorflow/core/common_runtime/optimization_registry_test.cc
index 3d94fa5bee..f85b02867e 100644
--- a/tensorflow/core/common_runtime/optimization_registry_test.cc
+++ b/tensorflow/core/common_runtime/optimization_registry_test.cc
@@ -46,8 +46,7 @@ TEST(OptimizationRegistry, OptimizationPass) {
class UpdateFuncLibPass : public GraphOptimizationPass {
public:
Status Run(const GraphOptimizationPassOptions& options) {
- options.flib_def->AddFunctionDef(test::function::WXPlusB());
- return Status::OK();
+ return options.flib_def->AddFunctionDef(test::function::WXPlusB());
}
};
diff --git a/tensorflow/core/debug/debug_graph_utils.cc b/tensorflow/core/debug/debug_graph_utils.cc
index 217022759b..4e7a2b4bb8 100644
--- a/tensorflow/core/debug/debug_graph_utils.cc
+++ b/tensorflow/core/debug/debug_graph_utils.cc
@@ -37,7 +37,7 @@ DebuggerState::DebuggerState(const DebugOptions& debug_options)
DebuggerState::~DebuggerState() {
for (const string& debug_url : debug_urls_) {
- DebugIO::CloseDebugURL(debug_url);
+ DebugIO::CloseDebugURL(debug_url).IgnoreError();
}
}
@@ -177,8 +177,8 @@ Status DebugNodeInserter::InsertNodes(
const DataType src_dt = src_node->output_type(src_output_slot);
MemoryType memory_type;
- MemoryTypeForOutput(device_type, graph, src_node, src_output_slot,
- &memory_type);
+ TF_RETURN_IF_ERROR(MemoryTypeForOutput(device_type, graph, src_node,
+ src_output_slot, &memory_type));
// Create the copy node for the watched tensor.
Node* copy_node;
diff --git a/tensorflow/core/debug/debug_grpc_io_utils_test.cc b/tensorflow/core/debug/debug_grpc_io_utils_test.cc
index bb79528cc1..e33ce83438 100644
--- a/tensorflow/core/debug/debug_grpc_io_utils_test.cc
+++ b/tensorflow/core/debug/debug_grpc_io_utils_test.cc
@@ -55,8 +55,8 @@ class GrpcDebugTest : public ::testing::Test {
// Clean up server dump directory.
int64 undeleted_files = -1;
int64 undeleted_dirs = -1;
- Env::Default()->DeleteRecursively(server_client_pair->dump_root,
- &undeleted_files, &undeleted_dirs);
+ TF_CHECK_OK(Env::Default()->DeleteRecursively(
+ server_client_pair->dump_root, &undeleted_files, &undeleted_dirs));
ASSERT_EQ(0, undeleted_files);
ASSERT_EQ(0, undeleted_dirs);
@@ -85,7 +85,7 @@ TEST_F(GrpcDebugTest, AttemptToSendToNonexistentGrpcAddress) {
"Channel at the following gRPC stream URL is not ready: "
"grpc://0.0.0.0:0"));
- DebugIO::CloseDebugURL(kInvalidGrpcUrl);
+ TF_ASSERT_OK(DebugIO::CloseDebugURL(kInvalidGrpcUrl));
}
TEST_F(GrpcDebugTest, SendSingleDebugTensorViaGrpcTest) {
@@ -97,7 +97,8 @@ TEST_F(GrpcDebugTest, SendSingleDebugTensorViaGrpcTest) {
// Verify that the expected dump file exists.
std::vector<string> dump_files;
- Env::Default()->GetChildren(server_client_pair->dump_root, &dump_files);
+ TF_EXPECT_OK(
+ Env::Default()->GetChildren(server_client_pair->dump_root, &dump_files));
ASSERT_EQ(1, dump_files.size());
ASSERT_EQ(0, dump_files[0].find("prep_node_0_DebugIdentity_"));
@@ -179,7 +180,8 @@ TEST_F(GrpcDebugTest, SendMultipleDebugTensorsSynchronizedViaGrpcTest) {
// Load the dump files generated by the server upon receiving the tensors
// via the Event stream.
std::vector<string> dump_files;
- Env::Default()->GetChildren(server_client_pair->dump_root, &dump_files);
+ TF_EXPECT_OK(
+ Env::Default()->GetChildren(server_client_pair->dump_root, &dump_files));
// One prep tensor plus kSends concurrent tensors are expected.
ASSERT_EQ(1 + kSends, dump_files.size());
diff --git a/tensorflow/core/debug/debug_grpc_testlib.cc b/tensorflow/core/debug/debug_grpc_testlib.cc
index 020a348428..921a33982a 100644
--- a/tensorflow/core/debug/debug_grpc_testlib.cc
+++ b/tensorflow/core/debug/debug_grpc_testlib.cc
@@ -51,7 +51,8 @@ namespace test {
string dump_path;
DebugFileIO::DumpTensorToDir(node_name, output_slot, debug_op, tensor,
- event.wall_time(), dump_root, &dump_path);
+ event.wall_time(), dump_root, &dump_path)
+ .IgnoreError();
}
return ::grpc::Status::OK;
diff --git a/tensorflow/core/debug/debug_io_utils.cc b/tensorflow/core/debug/debug_io_utils.cc
index f4136dcaba..2e832c361b 100644
--- a/tensorflow/core/debug/debug_io_utils.cc
+++ b/tensorflow/core/debug/debug_io_utils.cc
@@ -264,7 +264,8 @@ Status DebugIO::PublishGraph(const Graph& graph,
status.Update(
DebugFileIO::DumpEventProtoToFile(event, dump_root_dir, file_name));
} else if (debug_url.find(kGrpcURLScheme) == 0) {
- DebugGrpcIO::SendEventProtoThroughGrpcStream(event, debug_url);
+ status.Update(
+ DebugGrpcIO::SendEventProtoThroughGrpcStream(event, debug_url));
}
}
@@ -331,7 +332,7 @@ Status DebugFileIO::DumpEventProtoToFile(const Event& event_proto,
std::unique_ptr<WritableFile> f = nullptr;
TF_CHECK_OK(env->NewWritableFile(file_path, &f));
- f->Append(event_str);
+ f->Append(event_str).IgnoreError();
TF_CHECK_OK(f->Close());
return Status::OK();
@@ -372,7 +373,7 @@ Status DebugFileIO::RecursiveCreateDir(Env* env, const string& dir) {
" because the path exists as a file "));
}
- env->CreateDir(dir);
+ env->CreateDir(dir).IgnoreError();
// Guard against potential race in creating directories by doing a check
// after the CreateDir call.
if (env->FileExists(dir).ok() && env->IsDirectory(dir).ok()) {
diff --git a/tensorflow/core/debug/debug_io_utils_test.cc b/tensorflow/core/debug/debug_io_utils_test.cc
index ab020517b0..df821e6ef1 100644
--- a/tensorflow/core/debug/debug_io_utils_test.cc
+++ b/tensorflow/core/debug/debug_io_utils_test.cc
@@ -150,9 +150,9 @@ TEST_F(DebugIOUtilsTest, DumpTensorToFileCannotCreateDirectory) {
std::unique_ptr<WritableFile> file;
ASSERT_TRUE(env_->NewWritableFile(txt_file_name, &file).ok());
- file->Append("text in baz");
- file->Flush();
- file->Close();
+ TF_EXPECT_OK(file->Append("text in baz"));
+ TF_EXPECT_OK(file->Flush());
+ TF_ASSERT_OK(file->Close());
// Verify that the path exists and that it is a file, not a directory.
ASSERT_TRUE(env_->FileExists(txt_file_name).ok());
diff --git a/tensorflow/core/distributed_runtime/graph_mgr.cc b/tensorflow/core/distributed_runtime/graph_mgr.cc
index 13ca471f46..8afbd18a82 100644
--- a/tensorflow/core/distributed_runtime/graph_mgr.cc
+++ b/tensorflow/core/distributed_runtime/graph_mgr.cc
@@ -439,7 +439,8 @@ void GraphMgr::BuildCostModel(Item* item, StepStatsCollector* collector,
if (cost_graph != nullptr) {
for (const auto& unit : item->units) {
- cost_model_manager_.AddToCostGraphDef(unit.graph, cost_graph);
+ cost_model_manager_.AddToCostGraphDef(unit.graph, cost_graph)
+ .IgnoreError();
}
}
}
diff --git a/tensorflow/core/distributed_runtime/master.cc b/tensorflow/core/distributed_runtime/master.cc
index 23fe908d43..e6c9aae11b 100644
--- a/tensorflow/core/distributed_runtime/master.cc
+++ b/tensorflow/core/distributed_runtime/master.cc
@@ -101,7 +101,7 @@ void Master::GC() {
<< "Note that if you are starting multiple replicas "
<< "on a staggered delay, session_gc_seconds may need "
<< "to be raised.";
- sess->Close();
+ sess->Close().IgnoreError();
sess->Unref();
});
}
@@ -297,7 +297,7 @@ void Master::CreateSession(const CreateSessionRequest* req,
const_cast<CreateSessionRequest*>(req)->mutable_graph_def();
Status create_status = session->Create(gdef);
if (!create_status.ok()) {
- session->Close();
+ session->Close().IgnoreError();
session->Unref();
done(create_status);
return;
diff --git a/tensorflow/core/distributed_runtime/message_wrappers_test.cc b/tensorflow/core/distributed_runtime/message_wrappers_test.cc
index 00ccec4fdf..4c3394712b 100644
--- a/tensorflow/core/distributed_runtime/message_wrappers_test.cc
+++ b/tensorflow/core/distributed_runtime/message_wrappers_test.cc
@@ -16,6 +16,7 @@ limitations under the License.
#include "tensorflow/core/distributed_runtime/message_wrappers.h"
#include "tensorflow/core/framework/tensor_testutil.h"
+#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/platform/test.h"
namespace tensorflow {
@@ -51,9 +52,9 @@ static void CheckRunStepRequest(const RunStepRequestWrapper& request) {
EXPECT_EQ("feed_a:0", request.feed_name(0));
EXPECT_EQ("feed_b:0", request.feed_name(1));
Tensor val;
- request.FeedValue(0, &val);
+ TF_EXPECT_OK(request.FeedValue(0, &val));
test::ExpectTensorEqual<int32>(TensorA(), val);
- request.FeedValue(1, &val);
+ TF_EXPECT_OK(request.FeedValue(1, &val));
test::ExpectTensorEqual<int32>(TensorB(), val);
EXPECT_EQ(2, request.num_fetches());
@@ -70,8 +71,10 @@ static void BuildRunGraphRequest(
run_graph_request->set_graph_handle("graph_handle");
run_graph_request->set_step_id(13);
run_graph_request->mutable_exec_opts()->set_record_timeline(true);
- run_graph_request->AddSendFromRunStepRequest(run_step_request, 0, "send_0");
- run_graph_request->AddSendFromRunStepRequest(run_step_request, 1, "send_1");
+ TF_EXPECT_OK(run_graph_request->AddSendFromRunStepRequest(run_step_request, 0,
+ "send_0"));
+ TF_EXPECT_OK(run_graph_request->AddSendFromRunStepRequest(run_step_request, 1,
+ "send_1"));
run_graph_request->add_recv_key("recv_2");
run_graph_request->add_recv_key("recv_3");
run_graph_request->set_is_partial(true);
@@ -84,9 +87,9 @@ static void CheckRunGraphRequest(const RunGraphRequestWrapper& request) {
EXPECT_TRUE(request.exec_opts().record_timeline());
EXPECT_EQ(2, request.num_sends());
Tensor val;
- request.SendValue(0, &val);
+ TF_EXPECT_OK(request.SendValue(0, &val));
test::ExpectTensorEqual<int32>(TensorA(), val);
- request.SendValue(1, &val);
+ TF_EXPECT_OK(request.SendValue(1, &val));
test::ExpectTensorEqual<int32>(TensorB(), val);
EXPECT_TRUE(request.is_partial());
EXPECT_FALSE(request.is_last_partial_run());
@@ -106,9 +109,9 @@ static void CheckRunGraphResponse(MutableRunGraphResponseWrapper* response) {
EXPECT_EQ("recv_2", response->recv_key(0));
EXPECT_EQ("recv_3", response->recv_key(1));
Tensor val;
- response->RecvValue(0, &val);
+ TF_EXPECT_OK(response->RecvValue(0, &val));
test::ExpectTensorEqual<int32>(TensorA(), val);
- response->RecvValue(1, &val);
+ TF_EXPECT_OK(response->RecvValue(1, &val));
test::ExpectTensorEqual<int32>(TensorB(), val);
EXPECT_EQ(1, response->mutable_step_stats()->dev_stats_size());
EXPECT_EQ("/cpu:0", response->mutable_step_stats()->dev_stats(0).device());
@@ -119,10 +122,10 @@ static void CheckRunGraphResponse(MutableRunGraphResponseWrapper* response) {
static void BuildRunStepResponse(
MutableRunGraphResponseWrapper* run_graph_response,
MutableRunStepResponseWrapper* run_step_response) {
- run_step_response->AddTensorFromRunGraphResponse("fetch_x:0",
- run_graph_response, 0);
- run_step_response->AddTensorFromRunGraphResponse("fetch_y:0",
- run_graph_response, 1);
+ TF_EXPECT_OK(run_step_response->AddTensorFromRunGraphResponse(
+ "fetch_x:0", run_graph_response, 0));
+ TF_EXPECT_OK(run_step_response->AddTensorFromRunGraphResponse(
+ "fetch_y:0", run_graph_response, 1));
*run_step_response->mutable_metadata()->mutable_step_stats() =
*run_graph_response->mutable_step_stats();
}
@@ -133,9 +136,9 @@ static void CheckRunStepResponse(
EXPECT_EQ("fetch_x:0", response.tensor_name(0));
EXPECT_EQ("fetch_y:0", response.tensor_name(1));
Tensor val;
- response.TensorValue(0, &val);
+ TF_EXPECT_OK(response.TensorValue(0, &val));
test::ExpectTensorEqual<int32>(TensorA(), val);
- response.TensorValue(1, &val);
+ TF_EXPECT_OK(response.TensorValue(1, &val));
test::ExpectTensorEqual<int32>(TensorB(), val);
EXPECT_EQ(1, response.metadata().step_stats().dev_stats_size());
EXPECT_EQ("/cpu:0", response.metadata().step_stats().dev_stats(0).device());
diff --git a/tensorflow/core/distributed_runtime/rpc/grpc_channel_test.cc b/tensorflow/core/distributed_runtime/rpc/grpc_channel_test.cc
index 4e8028b74f..1d09b2ffb2 100644
--- a/tensorflow/core/distributed_runtime/rpc/grpc_channel_test.cc
+++ b/tensorflow/core/distributed_runtime/rpc/grpc_channel_test.cc
@@ -18,6 +18,7 @@ limitations under the License.
#include <string>
#include <vector>
+#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/util/device_name_utils.h"
@@ -56,7 +57,8 @@ TEST(GrpcChannelTest, IsSameAddressSpace) {
TEST(GrpcChannelTest, HostPorts) {
GrpcChannelSpec spec;
- spec.AddHostPortsJob("mnist", {"a:1", "b:2", "c:3", "d:4", "e:5", "f:6"});
+ TF_EXPECT_OK(spec.AddHostPortsJob(
+ "mnist", {"a:1", "b:2", "c:3", "d:4", "e:5", "f:6"}));
std::unique_ptr<GrpcChannelCache> cc(
NewGrpcChannelCache(spec, NewHostPortGrpcChannel));
EXPECT_EQ(nullptr, cc->FindWorkerChannel("invalid_target"));
@@ -96,7 +98,8 @@ TEST(GrpcChannelTest, HostPorts) {
TEST(GrpcChannelTest, SparseHostPorts) {
GrpcChannelSpec spec;
- spec.AddHostPortsJob("mnist", {{0, "a:1"}, {3, "d:4"}, {4, "e:5"}});
+ TF_EXPECT_OK(
+ spec.AddHostPortsJob("mnist", {{0, "a:1"}, {3, "d:4"}, {4, "e:5"}}));
std::unique_ptr<GrpcChannelCache> cc(
NewGrpcChannelCache(spec, NewHostPortGrpcChannel));
EXPECT_EQ(nullptr, cc->FindWorkerChannel("invalid_target"));
diff --git a/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc b/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc
index d2d2bfceff..c32197536a 100644
--- a/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc
+++ b/tensorflow/core/distributed_runtime/rpc/grpc_server_lib.cc
@@ -190,7 +190,7 @@ Status GrpcServer::Init() {
host_port = task.second;
}
}
- channel_spec.AddHostPortsJob(job.name(), host_ports);
+ TF_RETURN_IF_ERROR(channel_spec.AddHostPortsJob(job.name(), host_ports));
}
std::unique_ptr<GrpcChannelCache> channel_cache(NewGrpcChannelCache(
diff --git a/tensorflow/core/distributed_runtime/rpc/grpc_tensorflow_server.cc b/tensorflow/core/distributed_runtime/rpc/grpc_tensorflow_server.cc
index 1c7bb4375c..569fb5628a 100644
--- a/tensorflow/core/distributed_runtime/rpc/grpc_tensorflow_server.cc
+++ b/tensorflow/core/distributed_runtime/rpc/grpc_tensorflow_server.cc
@@ -120,7 +120,7 @@ int main(int argc, char* argv[]) {
return -1;
}
std::unique_ptr<tensorflow::ServerInterface> server;
- tensorflow::NewServer(server_def, &server);
- server->Start();
- server->Join();
+ TF_QCHECK_OK(tensorflow::NewServer(server_def, &server));
+ TF_QCHECK_OK(server->Start());
+ TF_QCHECK_OK(server->Join());
}
diff --git a/tensorflow/core/distributed_runtime/rpc/grpc_testlib_server.cc b/tensorflow/core/distributed_runtime/rpc/grpc_testlib_server.cc
index 6b7f6f915b..016d051056 100644
--- a/tensorflow/core/distributed_runtime/rpc/grpc_testlib_server.cc
+++ b/tensorflow/core/distributed_runtime/rpc/grpc_testlib_server.cc
@@ -111,8 +111,8 @@ int main(int argc, char* argv[]) {
LOG(ERROR) << "Could not create server: " << s.error_message();
return -1;
}
- svr->Start();
- svr->Join();
+ TF_QCHECK_OK(svr->Start());
+ TF_QCHECK_OK(svr->Join());
// NOTE(mrry): Unreachable code.
return 0;
diff --git a/tensorflow/core/distributed_runtime/rpcbench_test.cc b/tensorflow/core/distributed_runtime/rpcbench_test.cc
index 866953ee4b..3d2b1894b8 100644
--- a/tensorflow/core/distributed_runtime/rpcbench_test.cc
+++ b/tensorflow/core/distributed_runtime/rpcbench_test.cc
@@ -84,8 +84,8 @@ void MakeGRPCCluster(const SessionOptions& options, int n,
std::unique_ptr<ServerInterface> svr;
TF_CHECK_OK(NewServer(server, &svr));
- svr->Start();
- svr->Join();
+ TF_CHECK_OK(svr->Start());
+ TF_CHECK_OK(svr->Join());
});
}
diff --git a/tensorflow/core/distributed_runtime/worker.cc b/tensorflow/core/distributed_runtime/worker.cc
index e59e880af3..0d6ccceef0 100644
--- a/tensorflow/core/distributed_runtime/worker.cc
+++ b/tensorflow/core/distributed_runtime/worker.cc
@@ -172,7 +172,7 @@ void Worker::DoRunGraph(CallOptions* opts, RunGraphRequestWrapper* request,
cost_graph, cm, in, [this, step_id, response, cm, out, token, collector,
opts, done](Status s) {
if (s.ok()) {
- env_->graph_mgr->RecvOutputs(step_id, out);
+ s = env_->graph_mgr->RecvOutputs(step_id, out);
}
opts->ClearCancelCallback();
{
diff --git a/tensorflow/core/example/example_parser_configuration_test.cc b/tensorflow/core/example/example_parser_configuration_test.cc
index 0fa772bd6b..6206d2bd51 100644
--- a/tensorflow/core/example/example_parser_configuration_test.cc
+++ b/tensorflow/core/example/example_parser_configuration_test.cc
@@ -16,6 +16,7 @@ limitations under the License.
#include "tensorflow/core/example/example.pb.h"
#include "tensorflow/core/framework/tensor_testutil.h"
+#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/lib/io/path.h"
#include "tensorflow/core/platform/protobuf.h"
#include "tensorflow/core/platform/test.h"
@@ -44,7 +45,7 @@ class ExtractExampleParserConfigurationTest : public ::testing::Test {
ReadFileToStringOrDie(Env::Default(), filename, &proto_string);
protobuf::TextFormat::ParseFromString(proto_string, &graph_def_);
session_.reset(CreateSession());
- session_->Create(graph_def_);
+ TF_CHECK_OK(session_->Create(graph_def_));
}
NodeDef* parse_example_node() {
@@ -194,8 +195,8 @@ class ExampleParserConfigurationProtoToFeatureVectorsTest
TEST_F(ExampleParserConfigurationProtoToFeatureVectorsTest, Basic) {
std::vector<FixedLenFeature> fixed_len_features;
std::vector<VarLenFeature> var_len_features;
- ExampleParserConfigurationProtoToFeatureVectors(
- config_proto_, &fixed_len_features, &var_len_features);
+ TF_ASSERT_OK(ExampleParserConfigurationProtoToFeatureVectors(
+ config_proto_, &fixed_len_features, &var_len_features));
ASSERT_EQ(1, fixed_len_features.size());
ASSERT_EQ(1, var_len_features.size());
diff --git a/tensorflow/core/framework/node_def_builder_test.cc b/tensorflow/core/framework/node_def_builder_test.cc
index 861ad9d7d0..196e5e46ed 100644
--- a/tensorflow/core/framework/node_def_builder_test.cc
+++ b/tensorflow/core/framework/node_def_builder_test.cc
@@ -155,7 +155,8 @@ TEST_F(NodeDefBuilderTest, Simple) {
{ // Finalize() twice.
NodeDefBuilder& builder = Builder();
- builder.Input(FakeInput()).Finalize(nullptr); // First call to Finalize()
+ // First call to Finalize()
+ TF_EXPECT_OK(builder.Input(FakeInput()).Finalize(nullptr));
// ExpectSuccess() also calls Finalize().
ExpectSuccess(builder, {DT_INT32}, {DT_FLOAT}, R"proto(
op: "Simple" input: "a" )proto");
diff --git a/tensorflow/core/framework/op_kernel.cc b/tensorflow/core/framework/op_kernel.cc
index 4b50386e94..b35e4ac243 100644
--- a/tensorflow/core/framework/op_kernel.cc
+++ b/tensorflow/core/framework/op_kernel.cc
@@ -738,7 +738,7 @@ Status FindKernelRegistration(DeviceType device_type, const NodeDef& node_def,
*reg = nullptr;
*was_attr_mismatch = false;
string label; // Label defaults to empty if not found in NodeDef.
- GetNodeAttr(node_def, "_kernel", &label);
+ GetNodeAttr(node_def, "_kernel", &label).IgnoreError();
const string key = Key(node_def.op(), device_type, label);
auto regs = GlobalKernelRegistryTyped()->equal_range(key);
for (auto iter = regs.first; iter != regs.second; ++iter) {
diff --git a/tensorflow/core/framework/op_registration_test.cc b/tensorflow/core/framework/op_registration_test.cc
index 9ef55bcf9a..665b1bf33c 100644
--- a/tensorflow/core/framework/op_registration_test.cc
+++ b/tensorflow/core/framework/op_registration_test.cc
@@ -17,6 +17,7 @@ limitations under the License.
#include "tensorflow/core/framework/op.h"
+#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/platform/test.h"
namespace tensorflow {
@@ -47,10 +48,11 @@ TEST(OpRegistrationTest, TestDuplicate) {
Status s = registry->ProcessRegistrations();
EXPECT_TRUE(s.ok());
- registry->SetWatcher([](const Status& s, const OpDef& op_def) -> Status {
- EXPECT_TRUE(errors::IsAlreadyExists(s));
- return Status::OK();
- });
+ TF_EXPECT_OK(
+ registry->SetWatcher([](const Status& s, const OpDef& op_def) -> Status {
+ EXPECT_TRUE(errors::IsAlreadyExists(s));
+ return Status::OK();
+ }));
Register("Foo", registry.get());
s = registry->ProcessRegistrations();
EXPECT_TRUE(s.ok());
diff --git a/tensorflow/core/framework/shape_inference.cc b/tensorflow/core/framework/shape_inference.cc
index 02fdc16e88..1e985c872a 100644
--- a/tensorflow/core/framework/shape_inference.cc
+++ b/tensorflow/core/framework/shape_inference.cc
@@ -92,7 +92,8 @@ Status InferenceContext::set_output(StringPiece output_name,
const int start = result->second.first;
const int size = result->second.second - start;
if (size != shapes.size()) {
- errors::InvalidArgument("Must have exactly ", shapes.size(), " shapes.");
+ return errors::InvalidArgument("Must have exactly ", shapes.size(),
+ " shapes.");
}
for (int i = 0; i < size; ++i) {
outputs_[i + start] = shapes[i];
diff --git a/tensorflow/core/graph/equal_graph_def_test.cc b/tensorflow/core/graph/equal_graph_def_test.cc
index 6f1fce27e2..b10446cf8b 100644
--- a/tensorflow/core/graph/equal_graph_def_test.cc
+++ b/tensorflow/core/graph/equal_graph_def_test.cc
@@ -19,6 +19,7 @@ limitations under the License.
#include "tensorflow/core/framework/op.h"
#include "tensorflow/core/graph/graph_def_builder.h"
#include "tensorflow/core/kernels/ops_util.h"
+#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/platform/test.h"
#include "tensorflow/core/public/version.h"
@@ -51,9 +52,9 @@ class EqualGraphDefTest : public ::testing::Test {
bool Match() {
GraphDef expected;
- e_.ToGraphDef(&expected);
+ TF_EXPECT_OK(e_.ToGraphDef(&expected));
GraphDef actual;
- a_.ToGraphDef(&actual);
+ TF_EXPECT_OK(a_.ToGraphDef(&actual));
return EqualGraphDef(actual, expected, &diff_);
}
diff --git a/tensorflow/core/graph/graph_constructor_test.cc b/tensorflow/core/graph/graph_constructor_test.cc
index 9ce7a0fdf8..7f4cc28a2d 100644
--- a/tensorflow/core/graph/graph_constructor_test.cc
+++ b/tensorflow/core/graph/graph_constructor_test.cc
@@ -25,6 +25,7 @@ limitations under the License.
#include "tensorflow/core/graph/node_builder.h"
#include "tensorflow/core/kernels/ops_util.h"
#include "tensorflow/core/lib/core/status.h"
+#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/lib/strings/strcat.h"
#include "tensorflow/core/platform/logging.h"
@@ -1430,7 +1431,8 @@ TEST_F(GraphConstructorTest, ImportGraphDef_ControlDepsErrors) {
TEST_F(GraphConstructorTest, ImportGraphDef_ErrorsDoNoChangeTheGraph) {
GraphDef def;
- NodeDefBuilder("scope/A", "TestParams").Finalize(def.add_node());
+ TF_EXPECT_OK(
+ NodeDefBuilder("scope/A", "TestParams").Finalize(def.add_node()));
ImportGraphDefOptions opts;
const string& source = graph_.FindNodeId(Graph::kSourceId)->name();
const string& sink = graph_.FindNodeId(Graph::kSinkId)->name();
diff --git a/tensorflow/core/graph/graph_partition_test.cc b/tensorflow/core/graph/graph_partition_test.cc
index 6d69fcd0a4..02d368ddb5 100644
--- a/tensorflow/core/graph/graph_partition_test.cc
+++ b/tensorflow/core/graph/graph_partition_test.cc
@@ -170,20 +170,20 @@ class GraphPartitionTest : public ::testing::Test {
"/job:a/replica:0/task:0/cpu:1")) {}
const GraphDef& ToGraphDef() {
- in_.ToGraphDef(&in_graph_def_);
+ TF_EXPECT_OK(in_.ToGraphDef(&in_graph_def_));
return in_graph_def_;
}
void ExpectMatchA() {
GraphDef graph_def;
- scope_a_.ToGraphDef(&graph_def);
+ TF_EXPECT_OK(scope_a_.ToGraphDef(&graph_def));
string a = "/job:a/replica:0/task:0/cpu:0";
TF_EXPECT_GRAPH_EQ(graph_def, partitions_[a]);
}
void ExpectMatchB() {
GraphDef graph_def;
- scope_b_.ToGraphDef(&graph_def);
+ TF_EXPECT_OK(scope_b_.ToGraphDef(&graph_def));
string b = "/job:a/replica:0/task:0/cpu:1";
TF_EXPECT_GRAPH_EQ(graph_def, partitions_[b]);
}
diff --git a/tensorflow/core/kernels/adjust_contrast_op_benchmark_test.cc b/tensorflow/core/kernels/adjust_contrast_op_benchmark_test.cc
index f8da54b9db..ffd47406eb 100644
--- a/tensorflow/core/kernels/adjust_contrast_op_benchmark_test.cc
+++ b/tensorflow/core/kernels/adjust_contrast_op_benchmark_test.cc
@@ -29,10 +29,10 @@ static Graph* BM_AdjustContrast(int batches, int width, int height) {
factor.flat<float>().setConstant(1.2);
Node* ret;
- NodeBuilder(g->NewName("n"), "AdjustContrastv2")
- .Input(test::graph::Constant(g, in))
- .Input(test::graph::Constant(g, factor))
- .Finalize(g, &ret);
+ TF_CHECK_OK(NodeBuilder(g->NewName("n"), "AdjustContrastv2")
+ .Input(test::graph::Constant(g, in))
+ .Input(test::graph::Constant(g, factor))
+ .Finalize(g, &ret));
return g;
}
diff --git a/tensorflow/core/kernels/cloud/bigquery_table_accessor_test.cc b/tensorflow/core/kernels/cloud/bigquery_table_accessor_test.cc
index 57a4b89251..7591f9cfd5 100644
--- a/tensorflow/core/kernels/cloud/bigquery_table_accessor_test.cc
+++ b/tensorflow/core/kernels/cloud/bigquery_table_accessor_test.cc
@@ -387,7 +387,7 @@ TEST_F(BigQueryTableAccessorTest, SwitchingPartitionsTest) {
partition.set_start_index(3);
partition.set_end_index(-1);
- accessor_->SetPartition(partition);
+ TF_EXPECT_OK(accessor_->SetPartition(partition));
TF_EXPECT_OK(accessor_->ReadRow(&row_id, &example));
EXPECT_EQ(3, row_id);
EXPECT_TRUE(accessor_->Done());
@@ -396,7 +396,7 @@ TEST_F(BigQueryTableAccessorTest, SwitchingPartitionsTest) {
partition.set_start_index(0);
partition.set_end_index(1);
- accessor_->SetPartition(partition);
+ TF_EXPECT_OK(accessor_->SetPartition(partition));
TF_EXPECT_OK(accessor_->ReadRow(&row_id, &example));
EXPECT_EQ(0, row_id);
EXPECT_FALSE(accessor_->Done());
diff --git a/tensorflow/core/kernels/control_flow_ops_test.cc b/tensorflow/core/kernels/control_flow_ops_test.cc
index 301609e04d..07b8937a60 100644
--- a/tensorflow/core/kernels/control_flow_ops_test.cc
+++ b/tensorflow/core/kernels/control_flow_ops_test.cc
@@ -105,7 +105,7 @@ TEST_F(AbortOpTest, pass_error_msg) {
.Attr("error_msg", "abort_op_test")
.Finalize(node_def()));
TF_ASSERT_OK(InitOp());
- EXPECT_EXIT(RunOpKernel(), KilledBySignal(SIGABRT),
+ EXPECT_EXIT(RunOpKernel().IgnoreError(), KilledBySignal(SIGABRT),
"Abort_op intentional failure; abort_op_test");
}
@@ -113,7 +113,7 @@ TEST_F(AbortOpTest, pass_error_msg) {
TEST_F(AbortOpTest, default_msg) {
TF_ASSERT_OK(NodeDefBuilder("abort_op", "Abort").Finalize(node_def()));
TF_ASSERT_OK(InitOp());
- EXPECT_EXIT(RunOpKernel(), KilledBySignal(SIGABRT),
+ EXPECT_EXIT(RunOpKernel().IgnoreError(), KilledBySignal(SIGABRT),
"Abort_op intentional failure; ");
}
@@ -123,7 +123,7 @@ TEST_F(AbortOpTest, exit_normally) {
.Attr("exit_without_error", true)
.Finalize(node_def()));
TF_ASSERT_OK(InitOp());
- EXPECT_EXIT(RunOpKernel(), ::testing::ExitedWithCode(0), "");
+ EXPECT_EXIT(RunOpKernel().IgnoreError(), ::testing::ExitedWithCode(0), "");
}
} // namespace
diff --git a/tensorflow/core/kernels/conv_grad_ops.cc b/tensorflow/core/kernels/conv_grad_ops.cc
index 8b6a4ac369..cf2e6459d4 100644
--- a/tensorflow/core/kernels/conv_grad_ops.cc
+++ b/tensorflow/core/kernels/conv_grad_ops.cc
@@ -85,7 +85,8 @@ Status Conv2DBackpropComputeDimensions(
return errors::InvalidArgument(label, ": filter must be 4-dimensional");
}
if (out_backprop_shape.dims() != 4) {
- errors::InvalidArgument(label, ": out_backprop must be 4-dimensional");
+ return errors::InvalidArgument(label,
+ ": out_backprop must be 4-dimensional");
}
dims->batch_size = GetTensorDim(input_shape, data_format, 'N');
if (dims->batch_size != GetTensorDim(out_backprop_shape, data_format, 'N')) {
diff --git a/tensorflow/core/kernels/decode_csv_op.cc b/tensorflow/core/kernels/decode_csv_op.cc
index 4e19ce89ee..4710d3a286 100644
--- a/tensorflow/core/kernels/decode_csv_op.cc
+++ b/tensorflow/core/kernels/decode_csv_op.cc
@@ -62,7 +62,7 @@ class DecodeCSVOp : public OpKernel {
for (int i = 0; i < static_cast<int>(out_type_.size()); ++i) {
Tensor* out = nullptr;
- output.allocate(i, records->shape(), &out);
+ OP_REQUIRES_OK(ctx, output.allocate(i, records->shape(), &out));
}
for (int64 i = 0; i < records_size; ++i) {
diff --git a/tensorflow/core/kernels/example_parsing_ops.cc b/tensorflow/core/kernels/example_parsing_ops.cc
index f4c4460fa4..e0cc08f101 100644
--- a/tensorflow/core/kernels/example_parsing_ops.cc
+++ b/tensorflow/core/kernels/example_parsing_ops.cc
@@ -353,7 +353,7 @@ class SingleSequenceExampleParserOp : public OpKernel {
for (const int dim : attrs_.context_dense_shapes[d].dim_sizes())
out_shape.AddDim(dim);
Tensor* out = nullptr;
- context_dense_values.allocate(d, out_shape, &out);
+ OP_REQUIRES_OK(ctx, context_dense_values.allocate(d, out_shape, &out));
}
for (int d = 0; d < attrs_.num_context_dense; ++d) {
@@ -411,9 +411,11 @@ class SingleSequenceExampleParserOp : public OpKernel {
TensorShape indices_shape({num_elements, 1});
Tensor* sp_indices_d = nullptr;
Tensor* sp_shape_d = nullptr;
- context_sparse_indices.allocate(d, indices_shape, &sp_indices_d);
+ OP_REQUIRES_OK(ctx, context_sparse_indices.allocate(d, indices_shape,
+ &sp_indices_d));
context_sparse_values.set(d, feature_values);
- context_sparse_shapes.allocate(d, TensorShape({1}), &sp_shape_d);
+ OP_REQUIRES_OK(ctx, context_sparse_shapes.allocate(d, TensorShape({1}),
+ &sp_shape_d));
auto shape_t = sp_shape_d->vec<int64>();
shape_t(0) = num_elements;
auto indices_t = sp_indices_d->matrix<int64>();
@@ -424,9 +426,12 @@ class SingleSequenceExampleParserOp : public OpKernel {
Tensor* sp_indices_d = nullptr;
Tensor* sp_values_d = nullptr;
Tensor* sp_shape_d = nullptr;
- context_sparse_indices.allocate(d, indices_shape, &sp_indices_d);
- context_sparse_values.allocate(d, values_shape, &sp_values_d);
- context_sparse_shapes.allocate(d, TensorShape({1}), &sp_shape_d);
+ OP_REQUIRES_OK(ctx, context_sparse_indices.allocate(d, indices_shape,
+ &sp_indices_d));
+ OP_REQUIRES_OK(
+ ctx, context_sparse_values.allocate(d, values_shape, &sp_values_d));
+ OP_REQUIRES_OK(ctx, context_sparse_shapes.allocate(d, TensorShape({1}),
+ &sp_shape_d));
auto shape_t = sp_shape_d->vec<int64>();
shape_t(0) = 0;
}
@@ -468,7 +473,8 @@ class SingleSequenceExampleParserOp : public OpKernel {
out_shape.AddDim(dim);
}
Tensor* out = nullptr;
- feature_list_dense_values.allocate(d, out_shape, &out);
+ OP_REQUIRES_OK(ctx,
+ feature_list_dense_values.allocate(d, out_shape, &out));
for (int64 t = 0; t < fl.feature_size(); ++t) {
const Feature& f = fl.feature(t);
@@ -530,9 +536,12 @@ class SingleSequenceExampleParserOp : public OpKernel {
Tensor* sp_indices_d = nullptr;
Tensor* sp_values_d = nullptr;
Tensor* sp_shape_d = nullptr;
- feature_list_sparse_indices.allocate(d, indices_shape, &sp_indices_d);
- feature_list_sparse_values.allocate(d, values_shape, &sp_values_d);
- feature_list_sparse_shapes.allocate(d, TensorShape({2}), &sp_shape_d);
+ OP_REQUIRES_OK(ctx, feature_list_sparse_indices.allocate(d, indices_shape,
+ &sp_indices_d));
+ OP_REQUIRES_OK(ctx, feature_list_sparse_values.allocate(d, values_shape,
+ &sp_values_d));
+ OP_REQUIRES_OK(ctx, feature_list_sparse_shapes.allocate(
+ d, TensorShape({2}), &sp_shape_d));
auto shape_t = sp_shape_d->vec<int64>();
shape_t(0) = feature_list_size;
shape_t(1) = max_num_features;
diff --git a/tensorflow/core/kernels/fifo_queue.cc b/tensorflow/core/kernels/fifo_queue.cc
index 9acf8cbd2d..c426efc7f9 100644
--- a/tensorflow/core/kernels/fifo_queue.cc
+++ b/tensorflow/core/kernels/fifo_queue.cc
@@ -229,7 +229,13 @@ void FIFOQueue::TryDequeueMany(int num_elements, OpKernelContext* ctx,
// an optimized case where the queue 'knows' what attributes to
// use, and plumbs them through here.
Tensor element;
- ctx->allocate_temp(component_dtypes_[i], ManyOutShape(i, 0), &element);
+ Status status = ctx->allocate_temp(component_dtypes_[i],
+ ManyOutShape(i, 0), &element);
+ if (!status.ok()) {
+ ctx->SetStatus(status);
+ callback(Tuple());
+ return;
+ }
tuple.emplace_back(element);
}
callback(tuple);
@@ -309,8 +315,10 @@ void FIFOQueue::TryDequeueMany(int num_elements, OpKernelContext* ctx,
const TensorShape shape =
ManyOutShape(i, attempt->elements_requested);
Tensor element;
- attempt->context->allocate_temp(component_dtypes_[i],
- shape, &element);
+ attempt->context->SetStatus(
+ attempt->context->allocate_temp(component_dtypes_[i],
+ shape, &element));
+ if (!attempt->context->status().ok()) return kComplete;
attempt->tuple.emplace_back(element);
}
}
diff --git a/tensorflow/core/kernels/hexagon/graph_transfer_utils.cc b/tensorflow/core/kernels/hexagon/graph_transfer_utils.cc
index a41935b31b..c44ef2cc02 100644
--- a/tensorflow/core/kernels/hexagon/graph_transfer_utils.cc
+++ b/tensorflow/core/kernels/hexagon/graph_transfer_utils.cc
@@ -95,7 +95,7 @@ GraphTransferUtils::GetTopNFloatResults(const float* const data,
CHECK(scope.ok());
GraphDef fusedGraphDef;
- root.ToGraphDef(&fusedGraphDef);
+ TF_CHECK_OK(root.ToGraphDef(&fusedGraphDef));
return fusedGraphDef;
}
diff --git a/tensorflow/core/kernels/hexagon/graph_transferer.cc b/tensorflow/core/kernels/hexagon/graph_transferer.cc
index 5b7eb9eb68..826adbabee 100644
--- a/tensorflow/core/kernels/hexagon/graph_transferer.cc
+++ b/tensorflow/core/kernels/hexagon/graph_transferer.cc
@@ -606,15 +606,15 @@ void GraphTransferer::RegisterNodeWithPaddingAndStrides(
CHECK_GT(node.def().attr().count(PADDING_ATTR_NAME), 0);
// TODO(satok): Use context->GetAttr(...) instead?
Padding padding;
- context->GetAttr(PADDING_ATTR_NAME, &padding);
+ TF_CHECK_OK(context->GetAttr(PADDING_ATTR_NAME, &padding));
CHECK_GT(node.def().attr().count(STRIDES_ATTR_NAME), 0);
std::vector<int32> strides;
- context->GetAttr(STRIDES_ATTR_NAME, &strides);
+ TF_CHECK_OK(context->GetAttr(STRIDES_ATTR_NAME, &strides));
const int stride_id = RegisterConstantShape(strides);
std::vector<int> extra_inputs{stride_id};
if (node.def().attr().count(KSIZE_ATTR_NAME) > 0) {
std::vector<int32> kernel_sizes;
- context->GetAttr(KSIZE_ATTR_NAME, &kernel_sizes);
+ TF_CHECK_OK(context->GetAttr(KSIZE_ATTR_NAME, &kernel_sizes));
const int ksize_id = RegisterConstantShape(kernel_sizes);
extra_inputs.insert(extra_inputs.begin(), ksize_id);
}
diff --git a/tensorflow/core/kernels/padding_fifo_queue.cc b/tensorflow/core/kernels/padding_fifo_queue.cc
index 07902cd48b..c664d7eaf5 100644
--- a/tensorflow/core/kernels/padding_fifo_queue.cc
+++ b/tensorflow/core/kernels/padding_fifo_queue.cc
@@ -76,7 +76,8 @@ void PaddingFIFOQueue::TryDequeueMany(int num_elements, OpKernelContext* ctx,
Tensor element;
// Here, ManyOutShape returns zeros for undetermined shapes,
// which is exactly what we want to use.
- ctx->allocate_temp(component_dtypes_[i], ManyOutShape(i, 0), &element);
+ OP_REQUIRES_OK(ctx, ctx->allocate_temp(component_dtypes_[i],
+ ManyOutShape(i, 0), &element));
tuple.emplace_back(element);
}
callback(tuple);
@@ -179,8 +180,9 @@ void PaddingFIFOQueue::TryDequeueMany(int num_elements, OpKernelContext* ctx,
}
Tensor element;
- attempt->context->allocate_temp(component_dtypes_[i], shape,
- &element);
+ attempt->context->SetStatus(attempt->context->allocate_temp(
+ component_dtypes_[i], shape, &element));
+ if (!attempt->context->status().ok()) return kComplete;
bool has_dynamic_shape = !partial_shape.IsFullyDefined();
if (has_dynamic_shape) {
diff --git a/tensorflow/core/kernels/priority_queue.cc b/tensorflow/core/kernels/priority_queue.cc
index 85749a2954..8884c0c4a0 100644
--- a/tensorflow/core/kernels/priority_queue.cc
+++ b/tensorflow/core/kernels/priority_queue.cc
@@ -272,7 +272,13 @@ void PriorityQueue::TryDequeueMany(int num_elements, OpKernelContext* ctx,
// an optimized case where the queue 'knows' what attributes to
// use, and plumbs them through here.
Tensor element;
- ctx->allocate_temp(component_dtypes_[i], ManyOutShape(i, 0), &element);
+ Status status = ctx->allocate_temp(component_dtypes_[i],
+ ManyOutShape(i, 0), &element);
+ if (!status.ok()) {
+ ctx->SetStatus(status);
+ callback(Tuple());
+ return;
+ }
tuple.emplace_back(element);
}
callback(tuple);
@@ -339,8 +345,9 @@ void PriorityQueue::TryDequeueMany(int num_elements, OpKernelContext* ctx,
const TensorShape shape =
ManyOutShape(i, attempt->elements_requested);
Tensor element;
- attempt->context->allocate_temp(component_dtypes_[i], shape,
- &element);
+ attempt->context->SetStatus(attempt->context->allocate_temp(
+ component_dtypes_[i], shape, &element));
+ if (!attempt->context->status().ok()) return kComplete;
attempt->tuple.emplace_back(element);
}
}
diff --git a/tensorflow/core/kernels/quantize_and_dequantize_op_test.cc b/tensorflow/core/kernels/quantize_and_dequantize_op_test.cc
index 92b24a424c..33dd3915c0 100644
--- a/tensorflow/core/kernels/quantize_and_dequantize_op_test.cc
+++ b/tensorflow/core/kernels/quantize_and_dequantize_op_test.cc
@@ -197,7 +197,7 @@ TEST_F(QuantizeAndDequantizeTest, Invalid_range_given) {
ops::QuantizeAndDequantize(root, {-3.5} /* input */); \
TF_CHECK_OK(root.status()); \
Graph* g = new Graph(OpRegistry::Global()); \
- root.ToGraph(g); \
+ TF_CHECK_OK(root.ToGraph(g)); \
test::Benchmark(#DEVICE, g).Run(iters); \
} \
BENCHMARK(BM_SIMPLE_QUAN_DEQUAN_##DEVICE);
diff --git a/tensorflow/core/kernels/random_shuffle_queue_op.cc b/tensorflow/core/kernels/random_shuffle_queue_op.cc
index a973bc2b1c..d3987eeb32 100644
--- a/tensorflow/core/kernels/random_shuffle_queue_op.cc
+++ b/tensorflow/core/kernels/random_shuffle_queue_op.cc
@@ -308,7 +308,13 @@ void RandomShuffleQueue::TryDequeueMany(int num_elements, OpKernelContext* ctx,
// an optimized case where the queue 'knows' what attributes to
// use, and plumbs them through here.
Tensor element;
- ctx->allocate_temp(component_dtypes_[i], ManyOutShape(i, 0), &element);
+ Status s = ctx->allocate_temp(component_dtypes_[i], ManyOutShape(i, 0),
+ &element);
+ if (!s.ok()) {
+ ctx->SetStatus(s);
+ callback(Tuple());
+ return;
+ }
tuple.emplace_back(element);
}
callback(tuple);
@@ -387,8 +393,10 @@ void RandomShuffleQueue::TryDequeueMany(int num_elements, OpKernelContext* ctx,
const TensorShape shape =
ManyOutShape(i, attempt->elements_requested);
Tensor element;
- attempt->context->allocate_temp(component_dtypes_[i],
- shape, &element);
+ attempt->context->SetStatus(
+ attempt->context->allocate_temp(component_dtypes_[i],
+ shape, &element));
+ if (!attempt->context->status().ok()) return kComplete;
attempt->tuple.emplace_back(element);
}
}
diff --git a/tensorflow/core/kernels/reader_base.cc b/tensorflow/core/kernels/reader_base.cc
index c1ac04bed9..d5d1bbd44c 100644
--- a/tensorflow/core/kernels/reader_base.cc
+++ b/tensorflow/core/kernels/reader_base.cc
@@ -65,7 +65,7 @@ Status ReaderBase::RestoreState(const string& state) {
mutex_lock lock(mu_);
Status status = RestoreStateLocked(state);
if (!status.ok()) {
- ResetLocked();
+ ResetLocked().IgnoreError();
}
return status;
}
diff --git a/tensorflow/core/kernels/remote_fused_graph_execute_op.cc b/tensorflow/core/kernels/remote_fused_graph_execute_op.cc
index 8d1dacfc2e..5fcffa2042 100644
--- a/tensorflow/core/kernels/remote_fused_graph_execute_op.cc
+++ b/tensorflow/core/kernels/remote_fused_graph_execute_op.cc
@@ -27,7 +27,8 @@ class RemoteFusedGraphExecuteOp : public OpKernel {
explicit RemoteFusedGraphExecuteOp(OpKernelConstruction* const ctx)
: OpKernel(ctx), graph_transferer_() {
string serialized_proto;
- ctx->GetAttr("serialized_graph_transfer_info", &serialized_proto);
+ OP_REQUIRES_OK(
+ ctx, ctx->GetAttr("serialized_graph_transfer_info", &serialized_proto));
graph_transferer_.SetSerializedGraphTransferInfo(serialized_proto);
const GraphTransferInfo& gt_info = graph_transferer_.GetGraphTransferInfo();
switch (gt_info.destination()) {
diff --git a/tensorflow/core/kernels/save_op_test.cc b/tensorflow/core/kernels/save_op_test.cc
index 735e3606d8..a118936956 100644
--- a/tensorflow/core/kernels/save_op_test.cc
+++ b/tensorflow/core/kernels/save_op_test.cc
@@ -681,7 +681,7 @@ static void BM_LargeTensorWrite(int iters, int num_elements) {
TF_CHECK_OK(root.status());
Graph* g = new Graph(OpRegistry::Global());
- root.ToGraph(g);
+ TF_CHECK_OK(root.ToGraph(g));
VLOG(1) << "Save op's output path: " << temp_filename;
VLOG(1) << "# nodes in Graph: " << g->num_nodes();
diff --git a/tensorflow/core/kernels/save_restore_v2_ops.cc b/tensorflow/core/kernels/save_restore_v2_ops.cc
index 4618536b64..2e09956578 100644
--- a/tensorflow/core/kernels/save_restore_v2_ops.cc
+++ b/tensorflow/core/kernels/save_restore_v2_ops.cc
@@ -126,9 +126,10 @@ class SaveV2 : public OpKernel {
shape_spec, ", tensor: ",
tensor.shape().DebugString()));
- writer.AddSlice(tensor_name, shape, slice, tensor);
+ OP_REQUIRES_OK(context,
+ writer.AddSlice(tensor_name, shape, slice, tensor));
} else {
- writer.Add(tensor_name, tensor);
+ OP_REQUIRES_OK(context, writer.Add(tensor_name, tensor));
}
}
OP_REQUIRES_OK(context, writer.Finish());
@@ -186,7 +187,8 @@ class MergeV2Checkpoints : public OpKernel {
public:
explicit MergeV2Checkpoints(OpKernelConstruction* context)
: OpKernel(context) {
- context->GetAttr("delete_old_dirs", &delete_old_dirs_);
+ OP_REQUIRES_OK(context,
+ context->GetAttr("delete_old_dirs", &delete_old_dirs_));
}
void Compute(OpKernelContext* context) override {
diff --git a/tensorflow/core/kernels/scatter_nd_op.cc b/tensorflow/core/kernels/scatter_nd_op.cc
index f101cf204d..8eaeafd19a 100644
--- a/tensorflow/core/kernels/scatter_nd_op.cc
+++ b/tensorflow/core/kernels/scatter_nd_op.cc
@@ -156,7 +156,8 @@ class ScatterNdOp : public OpKernel {
errors::InvalidArgument("Shape must be a vector"));
auto vec = shape_input.flat<Index>();
TensorShape shape;
- TensorShapeUtils::MakeShape(vec.data(), vec.size(), &shape);
+ OP_REQUIRES_OK(c,
+ TensorShapeUtils::MakeShape(vec.data(), vec.size(), &shape));
int64 slice_dim;
Index num_updates;
diff --git a/tensorflow/core/kernels/sdca_internal.cc b/tensorflow/core/kernels/sdca_internal.cc
index a73e3ee817..5042cfafc0 100644
--- a/tensorflow/core/kernels/sdca_internal.cc
+++ b/tensorflow/core/kernels/sdca_internal.cc
@@ -109,8 +109,8 @@ Status ModelWeights::Initialize(OpKernelContext* const context) {
for (int i = 0; i < sparse_weights_inputs.size(); ++i) {
Tensor* delta_t;
- sparse_weights_outputs.allocate(i, sparse_weights_inputs[i].shape(),
- &delta_t);
+ TF_RETURN_IF_ERROR(sparse_weights_outputs.allocate(
+ i, sparse_weights_inputs[i].shape(), &delta_t));
// Convert the input vector to a row matrix in internal representation.
auto deltas = delta_t->shaped<float, 2>({1, delta_t->NumElements()});
deltas.setZero();
@@ -127,7 +127,8 @@ Status ModelWeights::Initialize(OpKernelContext* const context) {
std::vector<FeatureWeightsDenseStorage>* const feature_weights) {
for (int i = 0; i < weight_inputs.size(); ++i) {
Tensor* delta_t;
- weight_outputs->allocate(i, weight_inputs[i].shape(), &delta_t);
+ TF_RETURN_IF_ERROR(
+ weight_outputs->allocate(i, weight_inputs[i].shape(), &delta_t));
// Convert the input vector to a row matrix in internal representation.
auto deltas = delta_t->shaped<float, 2>({1, delta_t->NumElements()});
deltas.setZero();
@@ -136,12 +137,11 @@ Status ModelWeights::Initialize(OpKernelContext* const context) {
{1, weight_inputs[i].NumElements()}),
deltas});
}
+ return Status::OK();
};
- initialize_weights(dense_weights_inputs, &dense_weights_outputs,
- &dense_weights_);
-
- return Status::OK();
+ return initialize_weights(dense_weights_inputs, &dense_weights_outputs,
+ &dense_weights_);
}
// Computes the example statistics for given example, and model. Defined here
diff --git a/tensorflow/core/kernels/sdca_ops.cc b/tensorflow/core/kernels/sdca_ops.cc
index d7365c6560..eb679cf2ae 100644
--- a/tensorflow/core/kernels/sdca_ops.cc
+++ b/tensorflow/core/kernels/sdca_ops.cc
@@ -142,7 +142,8 @@ void DoCompute(const ComputeOptions& options, OpKernelContext* const context) {
Tensor mutable_example_state_data_t(*example_state_data_t);
auto example_state_data = mutable_example_state_data_t.matrix<float>();
- context->set_output("out_example_state_data", mutable_example_state_data_t);
+ OP_REQUIRES_OK(context, context->set_output("out_example_state_data",
+ mutable_example_state_data_t));
if (options.adaptative) {
OP_REQUIRES_OK(context,
diff --git a/tensorflow/core/kernels/spacetobatch_benchmark_test.cc b/tensorflow/core/kernels/spacetobatch_benchmark_test.cc
index a8c4b3746a..c25ce2d8bb 100644
--- a/tensorflow/core/kernels/spacetobatch_benchmark_test.cc
+++ b/tensorflow/core/kernels/spacetobatch_benchmark_test.cc
@@ -37,19 +37,19 @@ static Graph* ConstructSpaceToBatchGraph(
if (dtype == DT_FLOAT) {
Tensor input(DT_FLOAT, input_shape);
input.flat<float>().setRandom();
- NodeBuilder(g->NewName("n"), op_name)
- .Input(test::graph::Constant(g, input))
- .Input(test::graph::Constant(g, paddings_tensor))
- .Attr("block_size", block_size)
- .Finalize(g, &ret);
+ TF_CHECK_OK(NodeBuilder(g->NewName("n"), op_name)
+ .Input(test::graph::Constant(g, input))
+ .Input(test::graph::Constant(g, paddings_tensor))
+ .Attr("block_size", block_size)
+ .Finalize(g, &ret));
} else if (dtype == DT_HALF) {
Tensor input(DT_HALF, input_shape);
input.flat<Eigen::half>().setRandom();
- NodeBuilder(g->NewName("n"), op_name)
- .Input(test::graph::Constant(g, input))
- .Input(test::graph::Constant(g, paddings_tensor))
- .Attr("block_size", block_size)
- .Finalize(g, &ret);
+ TF_CHECK_OK(NodeBuilder(g->NewName("n"), op_name)
+ .Input(test::graph::Constant(g, input))
+ .Input(test::graph::Constant(g, paddings_tensor))
+ .Attr("block_size", block_size)
+ .Finalize(g, &ret));
}
return g;
}
diff --git a/tensorflow/core/kernels/summary_image_op.cc b/tensorflow/core/kernels/summary_image_op.cc
index 39022cd1c3..22f593ddca 100644
--- a/tensorflow/core/kernels/summary_image_op.cc
+++ b/tensorflow/core/kernels/summary_image_op.cc
@@ -84,7 +84,8 @@ class SummaryImageOp : public OpKernel {
return typename TTypes<uint8>::ConstMatrix(
&values(i, 0, 0), Eigen::DSizes<Eigen::DenseIndex, 2>(hw, depth));
};
- AddImages(base_tag, batch_size, w, h, depth, ith_image, &s);
+ OP_REQUIRES_OK(
+ c, AddImages(base_tag, batch_size, w, h, depth, ith_image, &s));
} else if (tensor.dtype() == DT_HALF) {
NormalizeAndAddImages<Eigen::half>(c, tensor, h, w, hw, depth, batch_size,
base_tag, &s);
@@ -121,7 +122,8 @@ class SummaryImageOp : public OpKernel {
NormalizeFloatImage<T>(hw, depth, values, bad_color, &image);
return image;
};
- AddImages(base_tag, batch_size, w, h, depth, ith_image, s);
+ OP_REQUIRES_OK(c,
+ AddImages(base_tag, batch_size, w, h, depth, ith_image, s));
}
// Add the sequence of images specified by ith_image to the summary.
diff --git a/tensorflow/core/kernels/tf_record_reader_op.cc b/tensorflow/core/kernels/tf_record_reader_op.cc
index efadd9b7e9..583216fd09 100644
--- a/tensorflow/core/kernels/tf_record_reader_op.cc
+++ b/tensorflow/core/kernels/tf_record_reader_op.cc
@@ -87,7 +87,8 @@ class TFRecordReaderOp : public ReaderOpKernel {
Env* env = context->env();
string compression_type;
- context->GetAttr("compression_type", &compression_type);
+ OP_REQUIRES_OK(context,
+ context->GetAttr("compression_type", &compression_type));
SetReaderFactory([this, compression_type, env]() {
return new TFRecordReader(name(), compression_type, env);
diff --git a/tensorflow/core/lib/core/status.cc b/tensorflow/core/lib/core/status.cc
index 32c33ff079..d5001730a6 100644
--- a/tensorflow/core/lib/core/status.cc
+++ b/tensorflow/core/lib/core/status.cc
@@ -113,6 +113,10 @@ string Status::ToString() const {
}
}
+void Status::IgnoreError() const {
+ // no-op
+}
+
std::ostream& operator<<(std::ostream& os, const Status& x) {
os << x.ToString();
return os;
diff --git a/tensorflow/core/lib/core/status.h b/tensorflow/core/lib/core/status.h
index 0dae2abfe9..1dde1b4281 100644
--- a/tensorflow/core/lib/core/status.h
+++ b/tensorflow/core/lib/core/status.h
@@ -72,6 +72,11 @@ class Status {
/// printing. Returns the string `"OK"` for success.
string ToString() const;
+ // Ignores any errors. This method does nothing except potentially suppress
+ // complaints from any tools that are checking that errors are not dropped on
+ // the floor.
+ void IgnoreError() const;
+
private:
static const string& empty_string();
struct State {
diff --git a/tensorflow/core/lib/io/buffered_inputstream.cc b/tensorflow/core/lib/io/buffered_inputstream.cc
index d4a5ed48bd..7bdbc1ff8c 100644
--- a/tensorflow/core/lib/io/buffered_inputstream.cc
+++ b/tensorflow/core/lib/io/buffered_inputstream.cc
@@ -163,7 +163,7 @@ Status BufferedInputStream::ReadLine(string* result) {
string BufferedInputStream::ReadLineAsString() {
string result;
- ReadLineHelper(&result, true);
+ ReadLineHelper(&result, true).IgnoreError();
return result;
}
diff --git a/tensorflow/core/lib/io/buffered_inputstream_test.cc b/tensorflow/core/lib/io/buffered_inputstream_test.cc
index 4488637cad..4def2de373 100644
--- a/tensorflow/core/lib/io/buffered_inputstream_test.cc
+++ b/tensorflow/core/lib/io/buffered_inputstream_test.cc
@@ -32,7 +32,7 @@ static std::vector<int> BufferSizes() {
TEST(BufferedInputStream, ReadLine_Empty) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/buffered_inputstream_test";
- WriteStringToFile(env, fname, "");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, ""));
std::unique_ptr<RandomAccessFile> file;
TF_ASSERT_OK(env->NewRandomAccessFile(fname, &file));
@@ -48,7 +48,8 @@ TEST(BufferedInputStream, ReadLine_Empty) {
TEST(BufferedInputStream, ReadLine1) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/buffered_inputstream_test";
- WriteStringToFile(env, fname, "line one\nline two\nline three\n");
+ TF_ASSERT_OK(
+ WriteStringToFile(env, fname, "line one\nline two\nline three\n"));
std::unique_ptr<RandomAccessFile> file;
TF_ASSERT_OK(env->NewRandomAccessFile(fname, &file));
@@ -72,7 +73,7 @@ TEST(BufferedInputStream, ReadLine1) {
TEST(BufferedInputStream, ReadLine_NoTrailingNewLine) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/buffered_inputstream_test";
- WriteStringToFile(env, fname, "line one\nline two\nline three");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, "line one\nline two\nline three"));
std::unique_ptr<RandomAccessFile> file;
TF_ASSERT_OK(env->NewRandomAccessFile(fname, &file));
@@ -96,7 +97,8 @@ TEST(BufferedInputStream, ReadLine_NoTrailingNewLine) {
TEST(BufferedInputStream, ReadLine_EmptyLines) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/buffered_inputstream_test";
- WriteStringToFile(env, fname, "line one\n\n\nline two\nline three");
+ TF_ASSERT_OK(
+ WriteStringToFile(env, fname, "line one\n\n\nline two\nline three"));
std::unique_ptr<RandomAccessFile> file;
TF_ASSERT_OK(env->NewRandomAccessFile(fname, &file));
@@ -124,7 +126,8 @@ TEST(BufferedInputStream, ReadLine_EmptyLines) {
TEST(BufferedInputStream, ReadLine_CRLF) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/buffered_inputstream_test";
- WriteStringToFile(env, fname, "line one\r\n\r\n\r\nline two\r\nline three");
+ TF_ASSERT_OK(WriteStringToFile(env, fname,
+ "line one\r\n\r\n\r\nline two\r\nline three"));
std::unique_ptr<RandomAccessFile> file;
TF_ASSERT_OK(env->NewRandomAccessFile(fname, &file));
@@ -152,7 +155,7 @@ TEST(BufferedInputStream, ReadLine_CRLF) {
TEST(BufferedInputStream, ReadNBytes) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/buffer_test";
- WriteStringToFile(env, fname, "0123456789");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, "0123456789"));
std::unique_ptr<RandomAccessFile> file;
TF_ASSERT_OK(env->NewRandomAccessFile(fname, &file));
@@ -189,7 +192,7 @@ TEST(BufferedInputStream, ReadNBytes) {
TEST(BufferedInputStream, SkipNBytes) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/buffered_inputstream_test";
- WriteStringToFile(env, fname, "0123456789");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, "0123456789"));
std::unique_ptr<RandomAccessFile> file;
TF_ASSERT_OK(env->NewRandomAccessFile(fname, &file));
@@ -226,7 +229,7 @@ TEST(BufferedInputStream, SkipNBytes) {
TEST(BufferedInputStream, ReadNBytesRandomAccessFile) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/buffer_test";
- WriteStringToFile(env, fname, "0123456789");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, "0123456789"));
std::unique_ptr<RandomAccessFile> file;
TF_ASSERT_OK(env->NewRandomAccessFile(fname, &file));
@@ -261,7 +264,7 @@ TEST(BufferedInputStream, ReadNBytesRandomAccessFile) {
TEST(BufferedInputStream, SkipNBytesRandomAccessFile) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/buffered_inputstream_test";
- WriteStringToFile(env, fname, "0123456789");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, "0123456789"));
std::unique_ptr<RandomAccessFile> file;
TF_ASSERT_OK(env->NewRandomAccessFile(fname, &file));
@@ -296,7 +299,7 @@ TEST(BufferedInputStream, SkipNBytesRandomAccessFile) {
TEST(BufferedInputStream, Seek) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/buffered_inputstream_test";
- WriteStringToFile(env, fname, "0123456789");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, "0123456789"));
std::unique_ptr<RandomAccessFile> file;
TF_ASSERT_OK(env->NewRandomAccessFile(fname, &file));
diff --git a/tensorflow/core/lib/io/inputbuffer_test.cc b/tensorflow/core/lib/io/inputbuffer_test.cc
index 31fa96bf76..4571df9a98 100644
--- a/tensorflow/core/lib/io/inputbuffer_test.cc
+++ b/tensorflow/core/lib/io/inputbuffer_test.cc
@@ -37,7 +37,7 @@ static std::vector<int> BufferSizes() {
TEST(InputBuffer, ReadLine_Empty) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/inputbuffer_test";
- WriteStringToFile(env, fname, "");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, ""));
for (auto buf_size : BufferSizes()) {
std::unique_ptr<RandomAccessFile> file;
@@ -51,7 +51,8 @@ TEST(InputBuffer, ReadLine_Empty) {
TEST(InputBuffer, ReadLine1) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/inputbuffer_test";
- WriteStringToFile(env, fname, "line one\nline two\nline three\n");
+ TF_CHECK_OK(
+ WriteStringToFile(env, fname, "line one\nline two\nline three\n"));
for (auto buf_size : BufferSizes()) {
std::unique_ptr<RandomAccessFile> file;
@@ -73,7 +74,7 @@ TEST(InputBuffer, ReadLine1) {
TEST(InputBuffer, ReadLine_NoTrailingNewLine) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/inputbuffer_test";
- WriteStringToFile(env, fname, "line one\nline two\nline three");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, "line one\nline two\nline three"));
for (auto buf_size : BufferSizes()) {
std::unique_ptr<RandomAccessFile> file;
@@ -95,7 +96,8 @@ TEST(InputBuffer, ReadLine_NoTrailingNewLine) {
TEST(InputBuffer, ReadLine_EmptyLines) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/inputbuffer_test";
- WriteStringToFile(env, fname, "line one\n\n\nline two\nline three");
+ TF_CHECK_OK(
+ WriteStringToFile(env, fname, "line one\n\n\nline two\nline three"));
for (auto buf_size : BufferSizes()) {
std::unique_ptr<RandomAccessFile> file;
@@ -121,7 +123,8 @@ TEST(InputBuffer, ReadLine_EmptyLines) {
TEST(InputBuffer, ReadLine_CRLF) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/inputbuffer_test";
- WriteStringToFile(env, fname, "line one\r\n\r\n\r\nline two\r\nline three");
+ TF_ASSERT_OK(WriteStringToFile(env, fname,
+ "line one\r\n\r\n\r\nline two\r\nline three"));
for (auto buf_size : BufferSizes()) {
std::unique_ptr<RandomAccessFile> file;
@@ -147,7 +150,7 @@ TEST(InputBuffer, ReadLine_CRLF) {
TEST(InputBuffer, ReadNBytes) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/inputbuffer_test";
- WriteStringToFile(env, fname, "0123456789");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, "0123456789"));
// ReadNBytes(int64, string*).
for (auto buf_size : BufferSizes()) {
@@ -220,7 +223,7 @@ TEST(InputBuffer, ReadNBytes) {
TEST(InputBuffer, SkipNBytes) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/inputbuffer_test";
- WriteStringToFile(env, fname, "0123456789");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, "0123456789"));
for (auto buf_size : BufferSizes()) {
std::unique_ptr<RandomAccessFile> file;
@@ -255,7 +258,7 @@ TEST(InputBuffer, SkipNBytes) {
TEST(InputBuffer, Seek) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/inputbuffer_test";
- WriteStringToFile(env, fname, "0123456789");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, "0123456789"));
for (auto buf_size : BufferSizes()) {
std::unique_ptr<RandomAccessFile> file;
diff --git a/tensorflow/core/lib/io/random_inputstream_test.cc b/tensorflow/core/lib/io/random_inputstream_test.cc
index 40b5be8571..7f697d5fa4 100644
--- a/tensorflow/core/lib/io/random_inputstream_test.cc
+++ b/tensorflow/core/lib/io/random_inputstream_test.cc
@@ -26,7 +26,7 @@ namespace {
TEST(RandomInputStream, ReadNBytes) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/random_inputbuffer_test";
- WriteStringToFile(env, fname, "0123456789");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, "0123456789"));
std::unique_ptr<RandomAccessFile> file;
TF_ASSERT_OK(env->NewRandomAccessFile(fname, &file));
@@ -55,7 +55,7 @@ TEST(RandomInputStream, ReadNBytes) {
TEST(RandomInputStream, SkipNBytes) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/random_inputbuffer_test";
- WriteStringToFile(env, fname, "0123456789");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, "0123456789"));
std::unique_ptr<RandomAccessFile> file;
TF_ASSERT_OK(env->NewRandomAccessFile(fname, &file));
@@ -86,7 +86,7 @@ TEST(RandomInputStream, SkipNBytes) {
TEST(RandomInputStream, Seek) {
Env* env = Env::Default();
string fname = testing::TmpDir() + "/random_inputbuffer_seek_test";
- WriteStringToFile(env, fname, "0123456789");
+ TF_ASSERT_OK(WriteStringToFile(env, fname, "0123456789"));
std::unique_ptr<RandomAccessFile> file;
TF_ASSERT_OK(env->NewRandomAccessFile(fname, &file));
diff --git a/tensorflow/core/lib/io/record_reader_writer_test.cc b/tensorflow/core/lib/io/record_reader_writer_test.cc
index 0a656473e4..95ac040602 100644
--- a/tensorflow/core/lib/io/record_reader_writer_test.cc
+++ b/tensorflow/core/lib/io/record_reader_writer_test.cc
@@ -45,8 +45,8 @@ TEST(RecordReaderWriterTest, TestBasics) {
io::RecordWriterOptions options;
options.zlib_options.output_buffer_size = buf_size;
io::RecordWriter writer(file.get(), options);
- writer.WriteRecord("abc");
- writer.WriteRecord("defg");
+ TF_EXPECT_OK(writer.WriteRecord("abc"));
+ TF_EXPECT_OK(writer.WriteRecord("defg"));
TF_CHECK_OK(writer.Flush());
}
@@ -82,8 +82,8 @@ TEST(RecordReaderWriterTest, TestZlib) {
options.compression_type = io::RecordWriterOptions::ZLIB_COMPRESSION;
options.zlib_options.output_buffer_size = buf_size;
io::RecordWriter writer(file.get(), options);
- writer.WriteRecord("abc");
- writer.WriteRecord("defg");
+ TF_EXPECT_OK(writer.WriteRecord("abc"));
+ TF_EXPECT_OK(writer.WriteRecord("defg"));
TF_CHECK_OK(writer.Flush());
}
diff --git a/tensorflow/core/ops/nn_ops.cc b/tensorflow/core/ops/nn_ops.cc
index 2d757b7a17..ec74240feb 100644
--- a/tensorflow/core/ops/nn_ops.cc
+++ b/tensorflow/core/ops/nn_ops.cc
@@ -281,10 +281,10 @@ REGISTER_OP("FusedBatchNorm")
TF_RETURN_IF_ERROR(c->WithRank(c->input(0), 4, &x));
bool is_training;
- c->GetAttr("is_training", &is_training);
+ TF_RETURN_IF_ERROR(c->GetAttr("is_training", &is_training));
int number_inputs = (is_training) ? 3 : 5;
string data_format;
- c->GetAttr("data_format", &data_format);
+ TF_RETURN_IF_ERROR(c->GetAttr("data_format", &data_format));
DimensionHandle channel_dim =
(data_format == "NHWC") ? c->Dim(x, 3) : c->Dim(x, 1);
@@ -360,8 +360,8 @@ REGISTER_OP("FusedBatchNormGrad")
bool is_training;
string data_format;
- c->GetAttr("is_training", &is_training);
- c->GetAttr("data_format", &data_format);
+ TF_RETURN_IF_ERROR(c->GetAttr("is_training", &is_training));
+ TF_RETURN_IF_ERROR(c->GetAttr("data_format", &data_format));
DimensionHandle channel_dim = (data_format == "NHWC")
? c->Dim(y_backprop, 3)
: c->Dim(y_backprop, 1);
diff --git a/tensorflow/core/ops/resource_variable_ops.cc b/tensorflow/core/ops/resource_variable_ops.cc
index 00194edea2..c8183edc42 100644
--- a/tensorflow/core/ops/resource_variable_ops.cc
+++ b/tensorflow/core/ops/resource_variable_ops.cc
@@ -34,10 +34,10 @@ REGISTER_OP("VarHandleOp")
.SetShapeFn([](shape_inference::InferenceContext* c) {
c->set_output(0, c->Scalar());
DataType t;
- c->GetAttr("dtype", &t);
+ TF_RETURN_IF_ERROR(c->GetAttr("dtype", &t));
c->set_output_handle_dtype(0, t);
TensorShapeProto p;
- c->GetAttr("shape", &p);
+ TF_RETURN_IF_ERROR(c->GetAttr("shape", &p));
shape_inference::ShapeHandle s;
TF_RETURN_IF_ERROR(c->MakeShapeFromShapeProto(p, &s));
c->set_output_handle_shape(0, s);
@@ -60,7 +60,7 @@ REGISTER_OP("ReadVariableOp")
.SetShapeFn([](InferenceContext* c) {
DataType handle_dtype = c->input_handle_dtype(0);
DataType value_dtype;
- c->GetAttr("dtype", &value_dtype);
+ TF_RETURN_IF_ERROR(c->GetAttr("dtype", &value_dtype));
if (handle_dtype != value_dtype) {
return errors::InvalidArgument(
"Trying to read variable with wrong dtype. "
@@ -103,7 +103,7 @@ ignore_lookup_error: whether to ignore the error when the resource
Status CreateAssignShapeFn(InferenceContext* c) {
DataType handle_dtype = c->input_handle_dtype(0);
DataType value_dtype;
- c->GetAttr("dtype", &value_dtype);
+ TF_RETURN_IF_ERROR(c->GetAttr("dtype", &value_dtype));
if (handle_dtype != value_dtype) {
return errors::InvalidArgument(
"Trying to initialize handle for variable with wrong dtype. "
diff --git a/tensorflow/core/ops/sdca_ops.cc b/tensorflow/core/ops/sdca_ops.cc
index 0aed75366e..2029ed7de2 100644
--- a/tensorflow/core/ops/sdca_ops.cc
+++ b/tensorflow/core/ops/sdca_ops.cc
@@ -26,11 +26,12 @@ using shape_inference::InferenceContext;
static Status ApplySdcaOptimizerShapeFn(InferenceContext* c) {
std::vector<ShapeHandle> sparse_handles;
if (c->input("sparse_weights", &sparse_handles).ok()) {
- c->set_output("out_delta_sparse_weights", sparse_handles);
+ TF_RETURN_IF_ERROR(
+ c->set_output("out_delta_sparse_weights", sparse_handles));
}
std::vector<ShapeHandle> dense_handles;
if (c->input("dense_weights", &dense_handles).ok()) {
- c->set_output("out_delta_dense_weights", dense_handles);
+ TF_RETURN_IF_ERROR(c->set_output("out_delta_dense_weights", dense_handles));
}
return c->set_output(
"out_example_state_data",
diff --git a/tensorflow/core/platform/cloud/gcs_file_system.cc b/tensorflow/core/platform/cloud/gcs_file_system.cc
index ab56ad09d1..b7e2e1af4a 100644
--- a/tensorflow/core/platform/cloud/gcs_file_system.cc
+++ b/tensorflow/core/platform/cloud/gcs_file_system.cc
@@ -336,7 +336,7 @@ class GcsWritableFile : public WritableFile {
std::ofstream::binary | std::ofstream::app);
}
- ~GcsWritableFile() { Close(); }
+ ~GcsWritableFile() override { Close().IgnoreError(); }
Status Append(const StringPiece& data) override {
TF_RETURN_IF_ERROR(CheckWritable());
@@ -767,8 +767,9 @@ Status GcsFileSystem::BucketExists(const string& bucket, bool* result) {
std::unique_ptr<HttpRequest> request(http_request_factory_->Create());
TF_RETURN_IF_ERROR(request->Init());
- request->SetUri(strings::StrCat(kGcsUriBase, "b/", bucket));
- request->AddAuthBearerHeader(auth_token);
+ TF_RETURN_IF_ERROR(
+ request->SetUri(strings::StrCat(kGcsUriBase, "b/", bucket)));
+ TF_RETURN_IF_ERROR(request->AddAuthBearerHeader(auth_token));
const Status status = request->Send();
switch (status.code()) {
case errors::Code::OK:
diff --git a/tensorflow/core/platform/cloud/http_request_test.cc b/tensorflow/core/platform/cloud/http_request_test.cc
index 31ba3e337f..944dd34271 100644
--- a/tensorflow/core/platform/cloud/http_request_test.cc
+++ b/tensorflow/core/platform/cloud/http_request_test.cc
@@ -447,8 +447,8 @@ TEST(HttpRequestTest, WrongSequenceOfCalls_TwoSends) {
HttpRequest http_request(&libcurl);
TF_EXPECT_OK(http_request.Init());
- http_request.SetUri("http://www.google.com");
- http_request.Send();
+ TF_EXPECT_OK(http_request.SetUri("http://www.google.com"));
+ TF_EXPECT_OK(http_request.Send());
auto s = http_request.Send();
ASSERT_TRUE(errors::IsFailedPrecondition(s));
EXPECT_TRUE(StringPiece(s.error_message())
@@ -460,8 +460,8 @@ TEST(HttpRequestTest, WrongSequenceOfCalls_ReusingAfterSend) {
HttpRequest http_request(&libcurl);
TF_EXPECT_OK(http_request.Init());
- http_request.SetUri("http://www.google.com");
- http_request.Send();
+ TF_EXPECT_OK(http_request.SetUri("http://www.google.com"));
+ TF_EXPECT_OK(http_request.Send());
auto s = http_request.SetUri("http://mail.google.com");
ASSERT_TRUE(errors::IsFailedPrecondition(s));
EXPECT_TRUE(StringPiece(s.error_message())
@@ -473,7 +473,7 @@ TEST(HttpRequestTest, WrongSequenceOfCalls_SettingMethodTwice) {
HttpRequest http_request(&libcurl);
TF_EXPECT_OK(http_request.Init());
- http_request.SetDeleteRequest();
+ TF_EXPECT_OK(http_request.SetDeleteRequest());
auto s = http_request.SetPostEmptyBody();
ASSERT_TRUE(errors::IsFailedPrecondition(s));
EXPECT_TRUE(StringPiece(s.error_message())
diff --git a/tensorflow/core/platform/cloud/retrying_file_system.cc b/tensorflow/core/platform/cloud/retrying_file_system.cc
index 7e98cafa8b..4bab73112d 100644
--- a/tensorflow/core/platform/cloud/retrying_file_system.cc
+++ b/tensorflow/core/platform/cloud/retrying_file_system.cc
@@ -91,7 +91,7 @@ class RetryingWritableFile : public WritableFile {
~RetryingWritableFile() {
// Makes sure the retrying version of Close() is called in the destructor.
- Close();
+ Close().IgnoreError();
}
Status Append(const StringPiece& data) override {
diff --git a/tensorflow/core/platform/env_test.cc b/tensorflow/core/platform/env_test.cc
index 5ecf6688c4..d0a249ddc1 100644
--- a/tensorflow/core/platform/env_test.cc
+++ b/tensorflow/core/platform/env_test.cc
@@ -32,7 +32,7 @@ namespace {
string CreateTestFile(Env* env, const string& filename, int length) {
string input(length, 0);
for (int i = 0; i < length; i++) input[i] = i;
- WriteStringToFile(env, filename, input);
+ TF_CHECK_OK(WriteStringToFile(env, filename, input));
return input;
}
@@ -53,11 +53,12 @@ string BaseDir() { return io::JoinPath(testing::TmpDir(), "base_dir"); }
class DefaultEnvTest : public ::testing::Test {
protected:
- void SetUp() override { env_->CreateDir(BaseDir()); }
+ void SetUp() override { TF_CHECK_OK(env_->CreateDir(BaseDir())); }
void TearDown() override {
int64 undeleted_files, undeleted_dirs;
- env_->DeleteRecursively(BaseDir(), &undeleted_files, &undeleted_dirs);
+ TF_CHECK_OK(
+ env_->DeleteRecursively(BaseDir(), &undeleted_files, &undeleted_dirs));
}
Env* env_ = Env::Default();
diff --git a/tensorflow/core/platform/hadoop/hadoop_file_system.cc b/tensorflow/core/platform/hadoop/hadoop_file_system.cc
index 16e401a54e..1d0c9dc8cd 100644
--- a/tensorflow/core/platform/hadoop/hadoop_file_system.cc
+++ b/tensorflow/core/platform/hadoop/hadoop_file_system.cc
@@ -259,7 +259,7 @@ class HDFSWritableFile : public WritableFile {
~HDFSWritableFile() override {
if (file_ != nullptr) {
- Close();
+ Close().IgnoreError();
}
}
diff --git a/tensorflow/core/util/events_writer.cc b/tensorflow/core/util/events_writer.cc
index ee33722718..fa23ff2bcb 100644
--- a/tensorflow/core/util/events_writer.cc
+++ b/tensorflow/core/util/events_writer.cc
@@ -97,7 +97,7 @@ void EventsWriter::WriteSerializedEvent(StringPiece event_str) {
}
}
num_outstanding_events_++;
- recordio_writer_->WriteRecord(event_str);
+ recordio_writer_->WriteRecord(event_str).IgnoreError();
}
// NOTE(touts); This is NOT the function called by the Python code.
diff --git a/tensorflow/core/util/events_writer_test.cc b/tensorflow/core/util/events_writer_test.cc
index a96be61985..cdab986ec5 100644
--- a/tensorflow/core/util/events_writer_test.cc
+++ b/tensorflow/core/util/events_writer_test.cc
@@ -140,7 +140,7 @@ TEST(EventWriter, FailFlush) {
string filename = writer.FileName();
WriteFile(&writer);
TF_EXPECT_OK(env()->FileExists(filename));
- env()->DeleteFile(filename);
+ TF_ASSERT_OK(env()->DeleteFile(filename));
EXPECT_EQ(errors::Code::NOT_FOUND, env()->FileExists(filename).code());
EXPECT_FALSE(writer.Flush());
EXPECT_EQ(errors::Code::NOT_FOUND, env()->FileExists(filename).code());
@@ -152,7 +152,7 @@ TEST(EventWriter, FailClose) {
string filename = writer.FileName();
WriteFile(&writer);
TF_EXPECT_OK(env()->FileExists(filename));
- env()->DeleteFile(filename);
+ TF_ASSERT_OK(env()->DeleteFile(filename));
EXPECT_EQ(errors::Code::NOT_FOUND, env()->FileExists(filename).code());
EXPECT_FALSE(writer.Close());
EXPECT_EQ(errors::Code::NOT_FOUND, env()->FileExists(filename).code());
@@ -187,7 +187,7 @@ TEST(EventWriter, NameClose) {
string filename = writer.FileName();
EXPECT_TRUE(writer.Close());
TF_EXPECT_OK(env()->FileExists(filename));
- env()->DeleteFile(filename);
+ TF_ASSERT_OK(env()->DeleteFile(filename));
}
TEST(EventWriter, FileDeletionBeforeWriting) {
@@ -197,7 +197,7 @@ TEST(EventWriter, FileDeletionBeforeWriting) {
TF_EXPECT_OK(env()->FileExists(filename0));
env()->SleepForMicroseconds(
2000000); // To make sure timestamp part of filename will differ.
- env()->DeleteFile(filename0);
+ TF_ASSERT_OK(env()->DeleteFile(filename0));
EXPECT_TRUE(writer.Init()); // Init should reopen file.
WriteFile(&writer);
EXPECT_TRUE(writer.Flush());
diff --git a/tensorflow/core/util/example_proto_helper.cc b/tensorflow/core/util/example_proto_helper.cc
index 658b3588e6..8e406fde5e 100644
--- a/tensorflow/core/util/example_proto_helper.cc
+++ b/tensorflow/core/util/example_proto_helper.cc
@@ -359,9 +359,9 @@ Status BatchExampleProtoToTensors(
for (size_t b = 0; b < examples.size(); ++b) {
const Example& ex = *(examples[b]);
const string& example_name = (has_names) ? names[b] : "<unknown>";
- SingleExampleProtoToTensors(
+ TF_RETURN_IF_ERROR(SingleExampleProtoToTensors(
ex, example_name, b, fixed_len_features, var_len_features,
- &output_dense_values_tensor_ptrs, &sparse_values_tmp);
+ &output_dense_values_tensor_ptrs, &sparse_values_tmp));
}
for (size_t d = 0; d < var_len_features.size(); ++d) {
@@ -370,8 +370,9 @@ Status BatchExampleProtoToTensors(
const std::vector<Tensor>& sparse_values_tensor = sparse_values_tmp[d];
VarLenFeatureBatchShapes sparse_tensor_batch_shapes;
- GetSparseTensorShapes(feature_config, sparse_values_tensor, batch_size,
- &sparse_tensor_batch_shapes);
+ TF_RETURN_IF_ERROR(GetSparseTensorShapes(feature_config,
+ sparse_values_tensor, batch_size,
+ &sparse_tensor_batch_shapes));
const TensorShape& indices_shape = sparse_tensor_batch_shapes.indices_shape;
const TensorShape& values_shape = sparse_tensor_batch_shapes.values_shape;
diff --git a/tensorflow/core/util/example_proto_helper_test.cc b/tensorflow/core/util/example_proto_helper_test.cc
index 15c5d01c3b..5d57ac9492 100644
--- a/tensorflow/core/util/example_proto_helper_test.cc
+++ b/tensorflow/core/util/example_proto_helper_test.cc
@@ -15,6 +15,7 @@ limitations under the License.
#include "tensorflow/core/util/example_proto_helper.h"
#include "tensorflow/core/example/example.pb.h"
+#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/platform/test.h"
namespace tensorflow {
@@ -99,8 +100,9 @@ TEST_F(SingleExampleProtoToTensorsTest, SparseOnlyTrivial) {
}
std::vector<FixedLenFeature> empty_dense_vec;
- SingleExampleProtoToTensors(ex, "", 0, empty_dense_vec, sparse_vec_,
- &output_dense_values, &output_sparse_values_tmp);
+ TF_EXPECT_OK(SingleExampleProtoToTensors(ex, "", 0, empty_dense_vec,
+ sparse_vec_, &output_dense_values,
+ &output_sparse_values_tmp));
const std::vector<Tensor>& int64_tensor_vec = output_sparse_values_tmp[0];
EXPECT_EQ(1, int64_tensor_vec.size());
@@ -124,8 +126,9 @@ TEST_F(SingleExampleProtoToTensorsTest, SparseOnlyEmpty) {
}
std::vector<FixedLenFeature> empty_dense_vec;
- SingleExampleProtoToTensors(empty, "", 0, empty_dense_vec, sparse_vec_,
- &output_dense_values, &output_sparse_values_tmp);
+ TF_EXPECT_OK(SingleExampleProtoToTensors(empty, "", 0, empty_dense_vec,
+ sparse_vec_, &output_dense_values,
+ &output_sparse_values_tmp));
// Each feature will still have a tensor vector, however the tensor
// in the vector will be empty.
@@ -167,8 +170,9 @@ TEST_F(SingleExampleProtoToTensorsTest, DenseOnlyTrivial) {
std::vector<VarLenFeature> empty_sparse_vec;
std::vector<std::vector<Tensor>> output_sparse_values_tmp;
- SingleExampleProtoToTensors(ex, "", 0, dense_vec_, empty_sparse_vec,
- &output_dense_values, &output_sparse_values_tmp);
+ TF_EXPECT_OK(SingleExampleProtoToTensors(
+ ex, "", 0, dense_vec_, empty_sparse_vec, &output_dense_values,
+ &output_sparse_values_tmp));
EXPECT_TRUE(output_sparse_values_tmp.empty());
EXPECT_EQ(1, int64_dense_output.matrix<int64>().size());
@@ -196,8 +200,9 @@ TEST_F(SingleExampleProtoToTensorsTest, DenseOnlyDefaults) {
std::vector<VarLenFeature> empty_sparse_vec;
std::vector<std::vector<Tensor>> output_sparse_values_tmp;
- SingleExampleProtoToTensors(empty, "", 0, dense_vec_, empty_sparse_vec,
- &output_dense_values, &output_sparse_values_tmp);
+ TF_EXPECT_OK(SingleExampleProtoToTensors(
+ empty, "", 0, dense_vec_, empty_sparse_vec, &output_dense_values,
+ &output_sparse_values_tmp));
EXPECT_EQ(1, int64_dense_output.matrix<int64>().size());
EXPECT_EQ(0, int64_dense_output.matrix<int64>()(0, 0));
diff --git a/tensorflow/core/util/memmapped_file_system_test.cc b/tensorflow/core/util/memmapped_file_system_test.cc
index 179c72c1f5..db5ce2e50b 100644
--- a/tensorflow/core/util/memmapped_file_system_test.cc
+++ b/tensorflow/core/util/memmapped_file_system_test.cc
@@ -142,7 +142,7 @@ TEST(MemmappedFileSystemTest, ProxyToDefault) {
// Making sure to clean up after the test finishes.
const auto adh = [&memmapped_env, &filename](WritableFile* f) {
delete f;
- memmapped_env.DeleteFile(filename);
+ TF_CHECK_OK(memmapped_env.DeleteFile(filename));
};
std::unique_ptr<WritableFile, decltype(adh)> writable_file(
writable_file_temp.release(), adh);
diff --git a/tensorflow/core/util/tensor_bundle/tensor_bundle.cc b/tensorflow/core/util/tensor_bundle/tensor_bundle.cc
index 40391bb3c3..6d0229520c 100644
--- a/tensorflow/core/util/tensor_bundle/tensor_bundle.cc
+++ b/tensorflow/core/util/tensor_bundle/tensor_bundle.cc
@@ -233,7 +233,7 @@ bool IsFullSlice(const TensorSlice& slice_spec,
return true;
} else {
TensorShape sliced_shape;
- slice_spec.SliceTensorShape(full_tensor_shape, &sliced_shape);
+ slice_spec.SliceTensorShape(full_tensor_shape, &sliced_shape).IgnoreError();
return sliced_shape == full_tensor_shape;
}
}
@@ -348,7 +348,7 @@ Status BundleWriter::Finish() {
status_ = Env::Default()->RenameFile(tmp_data_path_,
DataFilename(prefix_, 0, 1));
} else {
- Env::Default()->DeleteFile(tmp_data_path_);
+ Env::Default()->DeleteFile(tmp_data_path_).IgnoreError();
}
}
if (!status_.ok()) return status_;
@@ -381,7 +381,7 @@ Status BundleWriter::Finish() {
}
status_.Update(file->Close());
if (!status_.ok()) {
- Env::Default()->DeleteFile(tmp_metadata_path_);
+ Env::Default()->DeleteFile(tmp_metadata_path_).IgnoreError();
return status_;
} else {
status_ =
@@ -515,7 +515,7 @@ Status MergeBundles(Env* env, gtl::ArraySlice<string> prefixes,
// Merges all metadata tables.
// TODO(zhifengc): KeyValue sorter if it becomes too big.
MergeState merge;
- env->CreateDir(io::Dirname(merged_prefix).ToString()); // Ignores errors.
+ env->CreateDir(io::Dirname(merged_prefix).ToString()).IgnoreError();
for (int i = 0; i < prefixes.size(); ++i) {
TF_RETURN_IF_ERROR(MergeOneBundle(env, prefixes[i], &merge));
}
@@ -554,7 +554,7 @@ Status MergeBundles(Env* env, gtl::ArraySlice<string> prefixes,
// Cleanup: best effort based and ignores errors.
for (const string& prefix : prefixes) {
- env->DeleteFile(MetaFilename(prefix));
+ env->DeleteFile(MetaFilename(prefix)).IgnoreError();
}
return status;
}
@@ -737,15 +737,15 @@ Status BundleReader::GetSliceValue(StringPiece full_tensor_key,
// Special case: a writer has saved a tensor fully, but the reader wants
// to read in slices. We therefore register the full slice on-demand here
// without further complicating the on-disk bundle format.
- RegisterTensorSlice(full_tensor_key_string, full_shape,
- full_tensor_entry.dtype(), /* tag */ "",
- /* full slice */ TensorSlice(full_shape.dims()),
- &tensor_slices_);
+ TF_RETURN_IF_ERROR(RegisterTensorSlice(
+ full_tensor_key_string, full_shape, full_tensor_entry.dtype(),
+ /* tag */ "",
+ /* full slice */ TensorSlice(full_shape.dims()), &tensor_slices_));
}
for (const TensorSliceProto& slice : full_tensor_entry.slices()) {
- RegisterTensorSlice(full_tensor_key_string, full_shape,
- full_tensor_entry.dtype(),
- /* tag */ "", TensorSlice(slice), &tensor_slices_);
+ TF_RETURN_IF_ERROR(RegisterTensorSlice(
+ full_tensor_key_string, full_shape, full_tensor_entry.dtype(),
+ /* tag */ "", TensorSlice(slice), &tensor_slices_));
}
tss = gtl::FindPtrOrNull(tensor_slices_, full_tensor_key_string);
CHECK_NE(tss, nullptr);
diff --git a/tensorflow/core/util/tensor_bundle/tensor_bundle_test.cc b/tensorflow/core/util/tensor_bundle/tensor_bundle_test.cc
index 4693b4c005..3b775e4000 100644
--- a/tensorflow/core/util/tensor_bundle/tensor_bundle_test.cc
+++ b/tensorflow/core/util/tensor_bundle/tensor_bundle_test.cc
@@ -123,10 +123,10 @@ template <typename T>
void TestBasic() {
{
BundleWriter writer(Env::Default(), Prefix("foo"));
- writer.Add("foo_003", Constant_2x3<T>(3));
- writer.Add("foo_000", Constant_2x3<T>(0));
- writer.Add("foo_002", Constant_2x3<T>(2));
- writer.Add("foo_001", Constant_2x3<T>(1));
+ TF_EXPECT_OK(writer.Add("foo_003", Constant_2x3<T>(3)));
+ TF_EXPECT_OK(writer.Add("foo_000", Constant_2x3<T>(0)));
+ TF_EXPECT_OK(writer.Add("foo_002", Constant_2x3<T>(2)));
+ TF_EXPECT_OK(writer.Add("foo_001", Constant_2x3<T>(1)));
TF_ASSERT_OK(writer.Finish());
}
{
@@ -142,10 +142,10 @@ void TestBasic() {
}
{
BundleWriter writer(Env::Default(), Prefix("bar"));
- writer.Add("bar_003", Constant_2x3<T>(3));
- writer.Add("bar_000", Constant_2x3<T>(0));
- writer.Add("bar_002", Constant_2x3<T>(2));
- writer.Add("bar_001", Constant_2x3<T>(1));
+ TF_EXPECT_OK(writer.Add("bar_003", Constant_2x3<T>(3)));
+ TF_EXPECT_OK(writer.Add("bar_000", Constant_2x3<T>(0)));
+ TF_EXPECT_OK(writer.Add("bar_002", Constant_2x3<T>(2)));
+ TF_EXPECT_OK(writer.Add("bar_001", Constant_2x3<T>(1)));
TF_ASSERT_OK(writer.Finish());
}
{
@@ -183,9 +183,11 @@ template <typename T>
void TestNonStandardShapes() {
{
BundleWriter writer(Env::Default(), Prefix("nonstandard"));
- writer.Add("scalar", Constant<T>(0, TensorShape()));
- writer.Add("non_standard0", Constant<T>(0, TensorShape({0, 1618})));
- writer.Add("non_standard1", Constant<T>(0, TensorShape({16, 0, 18})));
+ TF_EXPECT_OK(writer.Add("scalar", Constant<T>(0, TensorShape())));
+ TF_EXPECT_OK(
+ writer.Add("non_standard0", Constant<T>(0, TensorShape({0, 1618}))));
+ TF_EXPECT_OK(
+ writer.Add("non_standard1", Constant<T>(0, TensorShape({16, 0, 18}))));
TF_ASSERT_OK(writer.Finish());
}
{
@@ -323,12 +325,14 @@ TEST(TensorBundleTest, NonStandardShapes) {
TEST(TensorBundleTest, StringTensors) {
{
BundleWriter writer(Env::Default(), Prefix("foo"));
- writer.Add("string_tensor", Tensor(DT_STRING, TensorShape({1}))); // Empty.
- writer.Add("scalar", test::AsTensor<string>({"hello"}));
- writer.Add("strs", test::AsTensor<string>(
- {"hello", "", "x01", string(1 << 25, 'c')}));
+ TF_EXPECT_OK(writer.Add("string_tensor",
+ Tensor(DT_STRING, TensorShape({1})))); // Empty.
+ TF_EXPECT_OK(writer.Add("scalar", test::AsTensor<string>({"hello"})));
+ TF_EXPECT_OK(writer.Add(
+ "strs",
+ test::AsTensor<string>({"hello", "", "x01", string(1 << 25, 'c')})));
// Mixes in some floats.
- writer.Add("floats", Constant_2x3<float>(16.18));
+ TF_EXPECT_OK(writer.Add("floats", Constant_2x3<float>(16.18)));
TF_ASSERT_OK(writer.Finish());
}
{
@@ -355,7 +359,8 @@ TEST(TensorBundleTest, DirectoryStructure) {
Prefix("worker1")};
for (int i = 0; i < 2; ++i) {
BundleWriter writer(env, kBundlePrefixes[i]);
- writer.Add(strings::StrCat("tensor", i), Constant_2x3<float>(0.));
+ TF_EXPECT_OK(
+ writer.Add(strings::StrCat("tensor", i), Constant_2x3<float>(0.)));
TF_ASSERT_OK(writer.Finish());
}
@@ -396,8 +401,8 @@ TEST(TensorBundleTest, DirectoryStructure) {
TEST(TensorBundleTest, Error) {
{ // Dup keys.
BundleWriter writer(Env::Default(), Prefix("dup"));
- writer.Add("foo", Constant_2x3(1.f));
- writer.Add("foo", Constant_2x3(2.f));
+ TF_EXPECT_OK(writer.Add("foo", Constant_2x3(1.f)));
+ EXPECT_FALSE(writer.Add("foo", Constant_2x3(2.f)).ok());
EXPECT_TRUE(
StringPiece(writer.status().ToString()).contains("duplicate key"));
EXPECT_FALSE(writer.Finish().ok());
@@ -446,7 +451,7 @@ TEST(TensorBundleTest, Checksum) {
// Corrupts a float tensor.
{
BundleWriter writer(Env::Default(), Prefix("singleton"));
- writer.Add("foo", Constant_2x3(1.f));
+ TF_EXPECT_OK(writer.Add("foo", Constant_2x3(1.f)));
TF_ASSERT_OK(writer.Finish());
FlipByte("singleton", 0 /* corrupts any byte */);
@@ -458,7 +463,8 @@ TEST(TensorBundleTest, Checksum) {
{
auto WriteStrings = []() {
BundleWriter writer(Env::Default(), Prefix("strings"));
- writer.Add("foo", test::AsTensor<string>({"hello", "world"}));
+ TF_EXPECT_OK(
+ writer.Add("foo", test::AsTensor<string>({"hello", "world"})));
TF_ASSERT_OK(writer.Finish());
};
// Corrupts the first two bytes, which are the varint32-encoded lengths
@@ -482,7 +488,7 @@ TEST(TensorBundleTest, Checksum) {
TEST(TensorBundleTest, Endianness) {
BundleWriter writer(Env::Default(), Prefix("end"));
- writer.Add("key", Constant_2x3<float>(1.0));
+ TF_EXPECT_OK(writer.Add("key", Constant_2x3<float>(1.0)));
TF_ASSERT_OK(writer.Finish());
// Flips the endianness bit.
@@ -497,7 +503,7 @@ TEST(TensorBundleTest, Endianness) {
TEST(TensorBundleTest, TruncatedTensorContents) {
Env* env = Env::Default();
BundleWriter writer(env, Prefix("end"));
- writer.Add("key", Constant_2x3<float>(1.0));
+ TF_EXPECT_OK(writer.Add("key", Constant_2x3<float>(1.0)));
TF_ASSERT_OK(writer.Finish());
// Truncates the data file by one byte, so that we hit EOF.
@@ -517,7 +523,7 @@ TEST(TensorBundleTest, TruncatedTensorContents) {
TEST(TensorBundleTest, HeaderEntry) {
{
BundleWriter writer(Env::Default(), Prefix("b"));
- writer.Add("key", Constant_2x3<float>(1.0));
+ TF_EXPECT_OK(writer.Add("key", Constant_2x3<float>(1.0)));
TF_ASSERT_OK(writer.Finish());
}
diff --git a/tensorflow/core/util/tensor_slice_reader_test.cc b/tensorflow/core/util/tensor_slice_reader_test.cc
index a01706c78a..8545697886 100644
--- a/tensorflow/core/util/tensor_slice_reader_test.cc
+++ b/tensorflow/core/util/tensor_slice_reader_test.cc
@@ -410,7 +410,7 @@ static void VersionTest(const VersionDef& versions, const string& error) {
TF_ASSERT_OK(CreateTableTensorSliceBuilder(path, &builder));
builder->Add(kSavedTensorSlicesKey, contents);
int64 file_size;
- builder->Finish(&file_size);
+ TF_EXPECT_OK(builder->Finish(&file_size));
delete builder;
}
diff --git a/tensorflow/core/util/tensor_slice_set_test.cc b/tensorflow/core/util/tensor_slice_set_test.cc
index e5b31fb3bf..38ad6adf51 100644
--- a/tensorflow/core/util/tensor_slice_set_test.cc
+++ b/tensorflow/core/util/tensor_slice_set_test.cc
@@ -242,7 +242,7 @@ static void BM_RegisterOneByOne(int parts) {
TensorSliceSet slice_set(shape, DT_INT32);
for (int i = 0; i < parts; ++i) {
TensorSlice part({{i, 1}, {0, -1}});
- slice_set.Register(part, part.DebugString(), nullptr);
+ TF_CHECK_OK(slice_set.Register(part, part.DebugString(), nullptr));
}
}
diff --git a/tensorflow/core/util/tensor_slice_writer.cc b/tensorflow/core/util/tensor_slice_writer.cc
index 928d6fe72c..fbdd3ab83f 100644
--- a/tensorflow/core/util/tensor_slice_writer.cc
+++ b/tensorflow/core/util/tensor_slice_writer.cc
@@ -123,7 +123,7 @@ Status TensorSliceWriter::Finish() {
LOG(ERROR) << "Failed to rename file " << tmpname_ << " to " << filename_;
}
} else {
- Env::Default()->DeleteFile(tmpname_);
+ Env::Default()->DeleteFile(tmpname_).IgnoreError();
}
return s;
}
diff --git a/tensorflow/core/util/tensor_slice_writer_test.cc b/tensorflow/core/util/tensor_slice_writer_test.cc
index ad5a9a5b4f..0b6d6faf85 100644
--- a/tensorflow/core/util/tensor_slice_writer_test.cc
+++ b/tensorflow/core/util/tensor_slice_writer_test.cc
@@ -17,6 +17,7 @@ limitations under the License.
#include <array>
+#include "tensorflow/core/lib/core/status_test_util.h"
#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/io/path.h"
#include "tensorflow/core/platform/logging.h"
@@ -270,12 +271,14 @@ size_t BytesPerElementHelper(DT value) {
SavedSlice ss;
std::array<DT, 1> lo_data;
std::fill(lo_data.begin(), lo_data.end(), value);
- TensorSliceWriter::SaveData(lo_data.data(), lo_data.size(), &ss);
+ TF_EXPECT_OK(
+ TensorSliceWriter::SaveData(lo_data.data(), lo_data.size(), &ss));
int lo_byte_size = ss.ByteSize();
std::array<DT, 1001> hi_data;
std::fill(hi_data.begin(), hi_data.end(), value);
- TensorSliceWriter::SaveData(hi_data.data(), hi_data.size(), &ss);
+ TF_EXPECT_OK(
+ TensorSliceWriter::SaveData(hi_data.data(), hi_data.size(), &ss));
int hi_byte_size = ss.ByteSize();
return (hi_byte_size - lo_byte_size) / (hi_data.size() - lo_data.size());
diff --git a/tensorflow/python/util/kernel_registry.cc b/tensorflow/python/util/kernel_registry.cc
index b05c2ef04b..d451bbace2 100644
--- a/tensorflow/python/util/kernel_registry.cc
+++ b/tensorflow/python/util/kernel_registry.cc
@@ -49,7 +49,8 @@ string TryFindKernelClass(const string& serialized_node_def) {
}
string class_name = "";
tensorflow::FindKernelDef(tensorflow::DeviceType(parsed_name.type.c_str()),
- node_def, nullptr /* kernel_def */, &class_name);
+ node_def, nullptr /* kernel_def */, &class_name)
+ .IgnoreError();
return class_name;
}
diff --git a/tensorflow/stream_executor/cuda/cuda_platform.cc b/tensorflow/stream_executor/cuda/cuda_platform.cc
index 9f58be4302..3e7032f97a 100644
--- a/tensorflow/stream_executor/cuda/cuda_platform.cc
+++ b/tensorflow/stream_executor/cuda/cuda_platform.cc
@@ -141,7 +141,8 @@ port::StatusOr<StreamExecutor*> CudaPlatform::GetExecutor(
}
StreamExecutor* naked_executor = executor.ValueOrDie().get();
- executor_cache_.Insert(config, executor.ConsumeValueOrDie());
+ SE_RETURN_IF_ERROR(
+ executor_cache_.Insert(config, executor.ConsumeValueOrDie()));
return naked_executor;
}
diff --git a/tensorflow/tools/benchmark/benchmark_model.cc b/tensorflow/tools/benchmark/benchmark_model.cc
index 180600e3b4..10a20db956 100644
--- a/tensorflow/tools/benchmark/benchmark_model.cc
+++ b/tensorflow/tools/benchmark/benchmark_model.cc
@@ -454,9 +454,9 @@ int Main(int argc, char** argv) {
// Report the stats.
TestReporter reporter(output_prefix, benchmark_name);
- reporter.Initialize();
- reporter.Benchmark(num_runs, -1.0, wall_time, throughput);
- reporter.Close();
+ TF_QCHECK_OK(reporter.Initialize());
+ TF_QCHECK_OK(reporter.Benchmark(num_runs, -1.0, wall_time, throughput));
+ TF_QCHECK_OK(reporter.Close());
}
return 0;
diff --git a/tensorflow/tools/graph_transforms/freeze_requantization_ranges.cc b/tensorflow/tools/graph_transforms/freeze_requantization_ranges.cc
index 8faad4a442..c20521e41b 100644
--- a/tensorflow/tools/graph_transforms/freeze_requantization_ranges.cc
+++ b/tensorflow/tools/graph_transforms/freeze_requantization_ranges.cc
@@ -201,9 +201,8 @@ Status FreezeRequantizationRanges(const GraphDef& input_graph_def,
new_node->CopyFrom(node);
}
}
- RenameNodeInputs(frozen_graph_def, inputs_to_rename,
- std::unordered_set<string>(), output_graph_def);
- return Status::OK();
+ return RenameNodeInputs(frozen_graph_def, inputs_to_rename,
+ std::unordered_set<string>(), output_graph_def);
}
REGISTER_GRAPH_TRANSFORM("freeze_requantization_ranges",
diff --git a/tensorflow/tools/graph_transforms/insert_logging.cc b/tensorflow/tools/graph_transforms/insert_logging.cc
index c9d72f3d7d..39ead61b98 100644
--- a/tensorflow/tools/graph_transforms/insert_logging.cc
+++ b/tensorflow/tools/graph_transforms/insert_logging.cc
@@ -141,10 +141,8 @@ Status InsertLogging(const GraphDef& input_graph_def,
}
output_graph_def->Clear();
- RenameNodeInputs(logged_graph_def, inputs_to_rename, ignore_when_renaming,
- output_graph_def);
-
- return Status::OK();
+ return RenameNodeInputs(logged_graph_def, inputs_to_rename,
+ ignore_when_renaming, output_graph_def);
}
REGISTER_GRAPH_TRANSFORM("insert_logging", InsertLogging);
diff --git a/tensorflow/tools/graph_transforms/quantize_nodes.cc b/tensorflow/tools/graph_transforms/quantize_nodes.cc
index 11cc91cd77..4533074268 100644
--- a/tensorflow/tools/graph_transforms/quantize_nodes.cc
+++ b/tensorflow/tools/graph_transforms/quantize_nodes.cc
@@ -243,8 +243,9 @@ Status MergeDuplicateNodes(const GraphDef& input_graph_def,
}
// Update the graph so that any nodes that referred to removed inputs now
// pull from the remaining duplicate.
- RenameNodeInputs(merged_graph_def, inputs_to_rename,
- std::unordered_set<string>(), &current_graph_def);
+ TF_RETURN_IF_ERROR(RenameNodeInputs(merged_graph_def, inputs_to_rename,
+ std::unordered_set<string>(),
+ &current_graph_def));
} while (any_duplicates_found);
*output_graph_def = current_graph_def;
@@ -303,10 +304,8 @@ Status RemoveRedundantQuantizations(const GraphDef& input_graph_def,
},
{true}, &replaced_graph_def));
- RenameNodeInputs(replaced_graph_def, inputs_to_rename,
- std::unordered_set<string>(), output_graph_def);
-
- return Status::OK();
+ return RenameNodeInputs(replaced_graph_def, inputs_to_rename,
+ std::unordered_set<string>(), output_graph_def);
}
// If the user has passed in the input_min and input_max args, then we need to
@@ -380,10 +379,12 @@ Status QuantizePlaceholders(const GraphDef& input_graph_def,
}
GraphDef first_pass_graph_def;
- RenameNodeInputs(placeholder_graph_def, inputs_to_rename_first_pass,
- std::unordered_set<string>(), &first_pass_graph_def);
- RenameNodeInputs(first_pass_graph_def, inputs_to_rename_second_pass,
- std::unordered_set<string>(), output_graph_def);
+ TF_RETURN_IF_ERROR(
+ RenameNodeInputs(placeholder_graph_def, inputs_to_rename_first_pass,
+ std::unordered_set<string>(), &first_pass_graph_def));
+ TF_RETURN_IF_ERROR(
+ RenameNodeInputs(first_pass_graph_def, inputs_to_rename_second_pass,
+ std::unordered_set<string>(), output_graph_def));
return Status::OK();
}
diff --git a/tensorflow/tools/graph_transforms/remove_nodes.cc b/tensorflow/tools/graph_transforms/remove_nodes.cc
index 429dbdd0b1..20f40d0640 100644
--- a/tensorflow/tools/graph_transforms/remove_nodes.cc
+++ b/tensorflow/tools/graph_transforms/remove_nodes.cc
@@ -79,8 +79,9 @@ Status RemoveNodes(const GraphDef& input_graph_def,
},
{true}, &replaced_graph_def));
// Make sure all references to removed nodes now point to their inputs.
- RenameNodeInputs(replaced_graph_def, inputs_to_rename,
- std::unordered_set<string>(), &current_graph_def);
+ TF_RETURN_IF_ERROR(RenameNodeInputs(replaced_graph_def, inputs_to_rename,
+ std::unordered_set<string>(),
+ &current_graph_def));
} while (any_nodes_removed);
}
diff --git a/tensorflow/tools/graph_transforms/transform_graph_test.cc b/tensorflow/tools/graph_transforms/transform_graph_test.cc
index 6ea42fdad6..d9e2ccbd64 100644
--- a/tensorflow/tools/graph_transforms/transform_graph_test.cc
+++ b/tensorflow/tools/graph_transforms/transform_graph_test.cc
@@ -145,33 +145,34 @@ class TransformGraphTest : public ::testing::Test {
void TestParseTransformParameters() {
TransformParameters params_list;
- ParseTransformParameters("foo", &params_list);
+ TF_EXPECT_OK(ParseTransformParameters("foo", &params_list));
EXPECT_EQ(1, params_list.size());
EXPECT_EQ("foo", params_list[0].first);
EXPECT_TRUE(params_list[0].second.empty());
- ParseTransformParameters("foo bar", &params_list);
+ TF_EXPECT_OK(ParseTransformParameters("foo bar", &params_list));
EXPECT_EQ(2, params_list.size());
EXPECT_EQ("foo", params_list[0].first);
EXPECT_TRUE(params_list[0].second.empty());
EXPECT_EQ("bar", params_list[1].first);
EXPECT_TRUE(params_list[1].second.empty());
- ParseTransformParameters("foo() bar()", &params_list);
+ TF_EXPECT_OK(ParseTransformParameters("foo() bar()", &params_list));
EXPECT_EQ(2, params_list.size());
EXPECT_EQ("foo", params_list[0].first);
EXPECT_TRUE(params_list[0].second.empty());
EXPECT_EQ("bar", params_list[1].first);
EXPECT_TRUE(params_list[1].second.empty());
- ParseTransformParameters("foo(bob_something=sue)", &params_list);
+ TF_EXPECT_OK(
+ ParseTransformParameters("foo(bob_something=sue)", &params_list));
EXPECT_EQ(1, params_list.size());
EXPECT_EQ("foo", params_list[0].first);
EXPECT_EQ(1, params_list[0].second.count("bob_something"));
EXPECT_EQ(1, params_list[0].second["bob_something"].size());
EXPECT_EQ("sue", params_list[0].second["bob_something"][0]);
- ParseTransformParameters("bar(a=1, b=2, a=3)", &params_list);
+ TF_EXPECT_OK(ParseTransformParameters("bar(a=1, b=2, a=3)", &params_list));
EXPECT_EQ(1, params_list.size());
EXPECT_EQ("bar", params_list[0].first);
EXPECT_EQ(1, params_list[0].second.count("a"));
@@ -182,7 +183,8 @@ class TransformGraphTest : public ::testing::Test {
EXPECT_EQ(1, params_list[0].second["b"].size());
EXPECT_EQ("2", params_list[0].second["b"][0]);
- ParseTransformParameters("bar(a=\"1\", b=\"1,2,3\", a=3)", &params_list);
+ TF_EXPECT_OK(ParseTransformParameters("bar(a=\"1\", b=\"1,2,3\", a=3)",
+ &params_list));
EXPECT_EQ(1, params_list.size());
EXPECT_EQ("bar", params_list[0].first);
EXPECT_EQ(1, params_list[0].second.count("a"));
diff --git a/tensorflow/tools/graph_transforms/transform_utils.cc b/tensorflow/tools/graph_transforms/transform_utils.cc
index 310c331e8f..2c639202b5 100644
--- a/tensorflow/tools/graph_transforms/transform_utils.cc
+++ b/tensorflow/tools/graph_transforms/transform_utils.cc
@@ -277,7 +277,7 @@ string NodeMatch::DebugString() const {
}
GraphMatcher::GraphMatcher(const GraphDef& graph_def) {
- SortByExecutionOrder(graph_def, &graph_def_);
+ SortByExecutionOrder(graph_def, &graph_def_).IgnoreError();
MapNamesToNodes(graph_def_, &node_map_);
}
@@ -362,7 +362,7 @@ Status ReplaceMatchingOpTypes(
// Start off by retrieving all the matching subgraphs.
GraphMatcher matcher(input_graph_def);
std::vector<NodeMatch> matches;
- matcher.GetOpTypeMatches(pattern, &matches);
+ TF_RETURN_IF_ERROR(matcher.GetOpTypeMatches(pattern, &matches));
// Do some housekeeping so we can easily look up the resulting matches given
// a node name.