From 7bdd26ca5b2e2dcd69136a8107f0ccf2245a1cb3 Mon Sep 17 00:00:00 2001 From: Gustavo Romero Date: Wed, 22 Sep 2021 22:43:01 +0000 Subject: [PATCH] [microTVM] Add wrapper for creating project using a MLF 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 Reviewed-by: Christopher Sidebottom --- python/tvm/micro/project.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/python/tvm/micro/project.py b/python/tvm/micro/project.py index 8a62c9b5f9ba1..8b959bd66aba1 100644 --- a/python/tvm/micro/project.py +++ b/python/tvm/micro/project.py @@ -154,3 +154,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: typing.Union[pathlib.Path, str], + project_dir: typing.Union[pathlib.Path, str], + mlf_path: typing.Union[pathlib.Path, str], + options: dict, +): + """Generate a project from a platform template and an existing Model Library Format (MLF) 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)