-
Notifications
You must be signed in to change notification settings - Fork 88
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
Make argument constructor explicit #2346
Conversation
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.
looks good.
There is also argument(shape, std::nullptr)
. i wonder if it needs to be marked as explicit or not.
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.
looks fine. What was the perf issue?
You only need explicit on unary constructors. There is no implicit conversion for binary constructors. |
Codecov Report
@@ Coverage Diff @@
## develop #2346 +/- ##
========================================
Coverage 91.36% 91.36%
========================================
Files 439 439
Lines 16493 16493
========================================
Hits 15069 15069
Misses 1424 1424
|
Curious on this ? why implicit conversion caused perf issue ? |
Of the test cases, most ran incrementally faster with this tuning but one or two regressed to taking 10-20x as long as before. |
@@ -46,7 +46,7 @@ struct MIGRAPHX_EXPORT argument : raw_data<argument> | |||
{ | |||
argument() = default; | |||
|
|||
argument(const shape& s); | |||
explicit argument(const shape& s); |
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.
explicit argument(const shape& s); | |
// explicit to protect against passing argument to a function that only needs a shape | |
explicit argument(const shape& s); |
This build is OK for merge ✅ |
🔴torchvision-inceptionv3_1: FAILED: MIGraphX is not within tolerance - check verbose output🔴slim-inceptionv4_1: FAILED: MIGraphX is not within tolerance - check verbose output🔴bert_base_cased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output🔴bert_large_uncased_fp16: FAILED: MIGraphX is not within tolerance - check verbose output🔴distilgpt2_fp16: FAILED: MIGraphX is not within tolerance - check verbose output |
Paul said that when it implicitly converted function arguments from the shape type to the "argument" type, that caused it to make unnecessary memory allocations. I don't know the details of how much memory, or how many times it happened per inference, or why it only happened with a few models. |
This implicit conversion was causing the perf issus in #1668, as the function was using
argument
but passingshape
. So instead we should make the constructor explicit to avoid possible errors like this in the future.