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
…. (apache#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 <crefeda.rodrigues@arm.com>
  • Loading branch information
cfRod authored and josephevans committed Feb 28, 2022
1 parent ac4439d commit d903af9
Show file tree
Hide file tree
Showing 3 changed files with 13 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
11 changes: 11 additions & 0 deletions src/operator/operator_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,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
Expand All @@ -648,6 +654,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 d903af9

Please sign in to comment.