()
| 772 | |
| 773 | |
| 774 | def 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 | |
| 819 | def test_direct_return(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…