| 23 | namespace tensorflow { |
| 24 | |
| 25 | TEST(ControlFlowOpsTest, Merge_ShapeFn) { |
| 26 | ShapeInferenceTestOp op("Merge"); |
| 27 | |
| 28 | int n = 3; |
| 29 | std::vector<NodeDefBuilder::NodeOut> src_list; |
| 30 | src_list.reserve(n); |
| 31 | for (int i = 0; i < n; ++i) src_list.emplace_back("a", 0, DT_FLOAT); |
| 32 | TF_ASSERT_OK(NodeDefBuilder("test", "Merge") |
| 33 | .Input(src_list) |
| 34 | .Attr("N", n) |
| 35 | .Finalize(&op.node_def)); |
| 36 | |
| 37 | // The second output should always be scalar. |
| 38 | // The first output should be unknown if any of the inputs are unknown, or |
| 39 | // if two inputs disagree about rank. |
| 40 | INFER_OK(op, "?;?;?", "?;[]"); |
| 41 | INFER_OK(op, "[2,1];?;[2,1]", "?;[]"); |
| 42 | INFER_OK(op, "[2,1];[2,1];?", "?;[]"); |
| 43 | INFER_OK(op, "[2,1];[2,1];[3,1,2]", "?;[]"); |
| 44 | // If inputs on rank, but disagree on specific dimensions, those dimensions |
| 45 | // should be unknown. |
| 46 | INFER_OK(op, "[2,1];[2,1];[3,1]", "[?,d0_1];[]"); |
| 47 | INFER_OK(op, "[2,1];[2,2];[3,1]", "[?,?];[]"); |
| 48 | // Otherwise, all inputs agree and we return the first input. |
| 49 | INFER_OK(op, "[2,1];[2,1];[2,1]", "in0;[]"); |
| 50 | } |
| 51 | |
| 52 | TEST(ControlFlowOpsTest, SwitchN_ShapeFn) { |
| 53 | ShapeInferenceTestOp op("_SwitchN"); |
nothing calls this directly
no test coverage detected