-
-
Notifications
You must be signed in to change notification settings - Fork 835
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
Speed up ElementwiseKernel launch #1318
Conversation
|
cupy/core/elementwise.pxi
Outdated
@@ -106,9 +111,14 @@ cdef _int_type = _int_iinfo.dtype.type | |||
|
|||
cpdef _python_scalar_to_numpy_scalar(x): | |||
# Note that isinstance(x, six_integer_types) matches with bool. | |||
if isinstance(x, bool): | |||
typ = type(x) |
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.
Is it safe? x
could be of some type derived from Python built-in scalars.
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.
Previous code uses _python_type_to_numpy_type
.
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.
Do you mean we are not going to support such types?
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.
OK, I will add fallback code.
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.
(By the way, I'm not insisting we should support them. But if we are not going to support them, it's better to make consensus and write in the documentation.)
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.
I found this condition.
Already, the input data is filtered by it.
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.
I can't follow the link you pasted, but if there's assumption on this function, it's better to write in 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.
Sorry, Please check this link.
https://github.com/okuta/cupy/blob/0a87a602e4b3a7276fd92bf753e94fcaa86288f2/cupy/core/elementwise.pxi#L152
336b0e7
to
e912c6e
Compare
I rebased. |
Jenkins CI test failed with status FAILURE. |
Jenkins, test this please. |
Jenkins CI test failed with status FAILURE. |
Jenkins CI test (for commit |
Jenkins CI test (for commit 56cf755) failed with status FAILURE. |
39f0dd4
to
8367883
Compare
@kmaehashi I change to use |
Jenkins CI test (for commit 8367883) failed with status FAILURE. |
from cupy.core cimport internal | ||
|
||
|
||
cdef dict _typenames_base = { |
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.
Are these mapping safe?
e.g. can we assume long long
== int64
?
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.
OK. I do not change this code.
cupy/core/_scalar.pyx
Outdated
cpdef CScalar _python_scalar_to_c_scalar(x): | ||
cdef CScalar ret = CScalar() | ||
typ = type(x) | ||
if x is bool: |
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.
x
-> typ
?
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.
Thanks
I fixed. |
Jenkins CI test (for commit d4e0210) failed with status FAILURE. |
Jenkins CI test (for commit 661cdfb) failed with status FAILURE. |
jenkins, test this please. |
Jenkins CI test (for commit 6920986) succeeded without errors! |
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.
LGTM except for the line I commented.
@@ -206,8 +208,30 @@ def test_invalid_stop_type(self): | |||
{'x': 2 ** 40, 'expect': 2 ** 40}, | |||
{'x': 2 ** 40 - 1, 'expect': 2 ** 40}, | |||
{'x': 2 ** 40 + 1, 'expect': 2 ** 41}, | |||
{'x': 2 ** 40 + 1, 'expect': 2 ** 41}, |
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.
This set of parameters is already in the test.
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.
I fixed.
Jenkins, test this please. |
Jenkins CI test (for commit f51d899, target branch master) failed with status FAILURE. |
The Jenkins failure ( |
Speed up ElementwiseKernel launch
Speed up ElementwiseKernel launch
Jenkins CI test (for commit f51d899, target branch master) failed with status FAILURE. |
Thanks! |
test code
before
python adam.py 7.55s user 0.68s system 99% cpu 8.234 total
python adam.py 7.57s user 0.71s system 99% cpu 8.291 total
python adam.py 7.74s user 0.70s system 99% cpu 8.456 total
python adam.py 7.82s user 0.66s system 99% cpu 8.482 total
after
python adam.py 5.04s user 0.67s system 99% cpu 5.711 total
python adam.py 4.76s user 0.68s system 99% cpu 5.454 total
python adam.py 4.82s user 0.66s system 99% cpu 5.492 total
python adam.py 4.92s user 0.70s system 99% cpu 5.637 total