-
Notifications
You must be signed in to change notification settings - Fork 24.2k
[ONNX] Add module name as PythonOp attribute #67193
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
[ONNX] Add module name as PythonOp attribute #67193
Conversation
CI Flow Status⚛️ CI FlowRuleset - Version:
You can add a comment to the PR and tag @pytorchbot with the following commands: # ciflow rerun, "ciflow/default" will always be added automatically
@pytorchbot ciflow rerun
# ciflow rerun with additional labels "-l <ciflow/label_name>", which is equivalent to adding these labels manually and trigger the rerun
@pytorchbot ciflow rerun -l ciflow/scheduled -l ciflow/slow For more information, please take a look at the CI Flow Wiki. |
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 1083490 (more details on the Dr. CI page): 💚 💚 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. |
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.
- Could you please add a test that demonstrates the new behavior?
- The PR title is misleading. This change does not actually add the fully qualified name as an attribute, it adds the module name. I think it'd be perfectly reasonable to add the qualified name instead if that's what you want to do. Just use
__qualname__
instead of__module__
. That may actually be better since it seems from the docs that__module__
may beNone
but__qualname__
should always be set. But either way seems OK to me, just make sure the PR title matches the implementation.
@@ -621,6 +621,20 @@ PyObject* process_outputs(PyObject *op_obj, const std::shared_ptr<PyNode>& cdata | |||
} | |||
} | |||
|
|||
auto module_name = PyDict_GetItemString(((PyTypeObject*)op_obj)->tp_dict, "__module__"); | |||
if (!module_name) { | |||
return 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.
Could you please justify the error handling code here?
It seems like most uses of this code probably won't mind if the module is missing, so making this condition return early seems like it may not be the right thing to do.
5c2e3c6
to
afc24d0
Compare
afc24d0
to
1a9eb48
Compare
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.
Thanks!
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.
LGTM
* Add module name as pythonOp attr * Move to trace_post_record * Add tests * Code compactness
* Add module name as pythonOp attr * Move to trace_post_record * Add tests * Code compactness
* Add module name as pythonOp attr * Move to trace_post_record * Add tests * Code compactness
* Add module name as pythonOp attr * Move to trace_post_record * Add tests * Code compactness
* Add module name as pythonOp attr * Move to trace_post_record * Add tests * Code compactness
* Add module name as pythonOp attr * Move to trace_post_record * Add tests * Code compactness
…te (#67193)" * Add module name as pythonOp attr * Move to trace_post_record * Add tests * Code compactness [ghstack-poisoned]
* Add module name as pythonOp attr * Move to trace_post_record * Add tests * Code compactness [ghstack-poisoned]
Summary: Pull Request resolved: #73281 * Add module name as pythonOp attr * Move to trace_post_record * Add tests * Code compactness Test Plan: Imported from OSS Reviewed By: jbschlosser Differential Revision: D34625647 Pulled By: malfet fbshipit-source-id: b04b2a4f1dc2cf733fcf50a3b022337f80d6eead
Summary: Pull Request resolved: #73281 * Add module name as pythonOp attr * Move to trace_post_record * Add tests * Code compactness Test Plan: Imported from OSS Reviewed By: jbschlosser Differential Revision: D34625647 Pulled By: malfet fbshipit-source-id: b04b2a4f1dc2cf733fcf50a3b022337f80d6eead (cherry picked from commit 56e8658)
Stores the module name of the autograd function as attribute for a PythonOp node in the IR graph.
Before this modification:
After this modification: