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

[Hexagon] Resolve breakage in test_hexagon/test_cache_read_write #10520

Merged
merged 8 commits into from
Mar 10, 2022

Conversation

Lunderberg
Copy link
Contributor

Breakage was caused by #9727, which didn't account for the new builtin::mem_copy() when computing the stack size in StackSizeChecker. This wasn't caught in CI, because the test requires the hexagon toolchain/hardware to be present.

Breakage was caused by apache#9727, which
didn't account for the new `builtin::mem_copy()` when computing the
stack size in `StackSizeChecker`.
@Lunderberg
Copy link
Contributor Author

@mehrdadh @adstraw

@@ -73,10 +84,19 @@ class StackSizeChecker : public StmtExprVisitor {
return MakeShape(op);
} else if (op->op.same_as(builtin::tvm_stack_make_array())) {
return MakeArray(op);
} else if (op->op.same_as(builtin::mem_copy())) {
return MakeMemCopy(op);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can't you just call MakeCallPacked for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not quite, because the additional string for the name of the PackedFunc to execute takes up another spot on the stack. But since I needed to test it in order to convince myself of that, I've added a comment to explain the reasoning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also figured that by having the MakeMemCopyHelper be shared between StackSizeChecker and BuiltInLower makes it harder for them to get out of sync in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

That makes sense. Does that mean that the name "nonexistent_function" is actually significant in the sense that its length equals or exceeds the length of the actually called function name? That would be worth a comment (if that's the case).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question to ask, and no, the function name isn't significant. The stack size here is in number of arguments, where a string only counts as a single argument.

@kparzysz-quic
Copy link
Contributor

Also, have you tried running this test on simulator? That ability was just added over the weekend.

@Lunderberg
Copy link
Contributor Author

Lunderberg commented Mar 7, 2022

I haven't tried running it on the simulator, no. Is there a good entry point or example for how to call into it?

Copy link
Contributor

@adstraw adstraw left a comment

Choose a reason for hiding this comment

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

LGTM

@mehrdadh
Copy link
Member

mehrdadh commented Mar 7, 2022

I think the reason that CI didn't catch this is because we don't run this test in CI. We need fix this in both of these files:
https://github.com/apache/tvm/blob/main/tests/scripts/task_python_hexagon.sh
https://github.com/apache/tvm/blob/main/tests/scripts/task_python_hexagon_simulator.sh
Basically, we need to run the test on the directory instead of the pytest file. So:

--- a/tests/scripts/task_python_hexagon.sh
+++ b/tests/scripts/task_python_hexagon.sh
@@ -25,4 +25,4 @@ make cython3
 
-run_pytest ctypes python-contrib-hexagon-no-hwardware tests/python/contrib/test_hexagon/test_launcher.py
+run_pytest ctypes python-contrib-hexagon-no-hwardware tests/python/contrib/test_hexagon

@Lunderberg can you add it to this PR?

@mehrdadh
Copy link
Member

mehrdadh commented Mar 7, 2022

@Lunderberg To run in the simulator, use the ci-hexagon docker image. Build TVM and hexagon api and then run task_python_hexagon_simulator.sh

@Lunderberg
Copy link
Contributor Author

Thank you, and I can run the change in the simulator, and have updated the ci scripts to include everything in the tests/python/contrib/test_hexagon directory.

@Lunderberg
Copy link
Contributor Author

After a discussion with @adstraw , updated the fix here to remove the StackSizeChecker entirely. Instead of having two cases that must be kept in sync, it instead runs the same BuiltinLower twice.

@adstraw
Copy link
Contributor

adstraw commented Mar 10, 2022

Still LGTM with latest changes and I can confirm the test in questions (test_cache_read_write.py) is passing locally.

@masahi masahi merged commit 1f60529 into apache:main Mar 10, 2022
@Lunderberg Lunderberg deleted the hexagon_mem_copy_lower branch March 10, 2022 14:23
pfk-beta pushed a commit to pfk-beta/tvm that referenced this pull request Apr 11, 2022
…che#10520)

* [Hexagon] Resolve breakage in test_hexagon/test_cache_read_write

Breakage was caused by apache#9727, which
didn't account for the new `builtin::mem_copy()` when computing the
stack size in `StackSizeChecker`.

* Added comment indicating need for StackSizeChecker::MakeMemCopy.

* Updated unittests to run all contrib/test_hexagon at CI.

* CI bump

* Fix lint formatting error.

* Updated fix to remove StackSizeChecker entirely.

* Bugfix, verify the precheck's allocations, not own.

* Bugfix, pass context information to the precheck.
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