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

[JIT] Docstrings for custom C++ classes #46047

Closed
jamesr66a opened this issue Oct 8, 2020 · 3 comments
Closed

[JIT] Docstrings for custom C++ classes #46047

jamesr66a opened this issue Oct 8, 2020 · 3 comments
Assignees
Labels
oncall: jit Add this issue/PR to JIT oncall triage queue
Projects

Comments

@jamesr66a
Copy link
Collaborator

jamesr66a commented Oct 8, 2020

We should have a way to specify docstrings on a) custom registered classes and b) the methods thereof. I believe this will entail:

  1. C++ APIs for populating the docstring. I can't find a pybind11 equivalent for installing a docstring on a class, but it could be an extra string argument to the torch::class_<> constructor. For method definitions I think it should similarly be an extra string argument to class_::def()
  2. A way to represent docstrings in the TorchScript type system. For classes, it could preferably be a __doc__ attribute, or a special case method on the ClassType:
    struct CAFFE2_API ClassType : public NamedType {
    . For methods, I think we would need to add a special docstring method to jit::Function:
    struct TORCH_API Function {
  3. Then, in the Python bindings, for classes we would need to bind in a __doc__ property to access the docstring as we defined in step (2):
    .def("__call__", &ScriptClass::__call__);
    . For functions similarly we would bind in the __doc__ property on ScriptFunction:
    py::class_<StrongFunctionPtr>(m, "ScriptFunction", py::dynamic_attr())

Note that for any of these stages, if we can generalize the support to broader TorchScript support (particularly the frontend concerns), that would probably be a good idea

cc @gmagogsfm

@facebook-github-bot facebook-github-bot added the oncall: jit Add this issue/PR to JIT oncall triage queue label Oct 8, 2020
@github-actions github-actions bot added this to Need triage in JIT Triage Oct 8, 2020
@suo
Copy link
Member

suo commented Oct 8, 2020

Requested by @fmassa

@gmagogsfm
Copy link
Contributor

@wanchaol

I think this would be useful for torch.distributed as well.

@suo
Copy link
Member

suo commented Oct 8, 2020

@gmagogsfm gmagogsfm self-assigned this Oct 13, 2020
@gmagogsfm gmagogsfm moved this from Need triage to Pending in JIT Triage Oct 13, 2020
JIT Triage automation moved this from Pending to Done Oct 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
oncall: jit Add this issue/PR to JIT oncall triage queue
Projects
JIT Triage
  
Done
Development

Successfully merging a pull request may close this issue.

4 participants