-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Make script::Method a value type #21675
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
Now that modules are always first class, a Method is simply a pair of Function and Method object. It is no longer necessary to have a reified table of Methods and removes the need for locking.
Make script::Method a value type Now that modules are always first class, a Method is simply a pair of Function and Method object. It is no longer necessary to have a reified table of Methods and removes the need for locking. gh-metadata: pytorch pytorch 21675 gh/zdevito/64/head
Make script::Method a value type Now that modules are always first class, a Method is simply a pair of Function and Method object. It is no longer necessary to have a reified table of Methods and removes the need for locking. gh-metadata: pytorch pytorch 21675 gh/zdevito/64/head
Make script::Method a value type Now that modules are always first class, a Method is simply a pair of Function and Method object. It is no longer necessary to have a reified table of Methods and removes the need for locking. gh-metadata: pytorch pytorch 21675 gh/zdevito/64/head
Make script::Method a value type Now that modules are always first class, a Method is simply a pair of Function and Method object. It is no longer necessary to have a reified table of Methods and removes the need for locking. gh-metadata: pytorch pytorch 21675 gh/zdevito/64/head
| // can be removed as well | ||
| get_offset(name, EntityType::METHOD); | ||
| AT_ERROR("unreachable"); | ||
| AT_ERROR("Method '", name, "' is not defined."); |
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.
Let's swap this out for one of the new error methods while we're here
torch/csrc/jit/script/module.h
Outdated
| const std::vector<Method> get_methods() const { | ||
| return fmap(class_compilation_unit().get_functions(), | ||
| [&](const std::shared_ptr<Function> &func) { | ||
| return Method(const_cast<Module *>(this), func); |
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.
Can we remove this const_cast? It's not clear to me why methods need a mutable reference to their owner anyway
Make script::Method a value type Now that modules are always first class, a Method is simply a pair of Function and Method object. It is no longer necessary to have a reified table of Methods and removes the need for locking. gh-metadata: pytorch pytorch 21675 gh/zdevito/64/head
Make script::Method a value type Now that modules are always first class, a Method is simply a pair of Function and Method object. It is no longer necessary to have a reified table of Methods and removes the need for locking. gh-metadata: pytorch pytorch 21675 gh/zdevito/64/head
Make script::Method a value type Now that modules are always first class, a Method is simply a pair of Function and Method object. It is no longer necessary to have a reified table of Methods and removes the need for locking. gh-metadata: pytorch pytorch 21675 gh/zdevito/64/head
Make script::Method a value type Now that modules are always first class, a Method is simply a pair of Function and Method object. It is no longer necessary to have a reified table of Methods and removes the need for locking. gh-metadata: pytorch pytorch 21675 gh/zdevito/64/head
Make script::Method a value type Now that modules are always first class, a Method is simply a pair of Function and Method object. It is no longer necessary to have a reified table of Methods and removes the need for locking. gh-metadata: pytorch pytorch 21675 gh/zdevito/64/head
Make script::Method a value type Now that modules are always first class, a Method is simply a pair of Function and Method object. It is no longer necessary to have a reified table of Methods and removes the need for locking. gh-metadata: pytorch pytorch 21675 gh/zdevito/64/head
Make script::Method a value type Now that modules are always first class, a Method is simply a pair of Function and Method object. It is no longer necessary to have a reified table of Methods and removes the need for locking. gh-metadata: pytorch pytorch 21675 gh/zdevito/64/head
Make script::Method a value type Now that modules are always first class, a Method is simply a pair of Function and Method object. It is no longer necessary to have a reified table of Methods and removes the need for locking. gh-metadata: pytorch pytorch 21675 gh/zdevito/64/head
Stack from ghstack:
Now that modules are always first class, a Method is simply a pair
of Function and Method object. It is no longer necessary to have
a reified table of Methods and removes the need for locking.
Differential Revision: D15777725