-
Notifications
You must be signed in to change notification settings - Fork 26.3k
[jit] math module support: gcd, copysign, erf, erfc, expm1, fabs, gamma, lgamma #19707
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
Conversation
|
@pytorchbot retest this please |
|
@pytorchbot rebase this please |
|
Ok, I see tests fail in python 2 because there is no gcd method in math module. Seems like |
|
@eugenekoran you can guard |
|
@eellison Would you mind taking a look? |
eellison
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great thanks for doing this!
I added a couple comments to the tests, but they're nits since it's test code
test/test_jit.py
Outdated
| # map functions to the test values from their domains | ||
| default_inputs = [1, 10, 0, -1, -1.5, 5.0, 1.5] | ||
| func_inputs = {func: default_inputs for func in ['erf', 'erfc', 'expm1', 'fabs']} | ||
| func_inputs.update( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: would be a little more readable & not duplicate the default inputs if you had something like -
zero_not_def = ['gamma', 'lgamma']
and then below you can add a line like:
if func in zero_not_def and scalar == 0: continue
test/test_jit.py
Outdated
| # type: (float, float) -> float | ||
| return math.copysign(x, y) | ||
|
|
||
| for inputs in [(3, 5), (3, -5), (-3, 5), (-3, -5), (3, 0), (0, 3)]: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: to avoid duplicating the list of scalars, you can define all inputs as floats, and then cast the int inputs.
|
Looks like you have a lint failure: This one's pretty easy to fix. For future reference: https://github.com/pytorch/pytorch/wiki/Lint-as-you-type |
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eellison has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
@eellison @driazati Refer to issue #19026