Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[microTVM] Remove Arduino aot code #8869

Merged
merged 4 commits into from
Sep 4, 2021

Conversation

guberti
Copy link
Member

@guberti guberti commented Aug 27, 2021

PR #8758 changed the way AOT is handled in microTVM, which caused my Arduino PR to stop working. I should have been caught by the unit tests since it caused Arduino project compilation to stop working, but because I called subprocess.run in microtvm_api_server.py without passing check=True, the tests still pass.

This PR fixes the Arduino implementation of microTVM, changes the unit tests for Arduino to use check=True, and adds a regression test to make sure the unit tests will catch compilation failures.

@mehrdadh @areusch

@guberti guberti changed the title Remove Arduino aot code [microTVM] Remove Arduino aot code Aug 27, 2021
@mehrdadh
Copy link
Member

mehrdadh commented Aug 27, 2021

#8857
You guys need to coordinate on this.

@guberti
Copy link
Member Author

guberti commented Aug 27, 2021

I've rebased the PR on top of main now that #8857 is merged. This PR is ready for review.

Copy link
Contributor

@areusch areusch left a comment

Choose a reason for hiding this comment

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

@guberti thanks for this--a couple questions about your test fixtures

tests/micro/arduino/test_arduino_workflow.py Outdated Show resolved Hide resolved
tests/micro/arduino/test_arduino_workflow.py Outdated Show resolved Hide resolved
@guberti
Copy link
Member Author

guberti commented Aug 30, 2021

@guberti thanks for this--a couple questions about your test fixtures

The more I think about it, the more the save_generated_project_state fixture seems like a gross hack. It can create really weird bugs where microtvm_api_server.py is still running, but its source file has been repeatedly deleted and restored.

Even more so, the idea of having these saved project tests doesn't really fit with the test's "goal" - of simulating a user workflow of building and deploying a model on device.

IMO, the cleanest solution is to build a whole new test, test_arduino_error_detection, and move them there. I've done that with 3a8ea4c - take a look and LMK if you agree @areusch.

Copy link
Member

@Mousius Mousius left a comment

Choose a reason for hiding this comment

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

Thanks for following up on this @guberti, apologies I didn't pick this up in my original PR - I appreciate your diligence 😸 I just have a few suggestions here.

tests/micro/arduino/test_arduino_error_detection.py Outdated Show resolved Hide resolved

@pytest.fixture(scope="function")
def workspace_dir(request, platform):
return conftest.make_workspace_dir("arduino_error_detection", platform)
Copy link
Member

Choose a reason for hiding this comment

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

Given these fixtures are only used as part of the tests in this folder, and conftest is meant for auto-registration or pytest configuration rather than to hold helpers and utils, could these be either moved fully into conftest as fixtures or the underlying function moved into a more suitably named file?

Copy link
Member Author

Choose a reason for hiding this comment

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

The scope fixture of workspace_dir varies from test to test (for example, test_arduino_workflowhas it at module scope), and I suspect tests with more complexworkspace_dirsetups will be added in the future. For that reason, I'd prefer to defineworkspace_dirindividually in each test, but use the helper functionmake_workspace_dir` to avoid code reuse. I've also added a comment to each of these functions to clarify it.

That said, if you feel strongly I'm also open to other solutions, like defining multiple kinds of workspace dirs in conftest (e.g. a module_scope_workspace_dir, per_function_workspace_dir, etc.).

Copy link
Member

Choose a reason for hiding this comment

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

Argh, I feel like I could've been clearer here, my apologies. My suggestion is not to have general functions in conftest.py but rather in a different file such as a workspace.py to include from the test. This means only pytest-specific things end up in conftest.py, I have no issue with fixtures local to the test files which then use those functions.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, that makes more sense. I like the idea of moving non-pytest code into a workspace.py, but I think that might be OOS for this PR. Definitely worth addressing in a follow up though!

Copy link
Member

Choose a reason for hiding this comment

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

Agreed, it'd be good to have the move isolated in another PR 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

i agree with @Mousius sentiment--let's place test_utils in a file called test_utils or similar. can be a follow-up PR.

@guberti
Copy link
Member Author

guberti commented Sep 2, 2021

@Mousius Your comments should be addressed by bb37393 - take a look when you have a sec!

@Mousius
Copy link
Member

Mousius commented Sep 2, 2021

Apologies @guberti, I was a bit unclear in my initial response and I've introduced more changes, feel free to reach out if you need more clarification 😸

Break error detection tests into separate file

Address comments from Mousius

Re-add necessary fixture
@guberti
Copy link
Member Author

guberti commented Sep 2, 2021

Apologies @guberti, I was a bit unclear in my initial response and I've introduced more changes, feel free to reach out if you need more clarification

Oops, it was really late when I made those previous changes :). Should be fixed now @Mousius!

Copy link
Member

@Mousius Mousius left a comment

Choose a reason for hiding this comment

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

Looks good to me, removes the AOT code and then some 😸

Copy link
Contributor

@leandron leandron left a comment

Choose a reason for hiding this comment

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

LGTM

@areusch areusch merged commit 9f52e7e into apache:main Sep 4, 2021
ylc pushed a commit to ylc/tvm that referenced this pull request Sep 29, 2021
* Fix Arduino DLDevice includes

* microtvm_api_server fails if commands fail

* Add regression test for microtvm_api_server not failing

* Address PR comments

Break error detection tests into separate file

Address comments from Mousius

Re-add necessary fixture
ylc pushed a commit to ylc/tvm that referenced this pull request Jan 13, 2022
* Fix Arduino DLDevice includes

* microtvm_api_server fails if commands fail

* Add regression test for microtvm_api_server not failing

* Address PR comments

Break error detection tests into separate file

Address comments from Mousius

Re-add necessary fixture
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