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

Function test_match_cast

tests/python/relax/test_expr.py:108–129  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

106
107
108def test_match_cast() -> None:
109 # match_cast([16, 8], [m, n])
110 m = tirx.Var("m", dtype="int64")
111 n = tirx.Var("n", dtype="int64")
112 shape = rx.const([16, 8], "int32")
113 var = rx.Var("v0", R.Shape())
114 b0 = rx.MatchCast(var, shape, R.Tensor([m, n], "int32"))
115 assert b0.value == shape
116 assert b0.pattern[0] == m
117 assert b0.pattern[1] == n
118 assert b0.var is not None
119
120 # var1: R.Tensor((m, n), "float32") =
121 # match_cast(var0: R.Tensor("float32", ndim=-1), R.Tensor((m, n), "float32"))
122 value = rx.Var("value", R.Tensor("float32", ndim=-1))
123
124 var = rx.Var("v1", R.Tensor([m, n], "float32"))
125 b1 = rx.MatchCast(var, value, R.Tensor([m, n], "float32"))
126 assert b1.value == value
127 assert b1.pattern[0] == m
128 assert b1.pattern[1] == n
129 assert b1.var is not None
130
131
132def test_match_cast() -> None:

Callers

nothing calls this directly

Calls 4

ShapeMethod · 0.80
TensorMethod · 0.80
_check_json_roundtripFunction · 0.70
same_asMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…