forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mkl-dnn.BUILD
90 lines (86 loc) · 3.31 KB
/
mkl-dnn.BUILD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@//third_party:substitution.bzl", "template_rule")
_DNNL_RUNTIME_OMP = {
"#cmakedefine DNNL_CPU_THREADING_RUNTIME DNNL_RUNTIME_${DNNL_CPU_THREADING_RUNTIME}": "#define DNNL_CPU_THREADING_RUNTIME DNNL_RUNTIME_OMP",
"#cmakedefine DNNL_CPU_RUNTIME DNNL_RUNTIME_${DNNL_CPU_RUNTIME}": "#define DNNL_CPU_RUNTIME DNNL_RUNTIME_OMP",
"#cmakedefine DNNL_GPU_RUNTIME DNNL_RUNTIME_${DNNL_GPU_RUNTIME}": "#define DNNL_GPU_RUNTIME DNNL_RUNTIME_NONE",
"#cmakedefine DNNL_USE_RT_OBJECTS_IN_PRIMITIVE_CACHE": "/* undef DNNL_USE_RT_OBJECTS_IN_PRIMITIVE_CACHE */",
"#cmakedefine DNNL_WITH_SYCL": "/* #undef DNNL_WITH_SYCL */",
"#cmakedefine DNNL_WITH_LEVEL_ZERO": "/* #undef DNNL_WITH_LEVEL_ZERO */",
"#cmakedefine DNNL_SYCL_CUDA": "/* #undef DNNL_SYCL_CUDA */",
}
template_rule(
name = "third_party/oneDNN/include_dnnl_version",
src = "third_party/oneDNN/include/oneapi/dnnl/dnnl_version.h.in",
out = "third_party/oneDNN/include/oneapi/dnnl/dnnl_version.h",
substitutions = {
"@DNNL_VERSION_MAJOR@": "2",
"@DNNL_VERSION_MINOR@": "3",
"@DNNL_VERSION_PATCH@": "3",
"@DNNL_VERSION_HASH@": "f40443c413429c29570acd6cf5e3d1343cf647b4",
},
)
template_rule(
name = "third_party/oneDNN/include_dnnl_config",
src = "third_party/oneDNN/include/oneapi/dnnl/dnnl_config.h.in",
out = "third_party/oneDNN/include/oneapi/dnnl/dnnl_config.h",
substitutions = _DNNL_RUNTIME_OMP,
)
cc_library(
name = "mkl-dnn",
srcs = glob([
"third_party/oneDNN/src/common/*.cpp",
"third_party/oneDNN/src/cpu/**/*.cpp",
], exclude=[
"third_party/oneDNN/src/cpu/aarch64/**/*.cpp",
]),
hdrs = glob([
"third_party/oneDNN/include/oneapi/dnnl/*.h",
"third_party/oneDNN/include/oneapi/dnnl/*.hpp",
"third_party/oneDNN/include/*.h",
"third_party/oneDNN/include/*.hpp",
"third_party/oneDNN/src/cpu/**/*.hpp",
"third_party/oneDNN/src/cpu/**/*.h",
"third_party/oneDNN/src/common/*.hpp",
"third_party/oneDNN/src/common/ittnotify/jitprofiling.h",
], exclude=[
"third_party/oneDNN/src/cpu/aarch64/**/*.hpp",
"third_party/oneDNN/src/cpu/aarch64/**/*.h",
]) + [
"third_party/oneDNN/include/oneapi/dnnl/dnnl_config.h",
"third_party/oneDNN/include/oneapi/dnnl/dnnl_version.h",
],
copts = [
"-DUSE_AVX",
"-DUSE_AVX2",
"-DDNNL_DLL",
"-DDNNL_DLL_EXPORTS",
"-DDNNL_ENABLE_CONCURRENT_EXEC",
"-D__STDC_CONSTANT_MACROS",
"-D__STDC_LIMIT_MACROS",
"-fno-strict-overflow",
"-fopenmp",
] + select({
"@//tools/config:thread_sanitizer": ["-DDNNL_CPU_RUNTIME=0"],
"//conditions:default": ["-DDNNL_CPU_RUNTIME=2"],
}),
includes = [
"third_party/oneDNN/include/",
"third_party/oneDNN/include/oneapi/",
"third_party/oneDNN/include/oneapi/dnnl/",
"third_party/oneDNN/src/",
"third_party/oneDNN/src/common/",
"third_party/oneDNN/src/cpu/",
"third_party/oneDNN/src/cpu/x64/xbyak/",
],
visibility = ["//visibility:public"],
linkopts = [
"-lgomp",
],
deps = [
"@mkl",
] + select({
"@//tools/config:thread_sanitizer": [],
"//conditions:default": ["@tbb"],
}),
)