| 65 | namespace { |
| 66 | |
| 67 | TEST_F(FunctionalizeCondTest, JoinCondStates) { |
| 68 | Tensor pred_tensor(DT_BOOL, TensorShape()); |
| 69 | pred_tensor.flat<bool>().setZero(); |
| 70 | Node* pred = test::graph::Constant(graph_.get(), pred_tensor, "pred"); |
| 71 | Tensor val_tensor(DT_INT32, TensorShape()); |
| 72 | val_tensor.flat<int>().setZero(); |
| 73 | Node* val = test::graph::Constant(graph_.get(), val_tensor, "val"); |
| 74 | Node* m = test::graph::Merge(graph_.get(), val, val); |
| 75 | |
| 76 | StateMap::CondId then_branch; |
| 77 | { |
| 78 | StateMap::CondState ss; |
| 79 | ss.insert(std::make_pair(OutputTensor(pred, 0), BranchType::kThenBranch)); |
| 80 | then_branch = GetUniqueId(ss); |
| 81 | } |
| 82 | StateMap::CondId else_branch; |
| 83 | { |
| 84 | StateMap::CondState ss; |
| 85 | ss.insert(std::make_pair(OutputTensor(pred, 0), BranchType::kElseBranch)); |
| 86 | else_branch = GetUniqueId(ss); |
| 87 | } |
| 88 | |
| 89 | // An non-merge op with inputs from then and else branch. |
| 90 | Status status = JoinCondStatesNonMerge(then_branch, else_branch).status(); |
| 91 | EXPECT_TRUE(errors::IsInvalidArgument(status)); |
| 92 | |
| 93 | // Merge between then and else branch. |
| 94 | auto joined_or = JoinCondStatesMerge(m, then_branch, else_branch); |
| 95 | TF_EXPECT_OK(joined_or.status()); |
| 96 | StateMap::CondId joined = joined_or.ValueOrDie(); |
| 97 | |
| 98 | // Merge between then branch and both branch. |
| 99 | auto t = JoinCondStatesNonMerge(then_branch, joined); |
| 100 | // Note: this is OK in terms of constraint predication, but |
| 101 | TF_EXPECT_OK(t.status()); |
| 102 | } |
| 103 | |
| 104 | TEST_F(FunctionalizeCondTest, JoinCondStatesMergeWithInputNotInCondContext) { |
| 105 | Tensor val_tensor(DT_INT32, TensorShape()); |
nothing calls this directly
no test coverage detected