Skip to content

Commit 8ea3012

Browse files
penpornkGoogle-ML-Automation
authored andcommitted
[onednn] Fix tsan issue in oneDNN when initializing setting_t
As reported in #20686 PiperOrigin-RevId: 733730354
1 parent 14d26f3 commit 8ea3012

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
diff --git a/src/common/utils.hpp b/src/common/utils.hpp
2+
index 6ef5bf3163..ddd285f3fe 100644
3+
--- a/src/common/utils.hpp
4+
+++ b/src/common/utils.hpp
5+
@@ -673,11 +673,11 @@ template <typename T>
6+
struct setting_t {
7+
private:
8+
T value_;
9+
- bool initialized_;
10+
+ std::atomic<bool> initialized_ = false;
11+
12+
public:
13+
- constexpr setting_t() : value_ {}, initialized_ {false} {}
14+
- constexpr setting_t(const T init) : value_ {init}, initialized_ {false} {}
15+
+ constexpr setting_t() : value_ {} {}
16+
+ constexpr setting_t(const T init) : value_ {init} {}
17+
bool initialized() { return initialized_; }
18+
T get() { return value_; }
19+
void set(T new_value) {

tsl_workspace2.bzl

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ def _tf_repositories():
153153
tf_http_archive(
154154
name = "onednn",
155155
build_file = "//third_party/mkl_dnn:mkldnn_v1.BUILD",
156+
patch_file = ["//third_party/mkl_dnn:setting_init.patch"],
156157
sha256 = "8356aa9befde4d4ff93f1b016ac4310730b2de0cc0b8c6c7ce306690bc0d7b43",
157158
strip_prefix = "oneDNN-3.5",
158159
urls = tf_mirror_urls("https://github.com/oneapi-src/oneDNN/archive/refs/tags/v3.5.tar.gz"),

0 commit comments

Comments
 (0)