Files
apache--tvm/python/tvm/micro/project_api
Gustavo Romero 53cb5eadfb [TVMC][microTVM] Add new micro context (#9229)
* [microTVM] zephyr: Make platform options comply with RFC-0020

Make Zephyr platform options comply with RFC-0020 specification.

Project options now need to specify the required metadata for every
option, i.e. 'required', 'optional', and 'type'.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>

* [microTVM] arduino: Make platform options comply with RFC-0020

Make Arduino platform options comply with RFC-0020 specification.

Project options now need to specify the required metadata for every
option, i.e. 'required', 'optional', and 'type'.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>

* [microTVM] crt: Make crt options comply with RFC-0020

Make crt project options comply with RFC-0020 specification.

Project options now need to specify the required metadata for every
option, i.e. 'required', 'optional', and 'type'.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>

* [microTVM][Unittest] Adapt test to RFC-0020

Adapt test to new metadata fields accordingly to RFC-0020 specification.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>

* [microTVM] Add info() method to GeneratedProject class

Add info() method to GeneratedProject class so one can use the Project
API to query options for project dirs instead of only for template
projects.

This commit also adds for the sake of convenience a setter and a getter
for 'options' in case it's necessary to set or get 'options' after a
GeneratedProject class is instantiated without initializing 'options'.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>

* [microTVM] Fix typo in python/tvm/micro/session.py

Fix typo in comment.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>

* Allow multiple runs on micro targets

Currently there is a limitation on microTVM / TVM which doesn't allow
running a model multiple times in sequence without previously flashing
the model to the device.

Root cause is that RPCModuleNode class destructor is called once a run
finishes. The destructor sends a RPCCode::kFreeHandle packet with
type_code = kTVMModuleHandle to the device which wipes entries in
crt/src/runtime/crt/common/crt_runtime_api.c:147:static const TVMModule*
registered_modules[TVM_CRT_MAX_REGISTERED_MODULES] when TVMFreeMod() is
called when the target receives a kFreeHandle packet.

Hence when one tries to re-run a model registered_modules[0] == NULL
causes a backtrace on the host side. Probably never before a model on
microTVM was run without being flashed just before the run, so tvmc run
implementation for micro targets exposed the issue.

This commit fixes it by not calling TVMFreeMod() for system_lib_handle
on the target side when a session terminates so the pointer to the
system_lib_handle is not flushed from 'registered_modules', allowing
multiple runs on micro targets.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>

* [TVMC] Pass main parser when calling add_*_parser functions

Currently when a add_*_parser functions are called in main.py to build
and add the various subparsers to the main parser only a subparser is
passed to the functions. However if one of these functions need to build
a dynamic parser it needs also to call the main parser at least once to
parse once the command line and get the arguments necessary to finally
build the complete parser.

This commit fixes that limitation by passing also the main parser when
calling the subparser builders so it can be used to build the dynamic
subparses.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>

* [TVMC] micro: Add new micro context

This commit introduces support for micro targets (targets supported by
microTVM). It creates a new micro context under the new TVMC command
'tvmc micro'. Moreover, three new subcommands are made available in the
new context under 'tvmc micro': 'create-project', 'build', and 'flash'.

The new support relies on the Project API to query all the options
available for a selected platform (like Zephyr and Arduino) and also
from any adhoc platform template directory which provides a custom
Project API server.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>

* [TVMC] run: Add support for micro devices

Add support for micro devices using the Project API to query all options
available for a given platform and open a session with an specified
micro device. Use of 'tvmc run' with micro device is enabled via the
'--device micro' option in addition to the project directory.

Once the project directory is specified 'tvmc run' will make all options
specific to the platform found in the project dir available as options
in 'tvmc run'. They can be listed by '--list-options' and passed via
'--options'.

Signed-off-by: Gustavo Romero <gustavo.romero@linaro.org>
2021-11-19 10:14:04 -08:00
..