MCPcopy Index your code
hub / github.com/apache/tvm / test_dataflow_block

Function test_dataflow_block

tests/python/relax/test_tvmscript_ir_builder.py:124–167  ·  view source on GitHub ↗

@R.function def foo(x: Tensor((128, 128), "float32")) -> Tensor(None, "float32", ndim = 2): # block 0 with R.dataflow(): lv0 = R.call_dps_packed("extern_func", (x,), R.Tensor((128, 128), dtype="float32")) gv: Tensor((128, 128), "float32") = lv0

()

Source from the content-addressed store, hash-verified

122
123
124def test_dataflow_block():
125 """
126 @R.function
127 def foo(x: Tensor((128, 128), "float32")) -> Tensor(None, "float32", ndim = 2):
128 # block 0
129 with R.dataflow():
130 lv0 = R.call_dps_packed("extern_func", (x,), R.Tensor((128, 128), dtype="float32"))
131 gv: Tensor((128, 128), "float32") = lv0
132 R.output(gv)
133 return gv
134 """
135 # create with Script IRBuilder
136 with IRBuilder() as ir_builder:
137 with R.function():
138 R.func_name("foo")
139 x = R.arg("x", relax.TensorStructInfo((128, 128), "float32"))
140 with R.dataflow() as df:
141 lv0 = R.emit(
142 R.call_dps_packed(
143 "extern_func", x, relax.TensorStructInfo((128, 128), dtype="float32")
144 )
145 )
146 IRBuilder.name("lv0", lv0)
147 gv = R.emit(lv0)
148 IRBuilder.name("gv", gv)
149 R.output(gv)
150 (gv,) = df.output_vars
151 R.func_ret_value(gv)
152 func = ir_builder.get()
153
154 # create with BlockBuilder
155 x = relax.Var("x", relax.TensorStructInfo((128, 128), "float32"))
156 bb = relax.BlockBuilder()
157 with bb.function("foo", (x,)):
158 with bb.dataflow():
159 lv0 = bb.emit(
160 relax.call_dps_packed(
161 "extern_func", x, relax.TensorStructInfo((128, 128), dtype="float32")
162 )
163 )
164 gv = bb.emit_output(lv0)
165 bb.emit_func_output(gv)
166
167 tvm.ir.assert_structural_equal(func, bb.get()["foo"])
168
169
170def test_regression_py_print():

Callers

nothing calls this directly

Calls 12

dataflowMethod · 0.95
emitMethod · 0.95
functionMethod · 0.95
emit_outputMethod · 0.95
emit_func_outputMethod · 0.95
getMethod · 0.95
IRBuilderClass · 0.90
call_dps_packedMethod · 0.80
outputMethod · 0.80
functionMethod · 0.45
nameMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…