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

Function test_incremental_solving

tests/python/relax/test_dataflow_pattern.py:808–834  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

806
807
808def test_incremental_solving():
809 @R.function
810 def simple_chain(x: R.Tensor((32, 32), "float32")) -> R.Tensor:
811 with R.dataflow():
812 # relu -> sigmoid -> neg
813 lv0 = R.call_dps_packed("extern_relu", (x), R.Tensor((32, 32), dtype="float32"))
814 lv1 = R.call_dps_packed("extern_sigmoid", (lv0), R.Tensor((32, 32), dtype="float32"))
815 lv2 = R.call_dps_packed("extern_neg", (lv1), R.Tensor((32, 32), dtype="float32"))
816 R.output(lv2)
817 return lv2
818
819 relu = is_call_dps_packed("extern_relu")
820 sigmoid = is_call_dps_packed("extern_sigmoid")
821 neg = is_call_dps_packed("extern_neg")
822
823 with PatternContext() as ctx0:
824 relu >> sigmoid
825 with PatternContext(incremental=True) as ctx1:
826 # because we are doing incremental solving
827 # relu >> sigmoid is still a constraint in this context.
828 # that said the total constraint is:
829 # relu >> sigmoid >> neg
830 sigmoid >> neg
831 assert ctx1.match_dfb(simple_chain.body.blocks[0])
832
833 # match relue -> sigmoid
834 assert ctx0.match_dfb(simple_chain.body.blocks[0])
835
836
837def test_incremental_solving_counter():

Callers

nothing calls this directly

Calls 3

is_call_dps_packedFunction · 0.85
PatternContextClass · 0.85
match_dfbMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…