This is an automated email from the ASF dual-hosted git repository.

bgawrych pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git


The following commit(s) were added to refs/heads/master by this push:
     new ef0415d645 [BUGFIX] Fix floor divide (#21096)
ef0415d645 is described below

commit ef0415d6452160370cddfe654bb0abeaf53af894
Author: Kacper Pietkun <[email protected]>
AuthorDate: Mon Jul 18 15:50:14 2022 +0200

    [BUGFIX] Fix floor divide (#21096)
    
    * Fixed floor_divide bug on float16
    
    * Made separate version for half_t with division made on float
    
    * Update Contributors.md
---
 CONTRIBUTORS.md           |  1 +
 src/operator/mshadow_op.h | 15 +++++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index c214571224..716f146b78 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -301,6 +301,7 @@ List of Contributors
 * [Zhenghui Jin](https://github.com/barry-jin)
 * [Dominika Jedynak](https://github.com/DominikaJedynak)
 * [Adam Grabowski](https://github.com/agrabows)
+* [Kacper Pietkun](https://github.com/Kacper-Pietkun)
 
 Label Bot
 ---------
diff --git a/src/operator/mshadow_op.h b/src/operator/mshadow_op.h
index 991cae79d1..f048618675 100644
--- a/src/operator/mshadow_op.h
+++ b/src/operator/mshadow_op.h
@@ -248,10 +248,17 @@ struct floor_divide : public mxnet_op::tunable {
     return static_cast<bool>(::floor(a / b));
   }
 
-  template <
-      typename DType,
-      typename std::enable_if<!std::is_integral<DType>::value && 
!std::is_same<DType, float>::value,
-                              int>::type = 0>
+  MSHADOW_XINLINE static mshadow::half::half_t Map(mshadow::half::half_t a,
+                                                   mshadow::half::half_t b) {
+    return static_cast<mshadow::half::half_t>(
+        ::floor(static_cast<float>(a) / static_cast<float>(b)));
+  }
+
+  template <typename DType,
+            typename std::enable_if<!std::is_integral<DType>::value &&
+                                        !std::is_same<DType, float>::value &&
+                                        !std::is_same<DType, 
mshadow::half::half_t>::value,
+                                    int>::type = 0>
   MSHADOW_XINLINE static DType Map(DType a, DType b) {
     return ::floor(a / b);
   }

Reply via email to