• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1exports_files(["LICENSE"])
2
3load(
4    "@org_tensorflow//third_party/mkl:build_defs.bzl",
5    "if_mkl",
6)
7load(
8    "@org_tensorflow//tensorflow:tensorflow.bzl",
9    "tf_openmp_copts",
10)
11load(
12    "@org_tensorflow//third_party/mkl_dnn:build_defs.bzl",
13    "if_mkl_open_source_only",
14    "if_mkldnn_threadpool",
15)
16load(
17    "@org_tensorflow//third_party/mkl:build_defs.bzl",
18    "if_mkl_ml",
19)
20load(
21    "@org_tensorflow//third_party:common.bzl",
22    "template_rule",
23)
24
25_DNNL_RUNTIME_OMP = {
26    "#cmakedefine DNNL_CPU_THREADING_RUNTIME DNNL_RUNTIME_${DNNL_CPU_THREADING_RUNTIME}": "#define DNNL_CPU_THREADING_RUNTIME DNNL_RUNTIME_OMP",
27    "#cmakedefine DNNL_CPU_RUNTIME DNNL_RUNTIME_${DNNL_CPU_RUNTIME}": "#define DNNL_CPU_RUNTIME DNNL_RUNTIME_OMP",
28    "#cmakedefine DNNL_GPU_RUNTIME DNNL_RUNTIME_${DNNL_GPU_RUNTIME}": "#define DNNL_GPU_RUNTIME DNNL_RUNTIME_NONE",
29}
30
31_DNNL_RUNTIME_THREADPOOL = {
32    "#cmakedefine DNNL_CPU_THREADING_RUNTIME DNNL_RUNTIME_${DNNL_CPU_THREADING_RUNTIME}": "#define DNNL_CPU_THREADING_RUNTIME DNNL_RUNTIME_THREADPOOL",
33    "#cmakedefine DNNL_CPU_RUNTIME DNNL_RUNTIME_${DNNL_CPU_RUNTIME}": "#define DNNL_CPU_RUNTIME DNNL_RUNTIME_THREADPOOL",
34    "#cmakedefine DNNL_GPU_RUNTIME DNNL_RUNTIME_${DNNL_GPU_RUNTIME}": "#define DNNL_GPU_RUNTIME DNNL_RUNTIME_NONE",
35}
36
37_DNNL_RUNTIME_SEQ = {
38    "#cmakedefine DNNL_CPU_THREADING_RUNTIME DNNL_RUNTIME_${DNNL_CPU_THREADING_RUNTIME}": "#define DNNL_CPU_THREADING_RUNTIME DNNL_RUNTIME_SEQ",
39    "#cmakedefine DNNL_CPU_RUNTIME DNNL_RUNTIME_${DNNL_CPU_RUNTIME}": "#define DNNL_CPU_RUNTIME DNNL_RUNTIME_SEQ",
40    "#cmakedefine DNNL_GPU_RUNTIME DNNL_RUNTIME_${DNNL_GPU_RUNTIME}": "#define DNNL_GPU_RUNTIME DNNL_RUNTIME_NONE",
41}
42
43template_rule(
44    name = "dnnl_config_h",
45    src = "include/dnnl_config.h.in",
46    out = "include/dnnl_config.h",
47    substitutions = select({
48        "@org_tensorflow//third_party/mkl_dnn:build_with_mkldnn_threadpool": _DNNL_RUNTIME_THREADPOOL,
49        "@org_tensorflow//third_party/mkl:build_with_mkl": _DNNL_RUNTIME_OMP,
50        "//conditions:default": _DNNL_RUNTIME_SEQ,
51    }),
52)
53
54# Create the file dnnl_version.h with DNNL version numbers.
55# Currently, the version numbers are hard coded here. If DNNL is upgraded then
56# the version numbers have to be updated manually. The version numbers can be
57# obtained from the PROJECT_VERSION settings in CMakeLists.txt. The variable is
58# set to "version_major.version_minor.version_patch". The git hash version can
59# be set to NA.
60# TODO(agramesh1): Automatically get the version numbers from CMakeLists.txt.
61template_rule(
62    name = "dnnl_version_h",
63    src = "include/dnnl_version.h.in",
64    out = "include/dnnl_version.h",
65    substitutions = {
66        "@DNNL_VERSION_MAJOR@": "1",
67        "@DNNL_VERSION_MINOR@": "6",
68        "@DNNL_VERSION_PATCH@": "4",
69        "@DNNL_VERSION_HASH@": "N/A",
70    },
71)
72
73cc_library(
74    name = "mkl_dnn",
75    srcs = glob([
76        "src/common/*.cpp",
77        "src/common/*.hpp",
78        "src/cpu/*.cpp",
79        "src/cpu/*.hpp",
80        "src/cpu/**/*.cpp",
81        "src/cpu/**/*.hpp",
82        "src/cpu/xbyak/*.h",
83        "src/cpu/x64/jit_utils/jitprofiling/*.c",
84        "src/cpu/x64/jit_utils/jitprofiling/*.h",
85    ]) + [
86        ":dnnl_config_h",
87        ":dnnl_version_h",
88    ],
89    hdrs = glob(["include/*"]),
90    copts = select({
91        "@org_tensorflow//tensorflow:windows": [],
92        "//conditions:default": ["-fexceptions"],
93    }) + [
94        "-UUSE_MKL",
95        "-UUSE_CBLAS",
96        "-DDNNL_ENABLE_MAX_CPU_ISA",
97    ] + tf_openmp_copts(),
98    includes = [
99        "include",
100        "src",
101        "src/common",
102        "src/cpu",
103        "src/cpu/gemm",
104        "src/cpu/xbyak",
105    ],
106    visibility = ["//visibility:public"],
107    deps = if_mkl_ml(
108        ["@org_tensorflow//third_party/mkl:intel_binary_blob"],
109        [],
110    ),
111)
112
113cc_library(
114    name = "dnnl_single_threaded",
115    srcs = glob([
116        "src/common/*.cpp",
117        "src/cpu/*.cpp",
118        "src/cpu/gemm/**/*.cpp",
119        "src/cpu/matmul/**/*.cpp",
120        "src/cpu/rnn/**/*.cpp",
121        "src/cpu/x64/**/*.cpp",
122        "src/cpu/x64/jit_utils/jitprofiling/*.c",
123    ]) + [
124        ":dnnl_config_h",
125        ":dnnl_version_h",
126    ],
127    copts = [
128        "-fexceptions",
129        "-DDNNL_ENABLE_MAX_CPU_ISA",
130    ],
131    includes = [
132        "include",
133        "src",
134        "src/common",
135        "src/cpu",
136        "src/cpu/gemm",
137        "src/cpu/gemm/f32",
138        "src/cpu/gemm/s8x8s32",
139        "src/cpu/matmul",
140        "src/cpu/rnn",
141        "src/cpu/x64",
142        "src/cpu/x64/jit_utils",
143        "src/cpu/x64/jit_utils/jitprofiling",
144        "src/cpu/x64/xbyak",
145    ],
146    textual_hdrs = glob([
147        "include/*",
148        "src/common/*.hpp",
149        "src/cpu/*.hpp",
150        "src/cpu/**/*.hpp",
151        "src/cpu/x64/jit_utils/jitprofiling/*.h",
152        "src/cpu/x64/xbyak/*.h",
153    ]),
154    visibility = ["//visibility:public"],
155)
156
157cc_library(
158    name = "mkl_dnn_aarch64",
159    srcs = glob([
160        "src/common/*.cpp",
161        "src/common/*.hpp",
162        "src/cpu/*.cpp",
163        "src/cpu/*.hpp",
164        "src/cpu/rnn/*.cpp",
165        "src/cpu/rnn/*.hpp",
166        "src/cpu/matmul/*.cpp",
167        "src/cpu/matmul/*.hpp",
168        "src/cpu/gemm/**/*",
169    ]) + [
170        ":dnnl_config_h",
171        ":dnnl_version_h",
172    ],
173    hdrs = glob(["include/*"]),
174    copts = [
175        "-fexceptions",
176        "-UUSE_MKL",
177        "-UUSE_CBLAS",
178    ],
179    includes = [
180        "include",
181        "src",
182        "src/common",
183        "src/cpu",
184        "src/cpu/gemm",
185    ],
186    linkopts = ["-lgomp"],
187    visibility = ["//visibility:public"],
188)
189