Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] Devguide: TVM Codebase Walkthrough Tutorial #2160

Closed
tqchen opened this issue Nov 23, 2018 · 8 comments
Closed

[DOCS] Devguide: TVM Codebase Walkthrough Tutorial #2160

tqchen opened this issue Nov 23, 2018 · 8 comments

Comments

@tqchen
Copy link
Member

tqchen commented Nov 23, 2018

As more contributors start to collaborate on TVM, it would be super helpful to write a few developer guides to walk through the TVM code base. As an open source project, we value the maintainability and docs above the code itself, and we should provide some dev guide to do so. The current runtime system doc is one example. But we need more of these.

In particular, it would be helpful to analysis a simple example (e.g., vector add, or relay compilation) and go through all the files/steps it involved. Because we have the PackedFunc and sometimes code goes across python/c++, such an initial navigation example would be super helpful for beginners who want to work on the codebase. Please reply to this issue if you are interested in helping out on this.

Proposed Action Item

Let us build a dev-guide series called hacking TVM by example. The general idea is to provide a simple python side example and walk through the details, when necessary, we can focus on a particular part of detail and leave others into other examples. This kinda of example is usually complementary to the general document we have so far to highlight certain problems a developer might have.

Some of the existing resources:

We can propose new items, for example, one action item could be what happens when we build an add one function in CUDA and LLVM

@Ravenwater
Copy link

For the new folks, like myself, starting from scratch would be a long slog, but doing the more detailed discovery would be beneficial and writing up those experiences perfect for other newbies. Here is my suggestion, for the core developers of pieces of functionality that deliver a particular use case, if you could write a simple description and a list of code segments that follow the implementation. folks like myself can pick that up and transform that into a proper walk through. Two birds one stone: you get a newby to write the doc, and the newby learns by inspection, guided by the principal architect of the flow.

@Ravenwater
Copy link

One thing I am missing for comprehension is a proper architecture description that organizes the problem TVM and VTA are trying to solve, enumerates what the state space is of potential solutions, and why the particular organization was selected to deliver this solution. That architecture description should also identify independent areas of functionality, and I presume that this will be reflected in the code organization and build processes. Those independent areas would be areas of research interest and possibly further expansion of the state space of improved solutions. For example, I would be very interested in the thoughts that went into the transformation from (?) (to be inserted when I know) to Relay.

@masahi
Copy link
Member

masahi commented Nov 25, 2018

I want to contribute some write-up, since this issue is kind of dear to my heart. I can kick-start with a vector-add example, if nobody is going to do it. Recently I've studied how exactly python and c++ interop works (without using pybind or Boost Python etc). It would be interesting to write about it too.

Below are things which I think should be documented:

  • How to add a new backend. Recently I was asked about this, but I couldn't point to a relevant document.
  • How the TOPI target dispatching mechanism works

Below are things I'm not familiar with. I appreciate if somebody can write about them.

  • Relay IR design, motivation, compilation mechanism etc. How it relates to traditional computational graph representation. (They are discussed on Github, but not documented.)
  • TVM IR lowering process. How initial Realize/Provide stuff gets transformed into a low level IR. How bounds inference works.

@tqchen
Copy link
Member Author

tqchen commented Nov 26, 2018

Thanks for @Ravenwater @masahi this all makes sense and please go for it. For specific details, I would recommend us to open new threads(like working threads) in the discuss, where everyone can jump in and add details.

@Ravenwater
Copy link

@tqchen
Copy link
Member Author

tqchen commented Dec 26, 2018

#2273 thanks to @masahi

@FrozenGene
Copy link
Member

FrozenGene commented Dec 27, 2018

Ah...I think I can take one. As @tqchen know, I am writing articles to introduce TVM to Chinese developers and wish to attract them to join us (see https://zhuanlan.zhihu.com/p/50529704) . My next article will introduce one op of frozen model (like CoreML, Keras and so on) , then how to change into NNVM (Relay doesn't have frontend and I don't also be familiar with that, sorry about this), then how to be called into TVM, then how to become LLVM IR. I will walk through this by detail code (even the exact line) If @tqchen think this way (top -> down) is also good, I will PR this go-through tutorial when I complete this Chinese version.

@were
Copy link
Contributor

were commented Dec 27, 2018

Based on #2206, I can elaborate on how a schedule can be formed as a preliminary function body.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants