Skip to content

Commit

Permalink
[microTVM] Add wrapper for creating project using a MLF (apache#9090)
Browse files Browse the repository at this point in the history
Currently there is already a wrapper function for creating a new project
directory based on an ExportableModule, but there isn't one for creating
a new project directory based on an existing MLF archive, which is also
handy. Hence that commit adds a new wrapper for creating a project using
an existing model compiled and kept in a MLF archive.

Signed-off-by: Gustavo Romero <[email protected]>
Reviewed-by: Christopher Sidebottom <[email protected]>
Reviewed-by: Andrew Reusch <[email protected]>
  • Loading branch information
gromero authored Sep 30, 2021
1 parent 229eca4 commit 3d64783
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions python/tvm/micro/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,36 @@ def generate_project(
"""
template = TemplateProject.from_directory(str(template_project_dir))
return template.generate_project(module, str(generated_project_dir), options)


def generate_project_from_mlf(
template_project_dir: Union[pathlib.Path, str],
project_dir: Union[pathlib.Path, str],
mlf_path: Union[pathlib.Path, str],
options: dict,
):
"""Generate a project from a platform template and an existing Model Library Format archive.
Parameters
----------
template_project_path : pathlib.Path or str
Path to a template project containing a microTVM Project API server.
project_dir : pathlib.Path or str
Path to a directory where the project will be created.
mlf_path : pathlib.Path or str
Path to the Model Library Format archive that will be used when creating
the new project.
options : dict
Project API options given to the microTVM API server for the specified platform.
Returns
-------
GeneratedProject :
A class that wraps the generated project and which can be used to further interact with it.
"""

template = TemplateProject.from_directory(str(template_project_dir))
return template.generate_project_from_mlf(str(mlf_path), str(project_dir), options)

0 comments on commit 3d64783

Please sign in to comment.