-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Dynamic shape guards in C++ #139899
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
Dynamic shape guards in C++ #139899
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/139899
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit f7e4bb0 with merge base 19c3ba4 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
cc @anijain2305 |
torch/_dynamo/guards.py
Outdated
| import sympy | ||
|
|
||
| from torch._inductor.codecache import CppCodeCache | ||
| from torch._inductor.codegen.cpp_utils import cexpr |
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.
Sigh, layering violation lol
| ) -> Tuple[List[str], List[str]]: # regular, verbose | ||
| ) -> Tuple[ | ||
| List[str], List[str], List[Tuple[sympy.Expr, Dict[str, List[Source]]]] | ||
| ]: # regular, verbose, sympy |
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.
Re the changes here, would it make more sense to just directly do C++ rendering here directly? This prevents you from having to invent one-off sympy functions for special concepts we don't normally have in sympy. In general sympy IR is not a good IR for driving C++ codegen, IMO.
| if (!THPVariable_CheckExact(obj) && !THPVariable_Check(obj)) { | ||
| return false; | ||
| } |
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.
I think we should be able to skip this check. Because in the guard tree, this accessor will only be called from a GuardManager for a tensor.
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.
Just a ping on this.
|
I have done a quick non-rigorous review. The flow looks good to me. A few things that will help
|
|
cc @jansel as well |
Merge failedReason: Command Details for Dev Infra teamRaised by workflow job |
|
@pytorchbot merge |
Merge startedYour change will be merged once all checks pass (ETA 0-4 Hours). Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
Stack from ghstack (oldest at bottom):
cc @jgong5 @mingfeima @XiaobingSuper @sanchitintel @ashokei @jingxu10 @ezyang @SherlockNoMad @EikanWang @wenzhe-nrv @voznesenskym @penguinwu @Guobing-Chen @zhuhaozhe @blzheng @jiayisunx @chenyang78 @kadeng @chauhang @amjames