You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2021/09/16 23:06:43 UTC

[GitHub] [incubator-mxnet] barry-jin opened a new pull request #20587: [API] Add bitwise_left/right_shift

barry-jin opened a new pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587


   ## Description ##
   Add bitwise_left/right_shift standard APIs. 
   Tracked in #20579
   
   ## Checklist ##
   ### Essentials ###
   - [x] PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
   - [ ] Changes are complete (i.e. I finished coding on this PR)
   - [ ] All changes have test coverage
   - [x] Code is well-documented
   
   ## Comments ##
   - If this change is a backward incompatible change, why must this change be made.
   - Interesting edge cases to note here
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on a change in pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
szha commented on a change in pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#discussion_r726727299



##########
File path: src/common/cuda/rtc/backward_functions-inl.h
##########
@@ -426,6 +426,48 @@ copysign_grad(const DType val,
   return (val >= 0 && val2 >= 0) || (val < 0 && val2 < 0) ? 1 : -1;
 }
 
+template <typename DType, typename DType2>
+__device__ inline mixed_type<DType, DType2>
+bitwise_left_shift_grad(const DType val,
+                        const DType2 val2) {
+  return op::power(static_cast<DType>(2), val2);
+}
+
+template <typename DType, typename DType2>
+__device__ inline mixed_type<DType, DType2>
+bitwise_left_shift_rgrad(const DType val,
+                         const DType2 val2) {
+  return val * op::power(static_cast<DType>(2), val2) * op::log(static_cast<type>(2));

Review comment:
       Why did it pass the test?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-948111147


   Jenkins CI successfully triggered : [website, unix-cpu, windows-gpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] barry-jin commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
barry-jin commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-948236766


   @mxnet-bot run ci [website]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-942826910


   Jenkins CI successfully triggered : [centos-cpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] barry-jin commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
barry-jin commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-948111107


   @mxnet-bot run ci [unix-cpu, website, windows-gpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] barry-jin commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
barry-jin commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-955765743


   @mxnet-bot run ci [centos-gpu, miscellaneous]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha merged pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
szha merged pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-940520954


   Jenkins CI successfully triggered : [unix-gpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on a change in pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
szha commented on a change in pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#discussion_r726712209



##########
File path: src/common/cuda/rtc/backward_functions-inl.h
##########
@@ -426,6 +426,48 @@ copysign_grad(const DType val,
   return (val >= 0 && val2 >= 0) || (val < 0 && val2 < 0) ? 1 : -1;
 }
 
+template <typename DType, typename DType2>
+__device__ inline mixed_type<DType, DType2>
+bitwise_left_shift_grad(const DType val,
+                        const DType2 val2) {
+  return op::power(static_cast<DType>(2), val2);
+}
+
+template <typename DType, typename DType2>
+__device__ inline mixed_type<DType, DType2>
+bitwise_left_shift_rgrad(const DType val,
+                         const DType2 val2) {
+  return val * op::power(static_cast<DType>(2), val2) * op::log(static_cast<type>(2));

Review comment:
       what does the `type` in `static_cast<type>` refer to?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] barry-jin commented on a change in pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
barry-jin commented on a change in pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#discussion_r726727743



##########
File path: src/common/cuda/rtc/backward_functions-inl.h
##########
@@ -426,6 +426,48 @@ copysign_grad(const DType val,
   return (val >= 0 && val2 >= 0) || (val < 0 && val2 < 0) ? 1 : -1;
 }
 
+template <typename DType, typename DType2>
+__device__ inline mixed_type<DType, DType2>
+bitwise_left_shift_grad(const DType val,
+                        const DType2 val2) {
+  return op::power(static_cast<DType>(2), val2);
+}
+
+template <typename DType, typename DType2>
+__device__ inline mixed_type<DType, DType2>
+bitwise_left_shift_rgrad(const DType val,
+                         const DType2 val2) {
+  return val * op::power(static_cast<DType>(2), val2) * op::log(static_cast<type>(2));

Review comment:
       I find that numpy operator tests in https://github.com/apache/incubator-mxnet/blob/master/tests/python/gpu/test_operator_gpu.py#L41 is overrided by https://github.com/apache/incubator-mxnet/blob/master/tests/python/gpu/test_numpy_op.py. So, in this pr I also rename test_numpy_op.py in tests/python/gpu to test_numpy_einsum.py.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha merged pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
szha merged pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-921321546


   Hey @barry-jin , Thanks for submitting the PR 
   All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands: 
   - To trigger all jobs: @mxnet-bot run ci [all] 
   - To trigger specific jobs: @mxnet-bot run ci [job1, job2] 
   *** 
   **CI supported jobs**: [centos-cpu, website, miscellaneous, windows-cpu, unix-cpu, windows-gpu, edge, unix-gpu, sanity, clang, centos-gpu]
   *** 
   _Note_: 
    Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin. 
   All CI tests must pass before the PR can be merged. 
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-926932031


   Jenkins CI successfully triggered : [unix-cpu, unix-gpu, centos-gpu, website]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-948236787


   Jenkins CI successfully triggered : [website]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] barry-jin commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
barry-jin commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-949260348


   @mxnet-bot run ci [website]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-949260363


   Jenkins CI successfully triggered : [website]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] barry-jin commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
barry-jin commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-926931997


   @mxnet-bot run ci [centos-gpu, unix-cpu, unix-gpu, website]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] szha commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
szha commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-953114755


   @barry-jin could you resolve conflict for this?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] barry-jin commented on a change in pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
barry-jin commented on a change in pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#discussion_r726724944



##########
File path: src/common/cuda/rtc/backward_functions-inl.h
##########
@@ -426,6 +426,48 @@ copysign_grad(const DType val,
   return (val >= 0 && val2 >= 0) || (val < 0 && val2 < 0) ? 1 : -1;
 }
 
+template <typename DType, typename DType2>
+__device__ inline mixed_type<DType, DType2>
+bitwise_left_shift_grad(const DType val,
+                        const DType2 val2) {
+  return op::power(static_cast<DType>(2), val2);
+}
+
+template <typename DType, typename DType2>
+__device__ inline mixed_type<DType, DType2>
+bitwise_left_shift_rgrad(const DType val,
+                         const DType2 val2) {
+  return val * op::power(static_cast<DType>(2), val2) * op::log(static_cast<type>(2));

Review comment:
       Thanks for pointing it out. Here `type` should be `mixed_type<DType, DType2>`. 




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-955765755


   Jenkins CI successfully triggered : [miscellaneous, centos-gpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] barry-jin commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
barry-jin commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-942826896


   @mxnet-bot run ci [centos-cpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] barry-jin commented on pull request #20587: [API] Add bitwise_left/right_shift

Posted by GitBox <gi...@apache.org>.
barry-jin commented on pull request #20587:
URL: https://github.com/apache/incubator-mxnet/pull/20587#issuecomment-940520930


   @mxnet-bot run ci [unix-gpu]


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org