I need some help to understand how to register a new target properly.
I started working with TVM a few month ago. I’m currently trying to add an accelerator to TVM using BYOC. I already read the Tutorials and How-To Descriptions on the tvm website, however in my opinion they are only covering parts of the complete picture.
What steps are needed beside the steps below to add a new target called “my_target” so that I can run a “normal” TVM workflow similar to:
target = “my_target” with tvm.transform.PassContrext(opt_level=3) lib = relay.build(mod, target=target, params=params)”
How do I need to register the target globally so it is known by TVM and the Relay Pathes like “transform.MergeComposite” or “transform.AnnotateTarget” are called by the default workflow using “my_target” or alternatively how could I let tvm select to call my custom “partition_for_my_target(mod, params)” function?
I already followed the available how-to-guidelines (sources below) and performed the following steps
- Register Operations that should be offloaded to the target (python/tvm/relay/op/contrib/my_target.py + add entry to init.py)
- Create Compiler for my_target (src/relay/backend/contrib/my_target/codegen.cc)
- Created a Cmake file and add it to CMakeList (cmake/modules/contrib/MY_TARGET.cmake + CMakeList.txt + add Option to cmake/config.cmake)
Does anyone have some information / documentation (additional explanation, forum entries I might have overseen) he could share with me to identify the missing steps?
I would be very glad if I could get some hints from the community.
Some additional information about my sources I uses so far. I already read and viewed:
- The How-To Description for BYOC: http://tmp.syfeng.net:9090/dev/how_to/relay_bring_your_own_codegen.html.
- An article I found in the blog (How to Bring Your Own Codegen to TVM)
- A tutorial from 2020 TVM conference describing different Relay-pathes that allow to assign subgraphs to a custom target. (TVM Conf 2020 - Tutorials - Bring Your Own Codegen to TVM - YouTube Revisions · TVMConf-2020-BYOC-Demo.py · GitHub)
- Direct Code Search mainly in the code base for the bnns and dnnl targets