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

Function test_operators

tests/python/relax/test_ast_printer.py:553–581  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

551
552
553def test_operators():
554 @R.function
555 def foo(x: R.Tensor):
556 return R.unique(x, sorted=True, axis=-1)
557
558 foo_str = strip_whitespace(
559 dump_ast(
560 foo,
561 include_struct_info_annotations=False,
562 )
563 )
564 assert 'Op(name="relax.unique")' in foo_str
565 # the sorted argument is true, so it will be a PrimValue of 1
566 assert "PrimExpr(value=`T.int64(1)`)" in foo_str
567 # axis is -1
568 assert "PrimExpr(value=`T.int64(-1)`)" in foo_str
569
570 @R.function(pure=False)
571 def bar(x: R.Tensor):
572 return R.print(x, format="{}")
573
574 bar_str = strip_whitespace(
575 dump_ast(
576 bar,
577 include_struct_info_annotations=False,
578 )
579 )
580 # the format string is a StringImm argument
581 assert 'StringImm(value="{}")' in bar_str
582
583
584def test_print_struct_info_annotation_non_var():

Callers

nothing calls this directly

Calls 2

dump_astFunction · 0.90
strip_whitespaceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…