Skip to content

Commit

Permalink
add opencl codegen unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuan-Chuan-YUE committed Aug 18, 2021
1 parent 78dc373 commit eca13b2
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions tests/python/unittest/test_target_codegen_opencl.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,27 @@ def check_max(dev, n, dtype):
check_max(dev, 1, "float32")
check_max(dev, 1, "float64")

@tvm.testing.requires_gpu
@tvm.testing.requires_opencl
def test_opencl_erf():
def check_erf(dev, n, dtype):
A = te.placeholder((n,), name="A", dtype=dtype)
C = te.compute(A.shape, lambda *i: te.erf(A(*i)), name="C")
s = te.create_schedule(C.op)
s[C].bind(s[C].op.axis[0], te.thread_axis("threadIdx.x"))
fun = tvm.build(s, [A, C], target)
a = tvm.nd.empty((n,), A.dtype, dev)
c = tvm.nd.empty((n,), A.dtype, dev)
# Only need to test compiling here
fun(a, c)

dev = tvm.device(target, 0)

check_erf(dev, 1, "float32")
#check_erf(dev, 1, "float16")


if __name__ == "__main__":
test_opencl_ternary_expression()
test_opencl_inf_nan()
#test_opencl_ternary_expression()
#test_opencl_inf_nan()
test_opencl_erf()

0 comments on commit eca13b2

Please sign in to comment.