-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Allow tvmc to compile models with AOT executor in MLF #8331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
gromero
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Mousius . Thanks for adding these AOT bits to tvmc.
Please see my comments inline
I really liked your commit message and I get happy when I see that format instead of the "bullet format", like adding the comment about shlex etc. Thank you. The only thing I missed is that you actually added an important change in TVMCPackage.import_package() which is the ability to distinguish Graph from AOT runtime based on graph, so it would be nice to mention it also in the commit message, I think :)
python/tvm/driver/tvmc/model.py
Outdated
| if "graph" in metadata["runtimes"]: | ||
| graph = temp.relpath("runtime-config/graph/graph.json") | ||
| else: | ||
| graph = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. I just think a hint about AOT should exist here. How about adding a comment above graph = None, like "AOT runtime"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll use the code as docs rather than a comment and pop the condition in a variable:
is_graph_runtime = "graph" in metadata["runtimes"]
graph = temp.relpath("runtime-config/graph/graph.json") if is_graph_runtime else None
tests/python/driver/tvmc/conftest.py
Outdated
| @pytest.fixture(scope="session") | ||
| def tflite_compiled_model_mlf(tmpdir_factory): | ||
| @pytest.fixture | ||
| def tflite_tvmc_compiler(tmpdir_factory): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about renaming the tflite_tvmc_compiler fixture to tflite_compile_model, just because I don't think that tvmc in there is informative. But no strong feelings about it. Feel free also to get more input from Leandro before sending a v2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, this is in the tvmc conftest so context makes more sense 😸 good call!
tests/python/driver/tvmc/test_mlf.py
Outdated
|
|
||
|
|
||
| def test_tvmc_import_package_mlf(tflite_compiled_model_mlf): | ||
| def test_tvmc_import_package_mlf(tflite_mobilenet_v1_1_quant, tflite_tvmc_compiler): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can rename test_tvmc_import_package_mlf to test_tvmc_import_package_mlf_graph.
tests/python/driver/tvmc/test_mlf.py
Outdated
|
|
||
| assert tvmc_package.lib_name is None, ".lib_name must not be set in the MLF archive." | ||
| assert tvmc_package.lib_path is None, ".lib_path must not be set in the MLF archive." | ||
| assert tvmc_package.graph is not None, ".graph must be set in the MLF archive." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message must be adapted here, adding "[...] if not AOT". Maybe:
`".graph must be set in the MLF archive if not AOT runtime"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I'll say "if Graph" to make it clear where the distinction is
leandron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, agree with @gromero's suggestions.
The tflite_compiled_model fixture was getting duplicated a few times so I've added a parameterized fixture tflite_tvmc_compiler which combines tmpdir_factory setup with compile_model Nested targets broke a basic string split, so in cases where we use nested targets I replaced the string split with shlex split
Plus other clean ups
|
This is is failing in the latest version of this PR. I'm pasting the error below, to save a trip to Jenkins: Apart from that, LGTM. Happy to review/merge once we get CI working. |
|
Hopefully that should do it, thanks for your feedback @gromero 😸 |
leandron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Allow tvmc to compile models with AOT executor The tflite_compiled_model fixture was getting duplicated a few times so I've added a parameterized fixture tflite_tvmc_compiler which combines tmpdir_factory setup with compile_model Nested targets broke a basic string split, so in cases where we use nested targets I replaced the string split with shlex split * Clarify that graph JSON is required only for graph executor Plus other clean ups * Change parametrize fixture to use string instead of list
* Allow tvmc to compile models with AOT executor The tflite_compiled_model fixture was getting duplicated a few times so I've added a parameterized fixture tflite_tvmc_compiler which combines tmpdir_factory setup with compile_model Nested targets broke a basic string split, so in cases where we use nested targets I replaced the string split with shlex split * Clarify that graph JSON is required only for graph executor Plus other clean ups * Change parametrize fixture to use string instead of list
* Allow tvmc to compile models with AOT executor The tflite_compiled_model fixture was getting duplicated a few times so I've added a parameterized fixture tflite_tvmc_compiler which combines tmpdir_factory setup with compile_model Nested targets broke a basic string split, so in cases where we use nested targets I replaced the string split with shlex split * Clarify that graph JSON is required only for graph executor Plus other clean ups * Change parametrize fixture to use string instead of list
The tflite_compiled_model fixture was getting duplicated a few times so I've added a parameterized fixture tflite_tvmc_compiler which combines tmpdir_factory setup with compile_model
Nested target params broke a basic string split, so in cases where we use nested target params I replaced the string split with shlex split