Skip to content

Forbid Module.to with copy argument.#12617

Closed
t-vi wants to merge 4 commits intopytorch:masterfrom
t-vi:no_module_to_copy
Closed

Forbid Module.to with copy argument.#12617
t-vi wants to merge 4 commits intopytorch:masterfrom
t-vi:no_module_to_copy

Conversation

@t-vi
Copy link
Copy Markdown
Collaborator

@t-vi t-vi commented Oct 12, 2018

Module.to uses the Tensor.to parsing facility.
It should not, however, accept "copy" as a keyword/fourth positional
argument.

See #12571 for discussion.

Thank you @ssnl for noticing.

Module.to uses the Tensor.to parsing facility.
It should not, however, accept "copy" as a keyword/fourth positional
argument.

See pytorch#12571 for discussion.
Copy link
Copy Markdown
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

cc @ssnl

Maybe this deserves a Note, explaining that to is special and affects modules as well as functions?

Comment thread torch/nn/modules/module.py Outdated

if len(args) > 3:
raise TypeError("to() takes at most 3 arguments ({} given)".format(len(args)))
if "copy" in kwargs:

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

Copy link
Copy Markdown
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.

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

laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
Summary:
Module.to uses the Tensor.to parsing facility.
It should not, however, accept "copy" as a keyword/fourth positional
argument.

See pytorch#12571 for discussion.

Thank you SsnL for noticing.
Pull Request resolved: pytorch#12617

Differential Revision: D10392053

Pulled By: ezyang

fbshipit-source-id: b67a5def7993189b4b47193abc7b741b7d07512c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants