You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by zh...@apache.org on 2021/09/08 20:00:35 UTC

[incubator-mxnet] branch v1.x updated: [BUGFIX] Fix reuse of primitives for MKLDNN-AArch64. Fixes #20265. (#20482)

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

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


The following commit(s) were added to refs/heads/v1.x by this push:
     new 197671b  [BUGFIX] Fix reuse of primitives for MKLDNN-AArch64. Fixes #20265. (#20482)
197671b is described below

commit 197671b70330f3d1db0942bf2a92479c647cdc49
Author: Crefeda Rodrigues <65...@users.noreply.github.com>
AuthorDate: Wed Sep 8 20:58:10 2021 +0100

    [BUGFIX] Fix reuse of primitives for MKLDNN-AArch64. Fixes #20265. (#20482)
    
    This fix is a workaround for the accuracy issue observed when MXNet is built with Compute Library (ACL).
    This change includes:
    * Updating MXNet's AddSign function to generate unique hashes for MKLDNN-ACL backend.
    * Adding DNNL_AARCH64_USE_ACL to CMakeLists.txt
    * Adding Crefeda Rodrigues to the contributors list
    
    Signed-off-by: cfRod <cr...@arm.com>
---
 CMakeLists.txt                 |  1 +
 CONTRIBUTORS.md                |  1 +
 src/operator/operator_common.h | 11 +++++++++++
 3 files changed, 13 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8a4b8b3..ff893ae 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -307,6 +307,7 @@ if(USE_MKLDNN)
       # Also ACL_ROOT_DIR need to be set
       set(CMAKE_CXX_STANDARD 14)
       set(DNNL_AARCH64_USE_ACL ON CACHE INTERNAL "" FORCE)
+      add_definitions(-DDNNL_AARCH64_USE_ACL=1)
     endif()
     if (MKLDNN_USE_APL)
       # APL needs to be added to LD_LIBRARY_PATH
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index cd5903d..f054218 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -255,6 +255,7 @@ List of Contributors
 * [Zhaoqi Zhu](https://github.com/zha0q1)
 * [Harshit Sharma](https://github.com/harshitshrma)
 * [Andrzej Kotlowski](https://github.com/anko-intel)
+* [Crefeda Faviola Rodrigues](https://github.com/cfRod)
 
 Label Bot
 ---------
diff --git a/src/operator/operator_common.h b/src/operator/operator_common.h
index 2628c80..808e46c 100644
--- a/src/operator/operator_common.h
+++ b/src/operator/operator_common.h
@@ -620,6 +620,12 @@ class OpSignature {
       hash = hash * 2 + arr.dtype();
       eles.push_back(arr.dtype());
       AddSign(arr.shape());
+// Note:Temporary workaround for the accuracy issue noted here #20265.
+// Future releases of Compute Library will aim to fix this.
+#if DNNL_AARCH64_USE_ACL == 1
+      auto ival = reinterpret_cast<const uint64_t>(arr.storage_handle().dptr);
+      AddSign(ival);
+#endif
 #if MXNET_USE_MKLDNN == 1
     }
 #endif
@@ -643,6 +649,11 @@ class OpSignature {
     eles.push_back(val);
   }
 
+  void AddSign(uint64_t val) {
+    hash = hash * 2 + val;
+    eles.push_back(val);
+  }
+
   void AddSign(float val) {
     hash = dmlc::HashCombine(hash, val);
     eles.push_back(val);