polish example

This commit is contained in:
Dun Liang 2022-02-24 21:21:04 +08:00
parent 120057640c
commit c5acaa2474
2 changed files with 7 additions and 3 deletions

View File

@ -146,12 +146,13 @@ struct CodeOp : Op {
a = jt.random([10])
b = jt.code(a.shape, a.dtype, [a],
cpu_src='''
LOGir << HAHAHA;
@out0(0) = HAHAHA;
''')
# HAHAHA is defined in flags below
# /any/include/path can be change to any path you want to include
b.compile_options = {"FLAGS: -DHAHAHA=233 -I/any/include/path ": 1}
b.sync()
print(b[0])
# will output 233
CUDA Example-1::

View File

@ -34,9 +34,12 @@ class TestCodeOp(unittest.TestCase):
b = jt.code(a.shape, a.dtype, [a],
cpu_src='''
LOGir << HAHAHA;
@out0(0) = HAHAHA;
''')
b.compile_options = {"FLAGS: -DHAHAHA=233 -I/any/include/path ": 1}
b.sync()
# print(b[0])
assert b[0].item() == 233
def test_use_func(self):