tvm icon indicating copy to clipboard operation
tvm copied to clipboard

Using TVM compiler from C++

Open alex-weaver opened this issue 9 years ago • 4 comments

Is it possible to schedule and compile ops directly from C++? Digging around the code it seems straightforward to construct the computation graph from C++, but the actual compilation step seems to touch a big chunk of python code in build_module.py (build and lower functions). Would compiling in C++ require porting these functions over to C++ first, or does that functionality already exist under another API?

alex-weaver avatar Nov 15 '17 11:11 alex-weaver

TVM is mainly in C++ and the only reason python is used is to make things more flexible when stitching things up. build_module.py contains calls into C++ function. So we would need to port these wrapper calls to c++, but the functions that these functions calls are already in C++.

Contribution is welcomed

tqchen avatar Nov 17 '17 18:11 tqchen

@tqchen Thanks for clarifying that, I'm working on getting that ported to C++ at the moment - a quick question about conventions: Specifying a schedule requires touching functions like Stage::split. This function is not prefixed with the EXPORT macro, but is added to the global registry as "_StageSplitByFactor". What would be the preferred way of accessing this and similar functions? Should I add the EXPORT macro and use it directly, or go via the registry?

This affects other functions too such as ScheduleNode::make (depended on by create_schedule), and Schedule::operator[]. At the moment for testing purposes I'm just adding EXPORT to all of these, but I'm wondering what would be the preferred way?

alex-weaver avatar Nov 21 '17 12:11 alex-weaver

Use cxx when possible, if you find some function that you need missing export, add it

tqchen avatar Nov 21 '17 16:11 tqchen

I am going to close this issue for now. Feel free to open the PR or WIP issue to track the progress

tqchen avatar Nov 21 '17 17:11 tqchen