| 1222 | } |
| 1223 | |
| 1224 | void CreateSwitchN(const Scope& scope, Input data, Input output_index, |
| 1225 | int64 num_outs, OutputList* outputs) { |
| 1226 | if (!scope.ok()) return; |
| 1227 | auto _data = ops::AsNodeOut(scope, data); |
| 1228 | if (!scope.ok()) return; |
| 1229 | auto _output_index = ops::AsNodeOut(scope, output_index); |
| 1230 | if (!scope.ok()) return; |
| 1231 | Node* ret; |
| 1232 | const auto unique_name = scope.GetUniqueNameForOp("_SwitchN"); |
| 1233 | auto builder = NodeBuilder(unique_name, "_SwitchN") |
| 1234 | .Input(_data) |
| 1235 | .Input(_output_index) |
| 1236 | .Attr("num_outs", num_outs); |
| 1237 | scope.UpdateBuilder(&builder); |
| 1238 | scope.UpdateStatus(builder.Finalize(scope.graph(), &ret)); |
| 1239 | if (!scope.ok()) return; |
| 1240 | scope.UpdateStatus(scope.DoShapeInference(ret)); |
| 1241 | for (int32 i = 0; i < ret->num_outputs(); ++i) { |
| 1242 | outputs->push_back(Output(ret, i)); |
| 1243 | } |
| 1244 | } |
| 1245 | |
| 1246 | TEST(DeadnessAnalysisTest, Constant1_SwitchN_2Branches_DoesNotFail) { |
| 1247 | Scope root = Scope::NewRootScope().ExitOnError(); |
no test coverage detected