How to return a struct from PackedFunc?

I want to return multiple values from the C++ side to the Python side. For example, returning this:

struct Ret {
  std::string a;
  Integer b;
};

Are their elegant solutions?

Hope this could be helpful. https://github.com/dmlc/tvm/tree/master/apps/extension

I’m wondering what does the code field in extension_type_info do. What values can I use? Will my codes conflict with that in other extensions?

The simplest hack would be return a PackedFunc that maps from indices to field. After we add ADT runtime support, we should be able to return tuple which also solves the problem.

Thank you. Returning a PackedFunc is useful.

I think using type trait has been elegant enough, so that would you recommend the ADT way? Did I misread the question?

I think I misread…Another way is that subclass the struct from the object/node system, implement the VisitAttrs method, and you will immediately gain interoperability between python and C.