()
| 289 | |
| 290 | |
| 291 | def test_if_complex_condition(): |
| 292 | # Error: If condition must be a leaf expression |
| 293 | cond_tuple = rx.Tuple([cond]) |
| 294 | cond_idx = rx.TupleGetItem(cond_tuple, 0) |
| 295 | if_node = rx.If(cond_idx, rx.SeqExpr([], x), rx.SeqExpr([], x)) |
| 296 | blocks = [ |
| 297 | rx.BindingBlock( |
| 298 | [ |
| 299 | rx.VarBinding( |
| 300 | rx.Var("gv1", R.Tensor([m, n], "float32")), |
| 301 | if_node, |
| 302 | ) |
| 303 | ] |
| 304 | ) |
| 305 | ] |
| 306 | func = build_function(blocks) |
| 307 | mod = tvm.IRModule.from_expr(func) |
| 308 | assert not rx.analysis.check_well_formed(mod, check_struct_info=False) |
| 309 | |
| 310 | cond_var = rx.Var("q", R.Tensor([], "bool")) |
| 311 | new_if = rx.If(cond_var, rx.SeqExpr([], x), rx.SeqExpr([], x)) |
| 312 | blocks = [ |
| 313 | rx.BindingBlock( |
| 314 | [ |
| 315 | rx.VarBinding(cond_var, cond_idx), |
| 316 | rx.VarBinding( |
| 317 | rx.Var("gv1", R.Tensor([m, n], "float32")), |
| 318 | new_if, |
| 319 | ), |
| 320 | ] |
| 321 | ) |
| 322 | ] |
| 323 | func = build_function(blocks) |
| 324 | mod = tvm.IRModule.from_expr(func) |
| 325 | # apply normalization to fill in struct_info_ |
| 326 | normalized = rx.transform.Normalize()(mod) |
| 327 | rx.analysis.well_formed(normalized, check_struct_info=True) |
| 328 | |
| 329 | |
| 330 | def test_tuple_get_item_nested(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…