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

Add a warning message that torch.sign would not support complex numbers #43280

Closed
wants to merge 6 commits into from

Conversation

xuhdev
Copy link
Collaborator

@xuhdev xuhdev commented Aug 19, 2020

Stack from ghstack:

Differential Revision: D24538769

@dr-ci
Copy link

dr-ci bot commented Aug 19, 2020

💊 CI failures summary and remediations

As of commit e36d887 (more details on the Dr. CI page):


  • 1/1 failures introduced in this PR

🕵️ 1 new failure recognized by patterns

The following CI failures do not appear to be due to upstream breakages:

See CircleCI build pytorch_linux_xenial_py3_clang5_mobile_build (1/1)

Step: "Build" (full log | diagnosis details | 🔁 rerun)

Oct 23 23:57:43 caused by: Connection refused (os error 111)
Oct 23 23:57:43 ++++ extract_trap_cmd 
Oct 23 23:57:43 ++++ printf '%s\n' '' 
Oct 23 23:57:43 +++ printf '%s\n' cleanup 
Oct 23 23:57:43 ++ trap -- ' 
Oct 23 23:57:43 cleanup' EXIT 
Oct 23 23:57:43 ++ [[ pytorch-linux-xenial-py3-clang5-mobile-build != *pytorch-win-* ]] 
Oct 23 23:57:43 ++ which sccache 
Oct 23 23:57:43 ++ sccache --stop-server 
Oct 23 23:57:43 Stopping sccache server... 
Oct 23 23:57:43 error: couldn't connect to server 
Oct 23 23:57:43 caused by: Connection refused (os error 111) 
Oct 23 23:57:43 ++ true 
Oct 23 23:57:43 ++ rm /var/lib/jenkins/sccache_error.log 
Oct 23 23:57:43 rm: cannot remove '/var/lib/jenkins/sccache_error.log': No such file or directory 
Oct 23 23:57:43 ++ true 
Oct 23 23:57:43 ++ [[ pytorch-linux-xenial-py3-clang5-mobile-build == *rocm* ]] 
Oct 23 23:57:43 ++ SCCACHE_ERROR_LOG=/var/lib/jenkins/sccache_error.log 
Oct 23 23:57:43 ++ SCCACHE_IDLE_TIMEOUT=1200 
Oct 23 23:57:43 ++ RUST_LOG=sccache::server=error 
Oct 23 23:57:43 ++ sccache --start-server 
Oct 23 23:57:43 Starting sccache server... 

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 32 times.

@@ -266,7 +266,10 @@ Tensor& rsqrt_out(Tensor& result, const Tensor& self) { return unary_op_impl_out
Tensor rsqrt(const Tensor& self) { return unary_op_impl(self, at::rsqrt_out); }
Tensor& rsqrt_(Tensor& self) { return unary_op_impl_(self, at::rsqrt_out); }

Tensor& sign_out(Tensor& result, const Tensor& self) { return unary_op_impl_out(result, self, sign_stub); }
Tensor& sign_out(Tensor& result, const Tensor& self) {
TORCH_CHECK(!self.is_complex(), "Unlike NumPy, torch.sign is not intended to support complex numbers.");
Copy link
Contributor

@anjali411 anjali411 Aug 19, 2020

Choose a reason for hiding this comment

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

I don't think we need to add this. I think the current error is sufficient.

>>> a=torch.randn(4, dtype=torch.cdouble)
>>> a.sign()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: "sign_cpu" not implemented for 'ComplexDouble'

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Perhaps you can change the message in your #39955 ? This at least points users to the proper function.

Copy link
Contributor

Choose a reason for hiding this comment

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

sorry I don't follow. which message are you suggesting to update?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This message that I added here: "Unlike NumPy, torch.sign is not intended to support complex numbers. Please use sgn instead."

Copy link
Contributor

@anjali411 anjali411 Aug 25, 2020

Choose a reason for hiding this comment

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

I don't think we generally add these warning messages unless we are breaking BC or something. cc. @mruberry

Copy link
Collaborator

Choose a reason for hiding this comment

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

Redirecting users to look at torch.sgn (when it becomes available) seems like a helpful error message. It could be separated from the torch.sgn PR (as a follow-up like this). I would wait to add an error message here until torch.sgn is available, though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree that we should either wait until #39955 is merged, or having this message included in #39955 .

Copy link
Contributor

Choose a reason for hiding this comment

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

@xuhdev can you update the error message to what you mentioned above:
"Unlike NumPy, torch.sign is not intended to support complex tensors. Please use torch.sgn() instead."

@@ -5985,7 +5985,9 @@ def test_complex_assert_raises(self, device):
self.assertRaises(RuntimeError,
lambda: zeros.index_add(0, torch.arange(0, size[0], dtype=torch.long, device=device), tensor))

self.assertRaises(RuntimeError, lambda: torch.sign(torch.tensor([4j], device=device, dtype=dtype)))
with self.assertRaisesRegex(RuntimeError,
Copy link
Contributor

Choose a reason for hiding this comment

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

thanks good to have a test to check that sign throws an error for complex.

xuhdev added a commit that referenced this pull request Aug 19, 2020
ghstack-source-id: 89386811e2ec936ee883d29572770d9be8178d6b
Pull Request resolved: #43280
@ngimel ngimel added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Aug 25, 2020
xuhdev added a commit that referenced this pull request Oct 20, 2020
ghstack-source-id: 864a3a29e115954730bcafd943f81800f3838fff
Pull Request resolved: #43280
@xuhdev
Copy link
Collaborator Author

xuhdev commented Oct 20, 2020

@mruberry @anjali411 Do you think this is ready to merge now? #39955 has been merged.

@anjali411
Copy link
Contributor

@mruberry @anjali411 Do you think this is ready to merge now? #39955 has been merged.

yes looks good after the error message is updated to reference torch.sgn()

xuhdev added a commit that referenced this pull request Oct 21, 2020
ghstack-source-id: 684f326cd693d4473c08b4ff7ce6025615e046ec
Pull Request resolved: #43280
@xuhdev
Copy link
Collaborator Author

xuhdev commented Oct 21, 2020

@anjali411 I've added the reference now

Copy link
Contributor

@anjali411 anjali411 left a comment

Choose a reason for hiding this comment

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

lgtm

xuhdev added a commit that referenced this pull request Oct 23, 2020
ghstack-source-id: c8ddbac2c6fcf54c12d4b5cd82a4032f81e59f49
Pull Request resolved: #43280
@xuhdev
Copy link
Collaborator Author

xuhdev commented Oct 23, 2020

Updated the PR to fix an error in the test file

Copy link
Collaborator

@mruberry mruberry left a comment

Choose a reason for hiding this comment

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

Thanks @xuhdev!

@facebook-github-bot
Copy link
Contributor

@anjali411 merged this pull request in bcbb6ba.

1 similar comment
@facebook-github-bot
Copy link
Contributor

@anjali411 merged this pull request in bcbb6ba.

@facebook-github-bot
Copy link
Contributor

@anjali411 merged this pull request in bcbb6ba.

@xuhdev xuhdev deleted the gh/xuhdev/88/head branch October 27, 2020 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merged open source triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants