Previous, we use relay::Value to hold objects in the interpreter, and use relay::vm::Object to hold the objects in VM.
As we are moving toward a unified runtime object protocol, it would be really nice to unify these objects. So we no long have to say that “hey this object is specific for VM”, they are just normal tvm runtime objects.
Of course, we know that some of these objects need additional fields to hold reference to interpreter. These can be done via sub-classing (e.g. make TensorValue a sub-class of NDArray, perhaps we also want to bring a better name) so that from users’ perspective, they can treat them as runtime data structure.
Please share your thoughts and see if you are interested in help to push for this change.
This probably would help us unify the objects used in VM and interpreter as well. We currently have separate Tensor objects even in VM and interpreter.
Yes, closure requires some unification. The variable environment in interpreter is a compile time container Map, vm is std::vector. And function body in interpreter is the Function expression(with Stmt or PackedFunction, vm is a index to the compiled function(either sequence of bytecode or PackedFunction).
The environment maybe we can unify with runtime container. For function body I think they will have to diverge. Or we move the specific function body implementation into private area internal to interpreter or vm, in the closure we just store a reference(could be an integer).