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

torch.nn.functional.log_softmax parameter '_stacklevel' undocumented #83163

Open
cheyennee opened this issue Aug 10, 2022 · 7 comments
Open

torch.nn.functional.log_softmax parameter '_stacklevel' undocumented #83163

cheyennee opened this issue Aug 10, 2022 · 7 comments
Labels
actionable module: nn Related to torch.nn triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@cheyennee
Copy link

cheyennee commented Aug 10, 2022

📚 The doc issue

The documentation of the very popular torch.nn.functional.log_softmax doesn't explain what _stacklevel is, why it's set to 3 and what to do with it.

Suggest a potential alternative/fix

No response

cc @albanD @mruberry @jbschlosser @walterddr @kshitij12345 @saketh-are

@vadimkantorov
Copy link
Contributor

vadimkantorov commented Aug 10, 2022

Related: #36524 #64038. As discussed there, this _stacklevel is a remnant of migrating to explicit-only dim and to control warnings about not setting dim and the default value used. I think since a long time ago, this _stacklevel argument should be deleted.

@cheyennee
Copy link
Author

Related: #36524. As discussed there, this _stacklevel is a remnant of migrating to explicit-only dim and to control warnings about not setting dim and the default value used. I think since a long time ago, this _stacklevel argument should be deleted.

I want to know whether the value of '_stacklevel' can set to string❓ Even value in documentation is set to 3, I found that when it's set to string, such as "max", these two API works normally.

import torch
results={}
arg_1 = torch.rand([4, 12, 141, 141], dtype=torch.float32)
arg_2 = -1
arg_3 = "max"
results['res'] = torch.nn.functional.softmax(arg_1,arg_2,_stacklevel=arg_3,)

@vadimkantorov
Copy link
Contributor

vadimkantorov commented Aug 10, 2022

I think the essence of the story is that _stacklevel is passed to some warnings.warn(...) function or even is unused now / cast implicitly. So it's not very interesting to inquire about its possible values. If I'm correct, this argument should be dropped entirely from arguments list, and this is the right course of action about _stacklevel

But hopefully we can hear from devs @albanD @ezyang

@cheyennee
Copy link
Author

I think the essence of the story is that _stacklevel is passed to some warnings.warn(...) function or even is unused now / cast implicitly. So it's not very interesting to inquire about its possible values. If I'm correct, this argument should be dropped entirely from arguments list, and this is the right course of action about _stacklevel

But hopefully we can hear from devs @albanD @ezyang

Get it. I think you're right, because just now I found that bool / list or other value could be assigned to _stacklevel. Thank u🥰

@ezyang
Copy link
Contributor

ezyang commented Aug 10, 2022

Let's drop it

@albanD
Copy link
Collaborator

albanD commented Aug 10, 2022

This argument is only used for the depraction warning raised when dim=None. Otherwise it is not used and its type is not checked indeed.

Since dim=None has been deprecated for 5+ years now (98e6744), I think it is ok to remove it (and remove the _stacklevel arg)

@albanD albanD added module: nn Related to torch.nn triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module actionable labels Aug 10, 2022
@vadimkantorov
Copy link
Contributor

vadimkantorov commented Aug 11, 2022

After dropping, probably even functional python wrapper can be dropped or auto-generated instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable module: nn Related to torch.nn triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

No branches or pull requests

4 participants