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

Function test_tensor_with_vdevice

tests/python/relax/test_tvmscript_parser.py:774–816  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

772
773
774def test_tensor_with_vdevice():
775 vdevices = [
776 VDevice("llvm"),
777 VDevice("cuda", 0),
778 VDevice("metal", 0, "global"),
779 VDevice({"kind": "cuda", "arch": "sm_80"}, 0),
780 ]
781
782 @I.ir_module(s_tir=True)
783 class TestModule:
784 I.module_attrs({"attr": 10})
785 I.module_global_infos(
786 {
787 "vdevice": [
788 I.vdevice("llvm"),
789 I.vdevice("cuda", 0),
790 I.vdevice("metal", 0, "global"),
791 I.vdevice({"kind": "cuda", "arch": "sm_80"}, 0),
792 ]
793 }
794 )
795
796 @R.function
797 def foo(
798 a: R.Tensor((128, 128), "float32", "cuda:1"),
799 b: R.Tensor((128, 128), "float32", "llvm"),
800 c: R.Tensor((128, 128), "float32", "vdevice:3"),
801 ) -> R.Tensor((128, 128), "float32", "cuda:1"):
802 s = R.add(a, c)
803 return s
804
805 a = relax.Var("a", R.Tensor((128, 128), "float32", vdevices[3]))
806 b = relax.Var("b", R.Tensor((128, 128), "float32", vdevices[0]))
807 c = relax.Var("c", R.Tensor((128, 128), "float32", vdevices[3]))
808 bb = relax.BlockBuilder()
809 with bb.function("foo", (a, b, c)):
810 out = bb.emit(relax.op.add(a, c))
811 bb.emit_func_output(out)
812 mod = bb.get()
813 mod = mod.with_attr("attr", 10)
814 mod.update_global_info("vdevice", vdevices)
815
816 _check(TestModule, mod)
817
818
819def test_direct_return():

Callers

nothing calls this directly

Calls 10

functionMethod · 0.95
emitMethod · 0.95
emit_func_outputMethod · 0.95
getMethod · 0.95
VDeviceClass · 0.90
TensorMethod · 0.80
update_global_infoMethod · 0.80
_checkFunction · 0.70
addMethod · 0.45
with_attrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…