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

Function test_emit_te

tests/python/relax/test_transform_gradient_te_register.py:121–145  ·  view source on GitHub ↗
(register_te_grads)

Source from the content-addressed store, hash-verified

119
120
121def test_emit_te(register_te_grads):
122 # Build the target module using emit_te
123 def f_mul(src1, src2):
124 def mul(*idx):
125 return src1[idx] * src2[idx]
126
127 return tvm.te.compute(src1.shape, mul, name="f_mul")
128
129 a = relax.Var("a", relax.TensorStructInfo([5, 5], "float32"))
130 b = relax.Var("b", relax.TensorStructInfo([5, 5], "float32"))
131
132 bb = relax.BlockBuilder()
133 with bb.function("main", [a, b]):
134 with bb.dataflow():
135 d = bb.emit(
136 bb.call_te_with_grad(
137 f_mul, a, b, primfunc_name_hint="f_mul", te_grad_name="f_mul_grad"
138 )
139 )
140 out = bb.emit_output(R.sum(d))
141 bb.emit_func_output(out)
142
143 Before = bb.get()
144 After = Gradient("main")(Before)
145 assert_structural_equal(After, get_expected_1())
146
147
148def test_call_tir(register_te_grads):

Callers

nothing calls this directly

Calls 11

functionMethod · 0.95
dataflowMethod · 0.95
emitMethod · 0.95
call_te_with_gradMethod · 0.95
emit_outputMethod · 0.95
emit_func_outputMethod · 0.95
getMethod · 0.95
GradientFunction · 0.90
assert_structural_equalFunction · 0.90
get_expected_1Function · 0.85
sumMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…