Skip to content

Commit

Permalink
unfinishe
Browse files Browse the repository at this point in the history
  • Loading branch information
comaniac committed Jan 14, 2020
1 parent e899180 commit c147059
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions docs/dev/relay_bring_your_own_codegen.rst
Original file line number Diff line number Diff line change
Expand Up @@ -520,10 +520,26 @@ So that users can configure whether to include your compiler when configuring TV
Implement a Codegen for Your Representation
*******************************************

Although we have demonstrated how to implement a C codegen, your hardware may require other forms of graph representation, such as JSON. In this case, you can slightly modify ``CodegenC`` class we have implemented to generate your own graph representation, and implement a customized runtime module to let TVM runtime know how this graph representation should be executed. **(TBA)**
Although we have demonstrated how to implement a C codegen, your hardware may require other forms of graph representation, such as JSON. In this case, you can slightly modify ``CodegenC`` class we have implemented to generate your own graph representation, and implement a customized runtime module to let TVM runtime know how this graph representation should be executed.

Speifically, our goal is to implement the following customized TVM runtime module:

.. code-block:: c++

runtime::Module MyIRCompiler(const NodeRef& ref) {
graph_ir = MyCodeGen(ref); // Note 1
return CreateMyModule(graph_ir); // Note 2
}

**Note 1**: ``MyCodeGen`` can be fully-customized as long as it takes a subgraph (``NodeRef``) and outputs a representation you prefer. You don't have to register ``MyCodeGen`` to TVM because this is the only place it will be used.

**Note 2**: ``CreateMyModule`` instantiates a customized TVM module with the subgraph in your representation. It means this module is able to execute the subgraph when TVM invokes its subgraph ID on the fly.

In the following sections, we are going to introduce how to implement ``MyCodeGen`` and ``CreateMyModule``.

Implement MyCodeGen
===================

Implement CodegenJSON
=====================

Implement Customized Runtime
============================

0 comments on commit c147059

Please sign in to comment.