Registering a data packing function and return a new data type

Hi,

I am trying to register an external function which pack data. I want to be able to return a handle to created data structure ( a templatized class) using ret.

Gist:
TVM_REGISTER_GLOBAL(“tvm.contrib.fbgemm.pack_matB”)
.set_body([](TVMArgs args, TVMRetValue *ret) {
auto packB = new PackBMatrix<std::int8_t, std::int32_t> ( blah, blah);
*ret = *packB;
})

This doesn’t currently work. Any pointers on how to achieve this will be helpful

I guess one way I see in the code is to use:
TVM_REGISTER_EXT_TYPE

Does this work with templatized classes:
eg. Will this work:

TVM_REGISTER_EXT_TYPE(PackBMatrix<std::int8_t, std::int32_t>);