[TVMC] Add support for the MLF to 'compile' command#8086
Merged
leandron merged 2 commits intoapache:mainfrom May 25, 2021
Merged
[TVMC] Add support for the MLF to 'compile' command#8086leandron merged 2 commits intoapache:mainfrom
leandron merged 2 commits intoapache:mainfrom
Conversation
leandron
reviewed
May 20, 2021
Contributor
|
Also just to report, I tested it locally and it works. |
areusch
reviewed
May 20, 2021
|
|
||
| if output_format in ["so", "tar"]: | ||
| return self.export_classic_format(executor_factory, package_path, cross, output_format) | ||
| else: |
Contributor
There was a problem hiding this comment.
could we be explicit here (elif output_format == "mlf") rather than as a fallback?
Contributor
Author
Add support for the Model Library Format (MLF) to 'tvmc' so users can output compilation artifacts to a MLF archive passing the new flag '--output-format mlf'. For instance: $ python3 -m tvm.driver.tvmc compile ./sine_model.tflite --target="c" --output sine.tar --output-format mlf will generate a sine.tar archive that is serialized accordingly to the MLF. Since the MLF is currently meant to be used only on micro targets, an error is generated if one tries to run a MLF outside a micro context. The micro context does not exist yet but will be later introduced as part of the [RFC] "TVMC: Add support for µTVM". That commit also adds 3 pytest tests to test tvmc + MLF. Finally, it also fixes some missing periods in the 'compile' command help sections and renames export_format to output_format so there is no confusion with flag '--dump-code', which contains "formats to export" in its help section. Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
Contributor
Author
leandron
reviewed
May 24, 2021
Contributor
leandron
left a comment
There was a problem hiding this comment.
LGTM just pending a test pending the fix for one of the tests.
leandron
reviewed
May 24, 2021
| assert str(exp.value) == expected_reason, on_error | ||
|
|
||
|
|
||
| def test_tvmc_import_package_mlf(tflite_compiled_model_mlf): |
Contributor
There was a problem hiding this comment.
Suggested change
| def test_tvmc_import_package_mlf(tflite_compiled_model_mlf): | |
| def test_tvmc_import_package_mlf(tflite_compiled_model_mlf): | |
| pytest.importorskip("tflite") |
As this test is compiled and executed in the same machine, it will need to be protected with a pytest.importorskip("tflite") as well, so that it will be skipped in the CI i386 machine, like the other in this file.
Fix missing importorskip() in the import_package test allowing the test in question to be skipped when 'tflite' is not installed in the test environment, otherwise the test will fail with: [...] > archive_path = exported_tvmc_package.package_path E AttributeError: 'str' object has no attribute 'package_path'
leandron
approved these changes
May 25, 2021
Contributor
Author
|
@tmoreau89 Hello Thierry. Could you please merge it? |
Contributor
trevor-m
pushed a commit
to trevor-m/tvm
that referenced
this pull request
Jun 17, 2021
* [TVMC] Add support for the MLF to 'compile' command Add support for the Model Library Format (MLF) to 'tvmc' so users can output compilation artifacts to a MLF archive passing the new flag '--output-format mlf'. For instance: $ python3 -m tvm.driver.tvmc compile ./sine_model.tflite --target="c" --output sine.tar --output-format mlf will generate a sine.tar archive that is serialized accordingly to the MLF. Since the MLF is currently meant to be used only on micro targets, an error is generated if one tries to run a MLF outside a micro context. The micro context does not exist yet but will be later introduced as part of the [RFC] "TVMC: Add support for µTVM". That commit also adds 3 pytest tests to test tvmc + MLF. Finally, it also fixes some missing periods in the 'compile' command help sections and renames export_format to output_format so there is no confusion with flag '--dump-code', which contains "formats to export" in its help section. Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org> * Fix missing importorskip in the import_package test Fix missing importorskip() in the import_package test allowing the test in question to be skipped when 'tflite' is not installed in the test environment, otherwise the test will fail with: [...] > archive_path = exported_tvmc_package.package_path E AttributeError: 'str' object has no attribute 'package_path'
trevor-m
pushed a commit
to neo-ai/tvm
that referenced
this pull request
Jun 17, 2021
* [TVMC] Add support for the MLF to 'compile' command Add support for the Model Library Format (MLF) to 'tvmc' so users can output compilation artifacts to a MLF archive passing the new flag '--output-format mlf'. For instance: $ python3 -m tvm.driver.tvmc compile ./sine_model.tflite --target="c" --output sine.tar --output-format mlf will generate a sine.tar archive that is serialized accordingly to the MLF. Since the MLF is currently meant to be used only on micro targets, an error is generated if one tries to run a MLF outside a micro context. The micro context does not exist yet but will be later introduced as part of the [RFC] "TVMC: Add support for µTVM". That commit also adds 3 pytest tests to test tvmc + MLF. Finally, it also fixes some missing periods in the 'compile' command help sections and renames export_format to output_format so there is no confusion with flag '--dump-code', which contains "formats to export" in its help section. Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org> * Fix missing importorskip in the import_package test Fix missing importorskip() in the import_package test allowing the test in question to be skipped when 'tflite' is not installed in the test environment, otherwise the test will fail with: [...] > archive_path = exported_tvmc_package.package_path E AttributeError: 'str' object has no attribute 'package_path'
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
Could I get reviews for the following change, please?
It adds support for the Model Library Format (MLF) to 'tvmc' so users can
output compilation artifacts to a MLF archive passing the new flag
'--output-format mlf'. For instance:
$ python3 -m tvm.driver.tvmc compile ./sine_model.tflite --target="c" --output sine.tar --output-format mlf
will generate a sine.tar archive that is serialized accordingly to the
MLF.
Since the MLF is currently meant to be used only on micro targets, an
error is generated if one tries to run a MLF outside a micro context:
$ python3 -m tvm.driver.tvmc run ./sine.tar
Error: You're trying to run a model saved using the Model Library Format (MLF). MLF can only be used to run micro targets (µTVM).
The micro context does not exist yet but will be later introduced as
part of the [RFC] "TVMC: Add support for µTVM".
Signed-off-by: Gustavo Romero gustavo.romero@linaro.org