Skip to content

[TS] Add complex support for more ops #54541

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

Closed
wants to merge 26 commits into from

Conversation

anjali411
Copy link
Contributor

@anjali411 anjali411 commented Mar 23, 2021

Stack from ghstack:

Differential Revision: D27599114

@facebook-github-bot
Copy link
Contributor

facebook-github-bot commented Mar 23, 2021

💊 CI failures summary and remediations

As of commit 3516612 (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 to the (internal) Dr. CI Users group.

Click here to manually regenerate this comment.

anjali411 added a commit that referenced this pull request Mar 24, 2021
ghstack-source-id: 9e614ee
Pull Request resolved: #54541
TODO: add tests


[ghstack-poisoned]
TODO: add tests


[ghstack-poisoned]
TODO: add tests


[ghstack-poisoned]
TODO: add tests


[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Mar 24, 2021
ghstack-source-id: b37978c
Pull Request resolved: #54541
DEFINE_SCALAR_SCALAR_BINARY_OP(
DEFINE_INT_COMPLEX_OP(aten::log, std::log(a) / std::log(b), complex),
DEFINE_FLOAT_COMPLEX_OP(aten::log, std::log(a) / std::log(b), complex),
DEFINE_SCALAR_BINARY_OP_WITH_COMPLEX(

Choose a reason for hiding this comment

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

Suggested change
DEFINE_SCALAR_BINARY_OP_WITH_COMPLEX(
DEFINE_SCALAR_SCALAR_BINARY_OP_WITH_COMPLEX(

As discussed this should probably be DEFINE_SCALAR_SCALAR_BINARY_OP_WITH_COMPLEX to avoid naming conflicts with aten::log for tensors.

TODO: add tests


[ghstack-poisoned]
TODO: add tests


[ghstack-poisoned]
TODO: add tests


[ghstack-poisoned]
TODO: add tests


[ghstack-poisoned]
TODO: add tests


[ghstack-poisoned]
TODO: add tests


[ghstack-poisoned]
TODO: add tests


[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Mar 30, 2021
ghstack-source-id: e7f5531
Pull Request resolved: #54541
TODO: add tests


[ghstack-poisoned]
anjali411 added a commit that referenced this pull request Apr 6, 2021
ghstack-source-id: 9d347f7
Pull Request resolved: #54541
@SplitInfinity SplitInfinity requested review from SplitInfinity and removed request for SplitInfinity April 8, 2021 03:34
Copy link

@SplitInfinity SplitInfinity left a comment

Choose a reason for hiding this comment

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

Just some nits and one or two questions.

anjali411 added a commit that referenced this pull request Apr 25, 2021
ghstack-source-id: c82eeea
Pull Request resolved: #54541
@anjali411 anjali411 requested a review from SplitInfinity May 6, 2021 18:52
anjali411 added a commit that referenced this pull request May 6, 2021
ghstack-source-id: b5a6d28
Pull Request resolved: #54541
anjali411 added a commit that referenced this pull request May 12, 2021
ghstack-source-id: 8661adf
Pull Request resolved: #54541
@anjali411 anjali411 requested a review from SplitInfinity May 12, 2021 13:29
anjali411 added a commit that referenced this pull request May 12, 2021
ghstack-source-id: 16ba113
Pull Request resolved: #54541
@anjali411 anjali411 added the module: complex Related to complex number support in PyTorch label May 12, 2021
Comment on lines 306 to 315
def fn5(a: complex, b: int):
return a == b
def fn6(a: complex, b: int):
return a != b

with self.assertRaises(RuntimeError):
self.checkScript(fn5, (x1, 1))
with self.assertRaises(RuntimeError):
self.checkScript(fn6, (x1, 1))

Choose a reason for hiding this comment

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

Why have these tests been removed? I think I commented about them earlier and that's why you added them?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right I saw an AddressSanitizer failure on just ASAN after I added them. Just wanted to verify if that was it.

@@ -99,7 +106,7 @@ def checkCmath(func_name, funcs_template=funcs_template):
self.assertEqual(res_python, res_script, msg=msg)

unary_ops = ['log', 'log10', 'sqrt', 'exp', 'sin', 'cos', 'asin', 'acos', 'atan', 'sinh', 'cosh',
'tanh', 'asinh', 'acosh', 'atanh', 'phase']
'tanh', 'asinh', 'acosh', 'atanh', 'phase', 'isinf', 'isnan', 'isfinite']

# --- Unary ops ---
for op in unary_ops:

Choose a reason for hiding this comment

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

One cool thing I learned about recently: https://docs.python.org/3/library/unittest.html#distinguishing-test-iterations-using-subtests

Using with self.subTest(op): here might make it clear which specific test being generated within this one test is failing.

Copy link
Contributor Author

@anjali411 anjali411 May 12, 2021

Choose a reason for hiding this comment

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

wow looks super useful!

def pow_float_complex(x: float, y: complex):
return pow(x, y)


Choose a reason for hiding this comment

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

Suggested change

@@ -120,7 +153,6 @@ def func():
for x in (float_consts + complex_consts):
checkCmath(x, funcs_template=func_constants_template)


Choose a reason for hiding this comment

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

Remove

Copy link

@SplitInfinity SplitInfinity left a comment

Choose a reason for hiding this comment

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

I noticed you got rid of tests that we added specifically because we were missing coverage for invalid comparisons between int and complex (or something like that). Can you comment on that?

Copy link

@SplitInfinity SplitInfinity left a comment

Choose a reason for hiding this comment

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

Ok approving but I strongly strongly recommend trying to add those tests in a follow up diff. They're not super valuable by themselves but the error logs from the failure make me think that they might have triggered a real issue that we should look into and fix.

@anjali411
Copy link
Contributor Author

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

@facebook-github-bot
Copy link
Contributor

@anjali411 merged this pull request in 82d7149.

krshrimali pushed a commit to krshrimali/pytorch that referenced this pull request May 19, 2021
Summary: Pull Request resolved: pytorch#54541

Test Plan: Imported from OSS

Reviewed By: SplitInfinity

Differential Revision: D27599114

Pulled By: anjali411

fbshipit-source-id: 182d4480fd788599c408bfaf0d23baf3d9a4e967
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla signed Merged module: complex Related to complex number support in PyTorch oncall: jit Add this issue/PR to JIT oncall triage queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants