diff options
author | Skye Wanderman-Milne <skyewm@google.com> | 2018-01-03 15:40:03 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-01-03 15:43:22 -0800 |
commit | 41ceb56c7f8e54dc6a11c0349c112404bdb3db54 (patch) | |
tree | 7020324ced33d35786107a79f3660dea75c0243c /tensorflow/core/common_runtime/function_test.cc | |
parent | 7753ab0b4aa3ff989b61725cbf42c4c57e176999 (diff) |
Run C++ control flow validation on FunctionDefs before running.
Clients should ideally prevent such functions from being created in
the first place, but we still want the runtime to be robust to
malformed functions. Trying to run functions with invalid control flow
constructs can result in crashes or hangs, so we want to catch it
before running.
PiperOrigin-RevId: 180727589
Diffstat (limited to 'tensorflow/core/common_runtime/function_test.cc')
-rw-r--r-- | tensorflow/core/common_runtime/function_test.cc | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tensorflow/core/common_runtime/function_test.cc b/tensorflow/core/common_runtime/function_test.cc index 7b553c2dcd..d4181ff48c 100644 --- a/tensorflow/core/common_runtime/function_test.cc +++ b/tensorflow/core/common_runtime/function_test.cc @@ -783,6 +783,16 @@ TEST_F(FunctionLibraryRuntimeTest, Error_InstantiaionError) { "type attr not found"); } +TEST_F(FunctionLibraryRuntimeTest, Error_BadControlFlow) { + Init({test::function::InvalidControlFlow()}); + auto x = test::AsTensor<int32>({0}); + DCHECK_EQ(x.dtype(), DT_INT32); + Tensor y; + HasError(InstantiateAndRun(flr0_, "InvalidControlFlow", {}, {x}, {&y}), + "The node 'add' has inputs from different frames. The input 'enter' " + "is in frame 'while'. The input 'i' is in frame ''."); +} + TEST_F(FunctionLibraryRuntimeTest, Gradient_XTimesTwo) { Init({test::function::XTimesTwo(), test::function::XTimesFour(), test::function::XTimes16()}); |