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

Function test_tir_var

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

Source from the content-addressed store, hash-verified

356
357
358def test_tir_var(register_te_grads):
359 def f_mul(src1, src2):
360 def mul(*idx):
361 return src1[idx] * src2[idx]
362
363 return tvm.te.compute(src1.shape, mul, name="f_mul")
364
365 n = tirx.Var("n", "int64")
366 a = relax.Var("a", relax.TensorStructInfo([n, n], "float32"))
367 b = relax.Var("b", relax.TensorStructInfo([n, n], "float32"))
368
369 bb = relax.BlockBuilder()
370 with bb.function("main", [a, b]):
371 with bb.dataflow():
372 d = bb.emit(
373 bb.call_te_with_grad(
374 f_mul, a, b, primfunc_name_hint="f_mul", te_grad_name="f_mul_grad"
375 )
376 )
377 out = bb.emit_output(R.sum(d))
378 bb.emit_func_output(out)
379
380 Before = bb.get()
381 After = Gradient("main")(Before)
382 assert_structural_equal(After, get_expected_3())
383 relax.analysis.well_formed(After)
384
385
386if __name__ == "__main__":

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_3Function · 0.85
sumMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…