Skip to content
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

Support doc_string for TorchBind custom classes #46576

Closed
wants to merge 1 commit into from
Closed

Support doc_string for TorchBind custom classes #46576

wants to merge 1 commit into from

Conversation

gmagogsfm
Copy link
Contributor

With this PR, users can optionally provide a "doc_string" to describe a class or its method. doc_string for TorchBind classes and methods are stored as doc_string properties in Function and ScriptClass. These dos_string properties are then exposed in Python layer via PyBind for doc generation.

Fixes #46047

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Oct 20, 2020
@dr-ci
Copy link

dr-ci bot commented Oct 20, 2020

💊 CI failures summary and remediations

As of commit fc9c761 (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).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions on the GitHub issue tracker or post in the (internal) Dr. CI Users group.

See how this bot performed.

This comment has been revised 28 times.

@gmagogsfm gmagogsfm marked this pull request as ready for review October 20, 2020 19:22
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmagogsfm has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@wanchaol wanchaol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! looks good, can you edit the test case to involve multiline docstring instead, and see if it works nicely (e.g. docstring like this), would like to ensure this works with multiline indented docstring

@gmagogsfm
Copy link
Contributor Author

Nice! looks good, can you edit the test case to involve multiline docstring instead, and see if it works nicely (e.g. docstring like this), would like to ensure this works with multiline indented docstring

Done, updated test to include a multi-line string. Please take another look

Copy link
Contributor

@wanchaol wanchaol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, a minor comment on the where the doc_string_ should be located.

@@ -110,6 +116,8 @@ struct BuiltinOpFunction : public Function {
std::function<void(Stack&)> callable_;

c10::FunctionSchema schema_;

std::string doc_string_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a bit curious here, why we added the doc_string_ inside BuiltinOpFunction instead of Function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function seems to be purely an interface. If we put a member here, then it either 1) limits how subclasses implement doc_string, maybe they want to generate it on the fly 2) or the member is a waste of memory. Let me know what you think.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed offline, let's keep doc_string only in builtinOpFunction as not all subclass of Function need this doc_string.

@@ -25,6 +25,11 @@ TORCH_API void preoptimizeGraph(std::shared_ptr<Graph>& graph);
// execution of the function. Method is a wrapper around a
// underlying Function that also provides a `self` object.
struct TORCH_API Function {
virtual const std::string& doc_string() const {
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 we can add the doc_string here, make it a default "', and then remove the no_doc_string?

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmagogsfm has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmagogsfm has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gmagogsfm has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@codecov
Copy link

codecov bot commented Oct 24, 2020

Codecov Report

Merging #46576 into master will decrease coverage by 0.00%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master   #46576      +/-   ##
==========================================
- Coverage   68.96%   68.96%   -0.01%     
==========================================
  Files         434      434              
  Lines       55993    55993              
==========================================
- Hits        38618    38617       -1     
- Misses      17375    17376       +1     

@facebook-github-bot
Copy link
Contributor

@gmagogsfm merged this pull request in f9b9430.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merged oncall: jit Add this issue/PR to JIT oncall triage queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[JIT] Docstrings for custom C++ classes
3 participants