Hi, I’m working on getting tvm integrated into some pytorch layers. To do this, I need to wrap a pytorch tensor as a DLpack. Fortunately, pytorch supports this using torch._C._to_dlpack(). However, this returns a PyCapsule object. I need to be able to point tvm to the data attribute of the DLTensor, but pytorch cannot access any attributes of a PyCapsule. Am I doing something wrong or is _to_dlpack only meant to be an intermediate between c function calls?
I’d like to do something like this:
@tvm.register_extension
class FireTensor(object):
    _tvm_tcode = tvm.TypeCode.ARRAY_HANDLE

    def __init__(self, tensor):
        self.handle = torch._C._to_dlpack(tensor)

    @property
    def _tvm_handle(self):
        return self.handle.data