Skip to content

Conversation

@suo
Copy link
Member

@suo suo commented Jun 25, 2019

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

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.
suo added 3 commits June 25, 2019 13:29
[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
Copy link
Contributor

@zdevito zdevito left a 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!
Copy link
Contributor

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* ?

Copy link
Member Author

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,
Copy link
Contributor

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);
Copy link
Contributor

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,
Copy link
Contributor

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 {
Copy link
Contributor

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
suo added 4 commits July 3, 2019 12:57
[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
@zou3519 zou3519 deleted the gh/suo/70/head branch July 10, 2019 22:21
@facebook-github-bot
Copy link
Contributor

@suo merged this pull request in c0674ce.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Merged module: cpp Related to C++ API oncall: jit Add this issue/PR to JIT oncall triage queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants