Adding VM module dependency versioning support. (#10014)
Modules now export a version number and each vm.import can declare
a minimum required version. When serializing the module out the minimum
module dependencies are calculated and written to the flatbuffer/emit-c
descriptor.
We can now get nice runtime errors on module mismatches:
```
context.c:134: NOT_FOUND; required module 'hal' version mismatch; have 0 but require 1; resolving module 'module' imports
```
Future changes will use this information to perform module dependency
resolution/dynamic loading.
Fixes #8014.
diff --git a/runtime/bindings/python/vm.cc b/runtime/bindings/python/vm.cc
index 349fa9e..c0b014e 100644
--- a/runtime/bindings/python/vm.cc
+++ b/runtime/bindings/python/vm.cc
@@ -624,6 +624,12 @@
py::class_<VmModule>(m, "VmModule")
.def_static("from_flatbuffer", &VmModule::FromFlatbufferBlob)
.def_property_readonly("name", &VmModule::name)
+ .def_property_readonly("version",
+ [](VmModule& self) {
+ iree_vm_module_signature_t sig =
+ iree_vm_module_signature(self.raw_ptr());
+ return sig.version;
+ })
.def("lookup_function", &VmModule::LookupFunction, py::arg("name"),
py::arg("linkage") = IREE_VM_FUNCTION_LINKAGE_EXPORT)
.def_property_readonly(