GithubHelp home page GithubHelp logo

Comments (8)

merrymercy avatar merrymercy commented on May 25, 2024

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

with target:
B = topi.nn.conv2d(A, W, stride, padding)
s = topi.generic.schedule_conv2d_nchw([B])
func = tvm.build(s, [A, W, B], target_host=target_host)
#print(func.imported_modules[0].get_source())

from tvm-mali.

janboeye avatar janboeye commented on May 25, 2024

@merrymercy
Thanks
How could I get opencl kernel after nnvm.compiler.build?

from tvm-mali.

merrymercy avatar merrymercy commented on May 25, 2024

After this block

with nnvm.compiler.build_config(opt_level=opt_level):
graph, lib, params = nnvm.compiler.build(
net, tvm.target.mali(), shape={"data": data_shape}, params=params,
dtype=dtype, target_host=args.target_host)

insert this line

print(lib.imported_modules[0].get_source())

from tvm-mali.

janboeye avatar janboeye commented on May 25, 2024

Thanks a lot!
What mean is lib.imported_modules?
And how to get host runtime source code too?

from tvm-mali.

merrymercy avatar merrymercy commented on May 25, 2024

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

from tvm-mali.

janboeye avatar janboeye commented on May 25, 2024

There is no way to get host c code, only LLVM IR, right?
export_library does not generate opencl runtime code, right?

from tvm-mali.

janboeye avatar janboeye commented on May 25, 2024

Is there any document to explain how this host library and opencl are executed on target platform?

from tvm-mali.

merrymercy avatar merrymercy commented on May 25, 2024
  1. TVM translate its Halide IR to LLVM IR directly, so there is no host c code.
  2. nnvm.compiler.build generates both host code and opencl code. export_library only saves them to files

Since the original question is answered, we can close this issue for now and open new issue on tvm repo.

from tvm-mali.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.