Make model info optional for TVM backends
PhilippvK opened this issue · comments
We currently need to load our TFLite/TF models before invoking the TVMC command line to populate the --input-shapes
argument, which is optional for most model types. Let's loosen up the requirement for model infos here which should make it easier to support more model formats in the future.
Just as a note: The refactored validate
feature (using .npz
files instead of raw .bin
files) will eventually need the model info anyway to map model input names to input indices.
This can not be implemented as easy as I thought, because the tvm wrapper generation currently depends on this. Let's hope that at some time TVM can generate those details (input shapes etc.) for us (There seems to already be work in that direction)
As I recently had to deal with dynamic and complex shapes I finally was able to resolve this.
I've implemented the following (not pushed yet):
- The
model_info
required for the TVM wrapper generation is generated by parsing the Relay IR representation of the model instead of dealing with the actual model format (ONNX, TFLite,...). This also ensures that the tensor names, types and shapes used in the wrappers match those used by TVM. - The
--input-shapes
argument oftvmc compile
is optional for most model types. If not provided it will now just be ommited. - If a
definition.yml
file is available for the used model, MLonMCU can now use it's contents to automatically determine the input shapes, types etc. in a format independent way. - For models which do not have a
definition.yml
file the shape/type information can also be provided my the user as follows:--config aww.input_shapes="x:[1,10,10,3]"
This way we have to rely less on the ModelInfo parsers and also can deal much better with dynamic/unknown shapes.
Great, sounds like a good solution!