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

Function test_two_matmul

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

Source from the content-addressed store, hash-verified

591
592
593def test_two_matmul():
594 # Same as Figure 2(a) in TASO paper.
595 @tvm.script.ir_module
596 class MatMul2:
597 @R.function
598 def main(
599 a: R.Tensor((32, 16), "float32"),
600 b: R.Tensor((16, 48), "float32"),
601 c: R.Tensor((48, 32), "float32"),
602 ) -> R.Tensor:
603 with R.dataflow():
604 lv0 = R.call_dps_packed("matmul", (a, b), R.Tensor((32, 48), dtype="float32"))
605 lv1 = R.call_dps_packed("matmul", (lv0, c), R.Tensor((32, 32), dtype="float32"))
606 R.output(lv1)
607 return lv1
608
609 with PatternContext() as ctx:
610 is_call_dps_packed("matmul") >> is_call_dps_packed("matmul")
611 dfb = MatMul2["main"].body.blocks[0]
612 assert ctx.match_dfb(dfb)
613
614 with PatternContext() as ctx:
615 is_call_dps_packed("matmul").has_shape([32, 48]) >> is_call_dps_packed("matmul").has_shape(
616 [32, 32]
617 )
618 dfb = MatMul2["main"].body.blocks[0]
619 assert ctx.match_dfb(dfb)
620
621 with PatternContext() as ctx:
622 is_call_dps_packed("matmul") >> is_call_dps_packed("matmul") >> is_call_dps_packed("matmul")
623 dfb = MatMul2["main"].body.blocks[0]
624 # Three MatMul cannot match
625 assert not ctx.match_dfb(dfb)
626
627
628def test_concat_mm_split():

Callers

nothing calls this directly

Calls 4

PatternContextClass · 0.85
is_call_dps_packedFunction · 0.85
match_dfbMethod · 0.80
has_shapeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…