Duplicate node handles

Hey, I have trying to get a bridged java/python tvm system working.

I am working with the jna bindings from tvm-clj. With these I can create a tvm object that will have TVMNodeFree called on it eventually.

I can get the handle from this object and construct a python TVM object going roughly through the pathway in _ctypes/node.py.

The problem is now I have 2 things that will call TVMNodeFree on 1 thing (the same node handle). Is there a simple way (or hack) through the API get another node handle that points to the same node? I looked for something like “TVMNodeDuplicateHandle” and nothing like that is there but I may have missed something.

Basically, I want to interleave python and Clojure mainly so I can use TVM from Clojure. I had this working but there is now so much work done in Python I would like to use libpython-clj to get things done. Basically I don’t want to replicate the compilation system any more but I still want to build the AST from Clojure.

Thanks for any help :-).

What you asked is possible, you could directly register a PackedFunc that takes a NodeRef and return itself, which will give you another node handle that points to the same node.

We did not yet offer a direct TVMNodeDuplicateHandle, which might have valid usage. Note that we are under upgrade of a new unified object protocol, and we could offer this API in the new object protocol.

Registering a packed func like you suggest is a great, simple workaround.

Looking forward to the unified object protocol! I have been following the thread and RFC.

Thanks