Right now TVM relies heavily on the PackedFunc mechanism to register C++ APIs to the frontend. Existing IDE will be able to goto definition within the same language, but not necessarily across languages.
On the other hand, it is not too hard logically to find the definition point from the python or Registry::Get(), by running a grep on TVM_REGISTER_GLOBAL and matches the related name.
One way to bake that into the IDE is to provide IDE extensions. For VSCode, there is a callback API VS Code API | Visual Studio Code Extension API (registerDefinitionProvider and registerReferenceProvider) to register the navigation APIs, reference code can be found in vscode-go/src at master · microsoft/vscode-go · GitHub t This way we might be able to nagivate across the code boundary more easily in the VSCode.
This seems would be a fun hacking project. Open this thread to see if this is of interest the community, and anyone want to hack a bit
I use emacs for most of my development unfortunately I am not familiar with elisp, my guess is that similar thing can be hacked up but will need a different solution, unless we adopt some common interface(there is a language server protocol which might be overkill) given it is only a grep and find
OK i did some hacks, it turns out to be a harder than i first thought…
Anyway, here is an initial version https://github.com/tqchen/ffi-navigator
It contains a language server, and a vscode client, you can try it out in vscode.
Because most implementations are done through the common language server protocol, we might be able to use it in other IDEs, by make use of emacs plugins that talks to the language server.
I am a complete novice to this area(code analysis, typescript, language server) so please feel free to jump in and help if it can be useful.
VS code extension works beautifully!
I’ve also tested that the extension can be compiled locally once and install to a remote server via Remote SSH, although fft_navigator must be available on the remote server to make it work.
I would also recommend directly installing the package so that we don’t need to setup PYTHONPATH.
I made some more hacks, the latest set of improvements are here https://github.com/tqchen/ffi-navigator#features Feel free play with it and enhance more to add features that might helps the development
This could also be of interest to MXNet or PyTorch dev. Supporting MXNet seems straightforward, but pytorch generates C++ code from templates during build, so it requires source build be done beforehand.
To make it easier to support other projects, we want to separate TVM-specific component into one place and make BaseServer dispatch into project-specific handlers.
I just did anothe refactor to isolate the project specific part into a folder. I will stop adding major changes at this point, I think it should be pretty easy to add new ffi dialects, and enhance the project a bit further to allow configuration of things like path to scan and so on, feel free to add features that you think are good
First, I tried to install it under my anaconda using following command inside ffi-navigator folder. It did not showed up on my list of packages of my anaconda environment.
python setup install --user
Second, I tried to install it on my VS studio, but I failed to find “%USERPROFILE%.vscode\extensions” folder on my windows machine. I am sure my %userprofile% is /my_username/ under users. But there is no .vscode folder.
If you just want to use it instead of development, you can install the extension via VSCode marketplace, and then pip install ffi_navigator. It doesn’t support CLion yet and currently no plan for it.
@comaniac – thank you very much, but VSCode marketplace does not show ffi-navigator. I did searched all combinations like ffi navigator, ffi, …etc. Nothing shows up.