-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Allow torch._C to be recognized a module in torch.package #80917
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
🔗 Helpful links
✅ No Failures (0 Pending)As of commit 20daf5e (more details on the Dr. CI page): Expand to see more💚 💚 Looks good so far! There are no failures yet. 💚 💚 This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
This pull request was exported from Phabricator. Differential Revision: D37630120 |
…multipy Summary: This pr addresses pytorch#82 and pytorch#44. A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module and checks if the module we are looking for is in it's children. For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`. The corresponding PR in torch.package is pytorch/pytorch#80917 Differential Revision: D37630606 fbshipit-source-id: 4fc5e75524eebc4f71fe978f42fd80e48900d2e4
…multipy (pytorch#91) Summary: Pull Request resolved: pytorch#91 This pr addresses pytorch#82 and pytorch#44. A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module and checks if the module we are looking for is in it's children. For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`. The corresponding PR in torch.package is pytorch/pytorch#80917 Differential Revision: D37630606 fbshipit-source-id: 65e549b66550d676a0e766a5f0c38b417f038a20
…multipy (pytorch#91) Summary: Pull Request resolved: pytorch#91 This pr addresses pytorch#82 and pytorch#44. A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module and checks if the module we are looking for is in it's children. For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`. The corresponding PR in torch.package is pytorch/pytorch#80917 Differential Revision: D37630606 fbshipit-source-id: f18991665618291664a0b3b34c95f5dbb91247af
This pull request was exported from Phabricator. Differential Revision: D37630120 |
torch/package/package_importer.py
Outdated
# so we search if the package is actually there or not before calling the error. | ||
if isinstance( | ||
parent_module.__loader__, | ||
_frozen_importlib_external.ExtensionFileLoader, |
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 use https://docs.python.org/3/library/importlib.html#importlib.machinery.ExtensionFileLoader instead of _frozen_importlib_external since that's an internal module?
It's an alias for it
…multipy (pytorch#91) Summary: Pull Request resolved: pytorch#91 This pr addresses pytorch#82 and pytorch#44. A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module and checks if the module we are looking for is in it's children. For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`. The corresponding PR in torch.package is pytorch/pytorch#80917 Reviewed By: d4l3k Differential Revision: D37630606 fbshipit-source-id: 19e6bb808b893aaab39790929e130eb0bbd62d91
This pull request was exported from Phabricator. Differential Revision: D37630120 |
…multipy (pytorch#91) Summary: Pull Request resolved: pytorch#91 This pr addresses pytorch#82 and pytorch#44. A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module and checks if the module we are looking for is in it's children. For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`. The corresponding PR in torch.package is pytorch/pytorch#80917 Reviewed By: d4l3k Differential Revision: D37630606 fbshipit-source-id: ee562573ea4c0bbc43facc5ae9a0fc4ad8f29cd6
This pull request was exported from Phabricator. Differential Revision: D37630120 |
This pull request was exported from Phabricator. Differential Revision: D37630120 |
) Summary: Pull Request resolved: pytorch#80917 This pr addresses pytorch/multipy#82 and pytorch/multipy#44. The changes will be copied over to [pytorch/multipy](https://github.com/pytorch/multipy) as well. A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module and checks if the module we are looking for is in it's children. For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`. Test Plan: buck test caffe2/test:package Reviewed By: d4l3k Differential Revision: D37630120 fbshipit-source-id: 920f0838bfd7f9b4497b606125a688d319579a0c
This pull request was exported from Phabricator. Differential Revision: D37630120 |
…multipy (#91) Summary: Pull Request resolved: #91 This pr addresses #82 and #44. A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module and checks if the module we are looking for is in it's children. For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`. The corresponding PR in torch.package is pytorch/pytorch#80917 Reviewed By: d4l3k Differential Revision: D37630606 fbshipit-source-id: 59b5b7c291ccecef9f598a93c33719d348a339f5
@pytorchbot merge (Initiating merge automatically since Phabricator Diff has merged) |
@pytorchbot successfully started a merge job. Check the current status here |
Hey @PaliC. |
Summary: Pull Request resolved: #80917 This pr addresses pytorch/multipy#82 and pytorch/multipy#44. The changes will be copied over to [pytorch/multipy](https://github.com/pytorch/multipy) as well. A C extension module behaves a bit differently than a normal python package as it does not contain a `__path__` attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module and checks if the module we are looking for is in it's children. For example, if we are importing `torch._C._nn` we check if the parent `torch._C` is a C extension module if necessary, and then check if `torch._C._nn` is a proper child of `torch._C`. Test Plan: buck test caffe2/test:package Reviewed By: d4l3k Differential Revision: D37630120 fbshipit-source-id: 4a3b6a465cf03c83d75b04ccc3aceb41b4e9ccc9
Summary:
This pr addresses pytorch/multipy#82 and pytorch/multipy#44. The changes will be copied over to pytorch/multipy as well.
A C extension module behaves a bit differently than a normal python package as it does not contain a
__path__
attribute. However, these modules still have information about their submodules. This PR also checks if a module is a C extension module and checks if the module we are looking for is in it's children.For example, if we are importing
torch._C._nn
we check if the parenttorch._C
is a C extension module if necessary, and then check iftorch._C._nn
is a proper child oftorch._C
.Differential Revision: D37630120