| 46 | } |
| 47 | |
| 48 | TEST(ValidateControlFlowTest, InputsFromDifferentFrames) { |
| 49 | Scope scope = Scope::NewRootScope().ExitOnError(); |
| 50 | std::vector<Output> inputs; |
| 51 | inputs.push_back(ops::Placeholder(scope, DT_INT32)); |
| 52 | std::vector<Output> outputs; |
| 53 | TF_ASSERT_OK(ops::BuildWhileLoop(scope.NewSubScope("outer"), inputs, |
| 54 | LessThanTenCond, NestedLoopBody, |
| 55 | "outer_loop", &outputs)); |
| 56 | std::unique_ptr<Graph> graph(new Graph(OpRegistry::Global())); |
| 57 | TF_ASSERT_OK(scope.ToGraph(graph.get())); |
| 58 | // {inner/Enter', 'outer/Switch'} --> 'inner/Merge'. 'inner/Enter' is in frame |
| 59 | // 'inner_loop'. 'outer/Switch' is in frame 'outer_loop'. |
| 60 | std::vector<ControlFlowInfo> info; |
| 61 | Status status = BuildControlFlowInfo(graph.get(), &info); |
| 62 | EXPECT_FALSE(status.ok()); |
| 63 | EXPECT_TRUE(absl::StrContains(status.error_message(), |
| 64 | "has inputs from different frames")) |
| 65 | << status.error_message(); |
| 66 | EXPECT_TRUE(absl::StrContains(status.error_message(), |
| 67 | "{{node outer/body/inner/Merge}}")) |
| 68 | << status.error_message(); |
| 69 | EXPECT_TRUE(absl::StrContains(status.error_message(), |
| 70 | "{{node outer/body/inner/Enter}}")) |
| 71 | << status.error_message(); |
| 72 | EXPECT_TRUE( |
| 73 | absl::StrContains(status.error_message(), "{{node outer/Switch}}")) |
| 74 | << status.error_message(); |
| 75 | } |
| 76 | |
| 77 | TEST(ValidateControlFlowTest, MismatchedParentFrames) { |
| 78 | Scope scope = Scope::NewRootScope().ExitOnError(); |
nothing calls this directly
no test coverage detected