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

Function test_emit_te_kwargs

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

Source from the content-addressed store, hash-verified

227
228
229def test_emit_te_kwargs(register_te_grads):
230 # Build the target module using emit_te
231 def f_mul2(src):
232 return tvm.te.compute(src.shape, lambda *idx: src[idx] * T.float32(2), name="f_mul2")
233
234 a = relax.Var("a", relax.TensorStructInfo([5, 5], "float32"))
235
236 bb = relax.BlockBuilder()
237 with bb.function("main", [a]):
238 with bb.dataflow():
239 d = bb.emit(
240 bb.call_te_with_grad(
241 f_mul2,
242 a,
243 primfunc_name_hint="f_mul",
244 te_grad_name="f_mulk_grad",
245 te_grad_kwargs={"k": T.float32(2)},
246 )
247 )
248 out = bb.emit_output(R.sum(d))
249 bb.emit_func_output(out)
250
251 Before = bb.get()
252 After = Gradient("main")(Before)
253
254 assert_structural_equal(After, get_expected_2())
255
256
257def test_call_tir_kwargs(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_2Function · 0.85
sumMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…