-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[jit] Give functions qualified names #22206
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
Conversation
This makes it so that all code objects owned by a CompilationUnit will have a qualified name. This also means that Module performs one new duty: it does qualified name resolution by concating the Module qualified name with the method name to find the method in the owning CU.
[jit] Give functions qualified names This makes it so that all code objects owned by a CompilationUnit will have a qualified name. This also means that Module performs one new duty: it does qualified name resolution by concating the Module qualified name with the method name to find the method in the owning CU. gh-metadata: pytorch pytorch 22206 gh/suo/70/head
[jit] Give functions qualified names This makes it so that all code objects owned by a CompilationUnit will have a qualified name. This also means that Module performs one new duty: it does qualified name resolution by concating the Module qualified name with the method name to find the method in the owning CU. gh-metadata: pytorch pytorch 22206 gh/suo/70/head
[jit] Give functions qualified names This makes it so that all code objects owned by a CompilationUnit will have a qualified name. This also means that Module performs one new duty: it does qualified name resolution by concating the Module qualified name with the method name to find the method in the owning CU. gh-metadata: pytorch pytorch 22206 gh/suo/70/head
zdevito
left a comment
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.
This looks pretty good. The one thing that really should be changed is that define really should not take two definitions for the name (qualName and name in def), and ignore the one in the def. I think we should just add the prefix as part of the define function.
|
|
||
| std::vector<Function*> ClassType::methods() const { | ||
| return compilation_unit()->get_functions(); | ||
| // TODO: this needs to be made more efficient! |
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.
Why can't ClassType hold a list of Function* ?
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 will move that stuff from the other PR to this one.
| // same as above but parse the definitions from source | ||
| void define( | ||
| // prefix namespace to put all the defined functions into | ||
| // If null, |
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.
If null, what?
|
|
||
| Function* ClassType::getMethod(const std::string& name) const { | ||
| return compilation_unit_->find_function(name); | ||
| const auto qualname = QualifiedName(*qualified_name_obj(), name); |
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.
qualified_name_obj is really confusing. If you look at the methods in NamedType they are pretty redundant. We really should have NamedType just return the qualified name and rename qualified_name_obj to just qualifiedName.
|
|
||
| private: | ||
| std::unique_ptr<Function> define( | ||
| const c10::QualifiedName& name, |
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 this should be prefix, otherwise it is denormalized with Def
| } | ||
| c10::optional<Method> find_method(const std::string& name) const { | ||
| if (const auto fn = class_compilation_unit()->find_function(name)) { | ||
| c10::optional<Method> find_method(const std::string& basename) const { |
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.
This runs in the user's eval loop, so I am not really happy about having to allocate a new string in order to look up the function. I feel like the ClassType should just be holding onto this mapping directly.
[jit] Give functions qualified names This makes it so that all code objects owned by a CompilationUnit will have a qualified name. This also means that Module performs one new duty: it does qualified name resolution by concating the Module qualified name with the method name to find the method in the owning CU. gh-metadata: pytorch pytorch 22206 gh/suo/70/head
[jit] Give functions qualified names This makes it so that all code objects owned by a CompilationUnit will have a qualified name. This also means that Module performs one new duty: it does qualified name resolution by concating the Module qualified name with the method name to find the method in the owning CU. gh-metadata: pytorch pytorch 22206 gh/suo/70/head
[jit] Give functions qualified names This makes it so that all code objects owned by a CompilationUnit will have a qualified name. This also means that Module performs one new duty: it does qualified name resolution by concating the Module qualified name with the method name to find the method in the owning CU. gh-metadata: pytorch pytorch 22206 gh/suo/70/head
[jit] Give functions qualified names This makes it so that all code objects owned by a CompilationUnit will have a qualified name. This also means that Module performs one new duty: it does qualified name resolution by concating the Module qualified name with the method name to find the method in the owning CU. gh-metadata: pytorch pytorch 22206 gh/suo/70/head
[jit] Give functions qualified names This makes it so that all code objects owned by a CompilationUnit will have a qualified name. This also means that Module performs one new duty: it does qualified name resolution by concating the Module qualified name with the method name to find the method in the owning CU. gh-metadata: pytorch pytorch 22206 gh/suo/70/head
[jit] Give functions qualified names This makes it so that all code objects owned by a CompilationUnit will have a qualified name. This also means that Module performs one new duty: it does qualified name resolution by concating the Module qualified name with the method name to find the method in the owning CU. gh-metadata: pytorch pytorch 22206 gh/suo/70/head
Stack from ghstack:
This makes it so that all code objects owned by a CompilationUnit will
have a qualified name.
This also means that Module performs one new duty: it does
qualified name resolution by concating the Module qualified name with
the method name to find the method in the owning CU.
Differential Revision: D15998762