Skip to content

[microTVM] Add platform version check to template project#9274

Merged
junrushao merged 13 commits into
apache:mainfrom
mehrdadh:add_platform_version
Oct 25, 2021
Merged

[microTVM] Add platform version check to template project#9274
junrushao merged 13 commits into
apache:mainfrom
mehrdadh:add_platform_version

Conversation

@mehrdadh

Copy link
Copy Markdown
Member

This PR:

  • adds platform version check to both Arduino and Zephyr
  • adds macro for version in different files to make it easier to find when update is needed.

@mehrdadh

Copy link
Copy Markdown
Member Author

cc @areusch @gromero @guberti

Comment thread apps/microtvm/arduino/template_project/microtvm_api_server.py Outdated
def generate_project(self, model_library_format_path, standalone_crt_dir, project_dir, options):
# Check Arduino version
version = self._get_platform_version(options["arduino_cli_cmd"])
if version != ARDUINO_CLI_VERSION:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm not sure we should do an exact match check. cc @guberti do you have a better suggestion as to how loose we should be? i could even just be okay with a warning

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think two levels of version, Major + Minor, is enough. We don't need to check the patch level version since they usually don't change interfaces. I discussed this with @gromero and that seems to be the case for Zephyr. For Arduino I got the same impression based on their release messages: https://github.com/arduino/arduino-cli/releases
@guberti probably has more info here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea the Arduino CLI seems to be relatively stable - this looks fine to me.

@gromero gromero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mehrdadh Only regarding the Zephyr platform changes and considering the nit pointed by Andrew is fixed, LGTM! I think that's a nice enhancement and that it's right for now to match exactly against Zephyr MAJOR and MINOR versions and so treat the version as a string. In the future if 2.5 becomes the minimum version supported on microTVM (not an exact match) we can easily adapt the code to match against, for instance, a float, like it's done in https://github.com/apache/tvm/blob/main/python/tvm/topi/arm_cpu/arm_utils.py#L24

Thanks!

@mehrdadh mehrdadh force-pushed the add_platform_version branch from 8c73aed to 1b0077c Compare October 15, 2021 19:16
@mehrdadh

Copy link
Copy Markdown
Member Author

@gromero thanks for the review.
I changed the versions to float so we could do comparison in future. Since we only tested Zephyr/Arduino with the current versions (2.5/0.18), we just compare with the exact version for now. In future, we can change this to be like >= MIN_VERSION_SUPPORTED.

Comment thread apps/microtvm/zephyr/template_project/microtvm_api_server.py Outdated

@gromero gromero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed these two typos on my last review. Could you please fix them?

Otherwise LGTM!

Comment thread apps/microtvm/arduino/template_project/microtvm_api_server.py Outdated
Comment thread apps/microtvm/zephyr/template_project/microtvm_api_server.py Outdated

@gromero gromero left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't comment on Arduino versioning, but since we now just warn when versions don't match rather than abort by default I'm ok with it. Plus the versioning mechanism can now be used for non exact matches, so LGTM. Thanks.

@mehrdadh

Copy link
Copy Markdown
Member Author

@areusch PTAL when you have time.
thanks!

@areusch areusch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mehrdadh sorry for delay--mostly small things here.

Comment thread apps/microtvm/arduino/template_project/microtvm_api_server.py Outdated
Comment thread apps/microtvm/arduino/template_project/microtvm_api_server.py
Comment thread apps/microtvm/arduino/template_project/microtvm_api_server.py Outdated
Comment thread apps/microtvm/arduino/template_project/microtvm_api_server.py Outdated
Comment thread apps/microtvm/reference-vm/arduino/base-box/base_box_provision.sh
Comment thread apps/microtvm/zephyr/template_project/microtvm_api_server.py
Comment thread docker/install/ubuntu_install_zephyr.sh

@guberti guberti left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Sorry about the delay caused by my midterms and being sick.

def generate_project(self, model_library_format_path, standalone_crt_dir, project_dir, options):
# Check Arduino version
version = self._get_platform_version(options["arduino_cli_cmd"])
if version != ARDUINO_CLI_VERSION:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea the Arduino CLI seems to be relatively stable - this looks fine to me.

def _get_platform_version(self, arduino_cli_path: str) -> float:
version_output = subprocess.check_output([arduino_cli_path, "version"], encoding="utf-8")
version_output = (
version_output.replace("\n", "").replace("\r", "").replace(":", "").lower().split(" ")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What exactly is this line stripping out? Can we use a regex or .strip()? I'd love to see a comment here with the standard output of arduino-cli version so I can better understand what's happening here.

@mehrdadh mehrdadh Oct 22, 2021

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the review. I will add the format as a comment and change it to use regex in the following PR which is waiting for this:
#9309

@junrushao junrushao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert in microTVM, but the other parts LGTM

@junrushao

Copy link
Copy Markdown
Member

Given @areusch is out this week, and it's been approved by multiple contributors in our community, I believe we can go ahead to merge this PR to unblock a subsequent one. What do you think @mehrdadh

@mehrdadh

Copy link
Copy Markdown
Member Author

@junrushao1994 sounds good to me. thanks!

@junrushao junrushao merged commit 133a7dc into apache:main Oct 25, 2021
@junrushao

Copy link
Copy Markdown
Member

Thanks @mehrdadh @guberti @gromero! The PR is merged

@mehrdadh mehrdadh deleted the add_platform_version branch October 25, 2021 18:19
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 7, 2022
* add platform version to project template

* fix arduino cli version on qemu

* specify arduino/zephyr version everywhere

* cleanup

* address comments

* fix warning message

* fix typo

* trigger

* trigger

* address comments

* trigger

* trigger
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
* add platform version to project template

* fix arduino cli version on qemu

* specify arduino/zephyr version everywhere

* cleanup

* address comments

* fix warning message

* fix typo

* trigger

* trigger

* address comments

* trigger

* trigger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants