(tvm_intrin, np_func, dtype)
| 674 | ] |
| 675 | |
| 676 | def run_test(tvm_intrin, np_func, dtype): |
| 677 | if dtype == "float16" and not have_fp16(tvm.cuda(0).compute_version): |
| 678 | print("Skip because gpu does not have fp16 support") |
| 679 | return |
| 680 | # set of intrinsics does not support fp16 yet. |
| 681 | skip_set = { |
| 682 | tvm.tirx.abs, |
| 683 | tvm.tirx.round, |
| 684 | tvm.tirx.tan, |
| 685 | tvm.tirx.atan, |
| 686 | tvm.tirx.tanh, |
| 687 | tvm.tirx.cosh, |
| 688 | tvm.tirx.sinh, |
| 689 | } |
| 690 | if dtype == "float16" and tvm_intrin in skip_set: |
| 691 | print(f"Skip because '{tvm_intrin.__name__}' does not support fp16 yet") |
| 692 | return |
| 693 | |
| 694 | n = 128 |
| 695 | f = sched(tvm_intrin, dtype, n) |
| 696 | dev = tvm.cuda(0) |
| 697 | a = tvm.runtime.tensor(np.random.uniform(0, 1, size=n).astype(dtype), dev) |
| 698 | b = tvm.runtime.tensor(np.zeros(shape=(n,)).astype(dtype), dev) |
| 699 | f(a, b) |
| 700 | tvm.testing.assert_allclose(b.numpy(), np_func(a.numpy()), atol=1e-3, rtol=1e-3) |
| 701 | |
| 702 | for func in test_funcs: |
| 703 | run_test(*func, "float32") |
no test coverage detected
searching dependent graphs…