-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
[4/10] Code generation for Conv2D via CMSIS-NN #9331
Conversation
Adding @Mousius @manupa-arm @grant-arm @areusch for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the work! It seems not trivial compared to other operators.
I did a pass. PTAL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broadly looks good! Thanks @ashutosh-arm.
Just a few questions.
|
||
// Since the constants are kicked out of the local partitioned functions | ||
// a new call to local function is needed | ||
if (auto* func_node = call->op.as<FunctionNode>()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack
primfunc_ = tir::PrimFunc(func_signature, body, VoidType(), Map<tir::Var, tir::Buffer>(), | ||
DictAttrs(dict_attrs)); | ||
} | ||
|
||
Array<PrimExpr> CMSISNNDimensions(const Array<PrimExpr>& shape) { | ||
ICHECK(shape.size() == 4) << "Supports only CMSIS-NN shapes of dimension 4."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to test these or not ? Im not sure now. @Mousius ?
@ashutosh-arm could you retrigger this one? the docker image is updated now. |
@manupa-arm / @ashutosh-arm in general if we're adding things that raise exceptions as part of their interface we should be testing them. |
I agree for user facing exceptions. What about internal assertions that are not meant to be triggered in a user execution flow and are only meant to be triggered when a "developer" is changing the compilation stack ? Generally these assertions are derived from assumptions that a user flow will never trigger them and usually are about inputs to a particularly component. Having a test that does another assertion to check an assertion on input is working does only seem to give confidence that the function call is successfully able to pass in an argument to trigger the assertion. Ideally, a release build should remove these internal assertions as they were only dev facing assertions. Let me know if you still think it is worthwhile adding a test check an dev facing assertion that gives us confidence that a component is successfully able to pass in an input that violate an assumption that the developer took that a user flow will never trigger. If so we might want to check the assertion in this PR (here or in a follow up) |
I would question why we're adding them if they're in unreachable code paths, but if we do think they're worth adding I would consider them part of the contract of the internal function and thus should have associated tests for the behaviour (throwing an exception is now part of the functions behaviour). As per TVM Code Review Guidelines, we should add test coverage for anything we contribute. If we're happy that at some point someone may inadvertently change the behaviour of this function, then potentially it's not a necessary line of code and we can apply the YAGNI principle from extreme programming 😸 |
There is a fine line between defining a failing internal assert as a "behaviour" of the function and removing the assert just because it not executed in the present organization of the components.
Enforcing YAGNI to remove internal asserts will discourage developers from using asserts just because the execution path is not enforced today. In a summary I would support having internal assertions that makes it easier if another developer changes this code or re-uses some of it somewhere else. If it means we need a add a borderline meaningful test that uses as an assertion to see if the assertion inside the code is triggered, lets do that then. I guess what you are saying is we need a test for the above ICHECK in this PR? |
It doesn't, you're the committer responsible for this PR, if you genuinely disagree feel free to merge without test coverage - this has happened on other PRs I've reviewed.
Yip, I would advocate for full test coverage in line with the TVM Code Review Guidelines, working on the assumption we want the code to continue working for the forsee-able future. Though I don't think we should turn this PR into a debate on software testing - that's been going for a long time now 😸 . |
My position is to keep the assert (as originally added by @ashutosh-arm -- not a request for a change). I only oppose removing it on the basis it is not tested. Im happy to do it in a follow up if thats what @ashutosh-arm wants to do here ?
Hence the questioning here, because this exact point is questioned elsewhere but not here. Other places we committed to follow up if that is direction we want to take. cc : @ekalda @mbaret. Im pretty sure if we agree on this point we will do the necessary changes.
Im pretty sure we all want this -- just being lenient on internal asserts -- that is all. |
In my view, I don't wish to remove the assert as this is a code that could be reused and fail if caller does not meet asserted criterion. At the same time, testing all internal asserts should not be made into a policy. I say this because at certain times, we know that the previous flow, before this stage is reached, assumes certain things and has its own set of asserts. On another note, this cannot be tested in the existing CMSIS-NN testing infrastructure as there is no direct interface to access it. How do we test such APIs currently? Can someone please point me to an example? |
Yes, I think we agreed to add the tests in a follow-up PR if we decide to test the internal asserts in the future, so it would make sense for this PR to go in as it is as well. My (unchanged) view on the topic is that I agree with @manupa-arm that we should test the user facing asserts, but not the simple developer facing asserts. While it is a good practice to test all the functionality, I think we should always evaluate these kind of guidelines in the context of the specific project if we want to avoid getting stuck in dogmas. It is a valid point that perhaps we should remove the unreachable asserts then, but I think TVM is very much still a project in progress and I have found the developer facing asserts very useful, so I don't think they do any harm. In general, the NPU side of codebase is in constant flux at the moment, so a lot of tests means a lot of extra code to maintain and makes making changes harder. So at that stage I think there is more harm in testing ICHECKs than benefits in a from maintenance overhead. |
Alright thanks for the views! Lets not block PR on this -- it is certainly a high bandwidth discussion to be had. |
I am working on resolving the conflicts. |
Change-Id: Ifa9ee3bb0b5292ba9911f9c4fc2af508957cd784
Co-authored-by: Chris Sidebottom <chris.sidebottom@arm.com> Change-Id: I15e7e7e4fa864ddc469a4e430c4f472057290e8a
Change-Id: Ie4c6f27318978d69aec9131d79f9a3f28c99f3b0
Change-Id: I47b64db6a14732420952aad58488438ac80b7816
Thanks @ashutosh-arm @Mousius @areusch! |
This PR is for support of Conv2D via CMSIS-NN.
This PR is for support of Conv2D via CMSIS-NN.
This PR is for support of Conv2D via CMSIS-NN.
This PR is for support of Conv2D via CMSIS-NN.
This PR is for support of Conv2D via CMSIS-NN.
This PR is for support of Conv2D via CMSIS-NN.
Here is the tracking issue: #8646