tvm icon indicating copy to clipboard operation
tvm copied to clipboard

[Relax] Expose BlockBuilder's Analyzer instance in Python

Open oskar-inceptron opened this issue 1 year ago • 2 comments

It is currently not possible to access a BlockBuilder's Analyzer instance from Python code, which would be useful e.g. when converting from front-end representations to Relax.

This PR addresses that by adding a get_analyzer method to the Python BlockBuilder class. Behind the scenes, it uses the same FFI and code paths as when creating a standalone Python Analyzer, the only difference being where the underlying C++ instance originates from. To avoid object lifetime issues in Python code (which would be surprising given that it is a memory managed language), a C++ BlockBuilder's Analyzer field is now a shared pointer.

oskar-inceptron avatar Nov 29 '24 14:11 oskar-inceptron

cc @tqchen

Hzfengsy avatar Dec 06 '24 05:12 Hzfengsy

thanks @oskar-inceptron If we want to go towards this directly, a better approach is to make Analyzer an Object, so we can use ObjectPtr for this

tqchen avatar Dec 10 '24 15:12 tqchen