MCPcopy Create free account
hub / github.com/apache/tvm / test_if_complex_condition

Function test_if_complex_condition

tests/python/relax/test_analysis_well_formed.py:291–327  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

289
290
291def 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
330def test_tuple_get_item_nested():

Callers

nothing calls this directly

Calls 3

build_functionFunction · 0.85
TensorMethod · 0.80
from_exprMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…