Skip to content

Commit

Permalink
[microTVM] Arduino: Fix MLF archive filename in generated project dir (
Browse files Browse the repository at this point in the history
…apache#9320)

* [microTVM] Arduino: Fix MLF archive filename in generated project dir

Currently generate_project API method is copying the input MLF archive
filename without renaming it to "model.tar" - hence not in accordance
with the specification. As a consequence when the server looks for that
file to determine if it's a project dir or a template dir it always
determines it is a template dir since "model.tar" can never be found, so
a TemplateProjectError() exception is thrown when instantiating a
GeneratedProject class.

This commit fixes that by correctly copying the input MLF archive to
the newly generated project dir as "model.tar" so the server can find
it.

It also takes the chance to change the MLF path returned by
server_info_query method: only if it's not a template dir the MLF path
is returned, otherwise an empty string is returned (it doesn't make
sense to return a MLF path when it's a template dir because there isn't
any model associated to a template dir).

Signed-off-by: Gustavo Romero <[email protected]>

* Retrigger CI
  • Loading branch information
gromero authored Oct 27, 2021
1 parent 37a8d7b commit 03665a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/microtvm/arduino/template_project/microtvm_api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def server_info_query(self, tvm_version):
return server.ServerInfo(
platform_name="arduino",
is_template=IS_TEMPLATE,
model_library_format_path=MODEL_LIBRARY_FORMAT_PATH,
model_library_format_path="" if IS_TEMPLATE else MODEL_LIBRARY_FORMAT_PATH,
project_options=PROJECT_OPTIONS,
)

Expand Down Expand Up @@ -329,7 +329,7 @@ def generate_project(self, model_library_format_path, standalone_crt_dir, projec

# Unpack the MLF and copy the relevant files
metadata = self._disassemble_mlf(model_library_format_path, source_dir)
shutil.copy2(model_library_format_path, source_dir / "model")
shutil.copy2(model_library_format_path, project_dir / MODEL_LIBRARY_FORMAT_RELPATH)

# For AOT, template model.h with metadata to minimize space usage
if options["project_type"] == "example_project":
Expand Down

0 comments on commit 03665a3

Please sign in to comment.