Skip to content

Commit

Permalink
[BUGFIX] Fix reuse of primitives for MKLDNN-AArch64. Fixes apache#20265.
Browse files Browse the repository at this point in the history
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 <crefeda.rodrigues@arm.com>
  • Loading branch information
cfRod committed Aug 3, 2021
1 parent aeff388 commit 20f9c2f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---------
Expand Down
9 changes: 9 additions & 0 deletions src/operator/operator_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,10 @@ class OpSignature {
hash = hash * 2 + arr.dtype();
eles.push_back(arr.dtype());
AddSign(arr.shape());
#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
Expand All @@ -643,6 +647,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);
Expand Down

0 comments on commit 20f9c2f

Please sign in to comment.