Closed janboeye closed 6 years ago
After you build the function, you can get the opencl source code.
s = tvm.create_schedule(C.op)
func = tvm.build(s, [A, B, C], target='opencl')
src = func.imported_modules[0].get_source()
Variable src
is a string of opencl code. Then you can write it to a file.
See the tutorial (http://docs.tvmlang.org/tutorials/get_started.html) for more explanation on this example.
For the convolution example in my blog post, I get the source code by uncommenting line 135 https://github.com/merrymercy/tvm-mali/blob/8b0ba396607839397ff1884051d3e8d58c0e4298/layer-test/test_conv2d.py#L131-L135
@merrymercy Thanks How could I get opencl kernel after nnvm.compiler.build?
After this block https://github.com/merrymercy/tvm-mali/blob/90395b509e01e6de6b83f5f2f8c4715dd5a024e9/mali_imagenet_bench.py#L32-L35 insert this line
print(lib.imported_modules[0].get_source())
Thanks a lot! What mean is lib.imported_modules? And how to get host runtime source code too?
lib
is the host module (llvm ir)
lib.imported_modules
is the device module (cuda, opencl)
lib.get_source() # get host llvm ir
lib.imported_modules[0].get_source() # get opencl/cuda source
There is no way to get host c code, only LLVM IR, right? export_library does not generate opencl runtime code, right?
Is there any document to explain how this host library and opencl are executed on target platform?
nnvm.compiler.build
generates both host code and opencl code. export_library
only saves them to filesSince the original question is answered, we can close this issue for now and open new issue on tvm repo.
hi,
This is a great job.
How to save the generated opencl code into a file?
Thanks