hi @dream-math @jossevandelm @Julien 

Thanks for some great collaboration, seems like there is significant community 
interest in merging RISC-V support. Let's lay out some steps we can follow to 
make this happen, and then we can discuss timelines.

1. To start with, I propose we explicitly test the Zephyr riscv32_qemu board in 
TVM CI. This is the easiest integration we could make, since we have so much 
Zephyr support in microTVM now. @mehrdadh is actually working on this right 
now, on top of the recently-merged [PR 
7557](https://github.com/apache/tvm/pull/7557) (which reorganizes the various 
Zephyr runtimes in tvm such that we should be able to have a single runtime 
compatible with all boards--a precursor to Project Generator API).

2. I think it's likely that some of you would like to try using RISC-V on 
platforms other than Zephyr. Though it's possible to proceed with this at 
`main` today (by implementing a `Compiler`, `Flasher`, `Transport` etc), I'd 
suggest working on top of the [Project Generator API 
PoC](https://github.com/areusch/incubator-tvm/tree/project-generator) if you'll 
be starting on this in the medium term (e.g. after maybe a week from now). In 
general, this approach should scale better as TVM integrates with more 
platforms or with bare metal.

3. Autotuning support is in [this PR](https://github.com/apache/tvm/pull/7545) 
which needs syncing. I'm hoping to do that after merging the Project Generator 
API (as autotuning added another dependency). After that lands, it would be 
great to explore some schedules on RISC-V.

4. Currently, the easiest way to add an accelerator is to expose a CPU-side 
control function to microTVM as a PackedFunc or C function, and then embed that 
in the TIR (I.e. TVM's pre-codegen representation of your program) as 
`tir.call_packed` or `tir.call_extern`. Doing this is effectively using the 
BYOC or Tensorization flows.

5. In the future, we should consider enhancing the interface between microTVM 
and accelerators. In the C++ runtime, a Device API exists. It's probably 
overkill for microTVM, but it's likely that what we have now could be made more 
efficient. In particular, a richer accelerator interface could allow us to 
pursue graph-level optimizations that may help to offload some of the 
implementation work around layout transformations and data copy. Let's discuss 
this further on @JosseVanDelm's post as there is quite a bit more detail there.

Now as to timelines (but these are estimates, don't hold me to them :) ):
- I think we'll try to have a PoC/PR for Zephyr riscv32 support in a few weeks. 
I believe we need to update to Zephyr 2.5.0 for this.
- I think we'll try to merge Project API in the next few weeks. Work is being 
done now to port the Zephyr runtime to work under Project API.
- Work to bring up an accelerator as in (4) would take I'd say maybe 2-3 
months, but there may be also a month or two of ramp-up work involved with 
that. I may defer to @JosseVanDelm here. We'd like to improve this, so any 
specific feedback on confusing or time-consuming things would be great!

-Andrew





---
[Visit 
Topic](https://discuss.tvm.apache.org/t/tvm-and-custom-accelerators/9525/9) to 
respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click 
here](https://discuss.tvm.apache.org/email/unsubscribe/ef126fb4bf8bf9c2aa91f609d372eb83353267d60fd97a2b1dc0f0efefc3a46c).

Reply via email to