aboutsummaryrefslogtreecommitdiffhomepage
path: root/third_party
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-09-25 22:57:54 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-09-25 23:02:36 -0700
commitc63d21b0bfc534b6377b332e9d2ba2abbdb7e0eb (patch)
tree6fb44dc9eb26de3ff6e25f57e4799ac2da066d95 /third_party
parentf2b17b22e12bd743b66945070f338f70b5fa3332 (diff)
Adds a build flag to enable MKL (mkl_enabled=true).
PiperOrigin-RevId: 214557082
Diffstat (limited to 'third_party')
-rw-r--r--third_party/mkl/BUILD23
-rw-r--r--third_party/mkl/build_defs.bzl41
-rw-r--r--third_party/mkl_dnn/BUILD6
-rw-r--r--third_party/mkl_dnn/build_defs.bzl2
4 files changed, 50 insertions, 22 deletions
diff --git a/third_party/mkl/BUILD b/third_party/mkl/BUILD
index efff7fd51b..15a3e5cfa7 100644
--- a/third_party/mkl/BUILD
+++ b/third_party/mkl/BUILD
@@ -1,26 +1,26 @@
licenses(["notice"]) # 3-Clause BSD
config_setting(
- name = "using_mkl",
+ name = "build_with_mkl",
define_values = {
- "using_mkl": "true",
+ "build_with_mkl": "true",
},
visibility = ["//visibility:public"],
)
config_setting(
- name = "using_mkl_ml_only",
+ name = "build_with_mkl_ml_only",
define_values = {
- "using_mkl": "true",
- "using_mkl_ml_only": "true",
+ "build_with_mkl": "true",
+ "build_with_mkl_ml_only": "true",
},
visibility = ["//visibility:public"],
)
config_setting(
- name = "using_mkl_lnx_x64",
+ name = "build_with_mkl_lnx_x64",
define_values = {
- "using_mkl": "true",
+ "build_with_mkl": "true",
},
values = {
"cpu": "k8",
@@ -28,6 +28,15 @@ config_setting(
visibility = ["//visibility:public"],
)
+config_setting(
+ name = "enable_mkl",
+ define_values = {
+ "enable_mkl": "true",
+ "build_with_mkl": "true",
+ },
+ visibility = ["//visibility:public"],
+)
+
load(
"//third_party/mkl:build_defs.bzl",
"if_mkl",
diff --git a/third_party/mkl/build_defs.bzl b/third_party/mkl/build_defs.bzl
index b645c0fc5c..bb798e715a 100644
--- a/third_party/mkl/build_defs.bzl
+++ b/third_party/mkl/build_defs.bzl
@@ -1,9 +1,11 @@
# -*- Python -*-
"""Skylark macros for MKL.
-if_mkl is a conditional to check if MKL is enabled or not.
-if_mkl_ml is a conditional to check if MKL-ML is enabled.
+
+if_mkl is a conditional to check if we are building with MKL.
+if_mkl_ml is a conditional to check if we are building with MKL-ML.
if_mkl_ml_only is a conditional to check for MKL-ML-only (no MKL-DNN) mode.
if_mkl_lnx_x64 is a conditional to check for MKL
+if_enable_mkl is a conditional to check if building with MKL and MKL is enabled.
mkl_repository is a repository rule for creating MKL repository rule that can
be pointed to either a local folder, or download it from the internet.
@@ -24,7 +26,7 @@ def if_mkl(if_true, if_false = []):
a select evaluating to either if_true or if_false as appropriate.
"""
return select({
- str(Label("//third_party/mkl:using_mkl")): if_true,
+ str(Label("//third_party/mkl:build_with_mkl")): if_true,
"//conditions:default": if_false,
})
@@ -40,8 +42,8 @@ def if_mkl_ml(if_true, if_false = []):
a select evaluating to either if_true or if_false as appropriate.
"""
return select({
- str(Label("//third_party/mkl_dnn:using_mkl_dnn_only")): if_false,
- str(Label("//third_party/mkl:using_mkl")): if_true,
+ str(Label("//third_party/mkl_dnn:build_with_mkl_dnn_only")): if_false,
+ str(Label("//third_party/mkl:build_with_mkl")): if_true,
"//conditions:default": if_false,
})
@@ -56,12 +58,12 @@ def if_mkl_ml_only(if_true, if_false = []):
a select evaluating to either if_true or if_false as appropriate.
"""
return select({
- str(Label("//third_party/mkl:using_mkl_ml_only")): if_true,
+ str(Label("//third_party/mkl:build_with_mkl_ml_only")): if_true,
"//conditions:default": if_false,
})
def if_mkl_lnx_x64(if_true, if_false = []):
- """Shorthand to select() on if MKL is on and the target is Linux x86-64.
+ """Shorthand to select() if building with MKL and the target is Linux x86-64.
Args:
if_true: expression to evaluate if building with MKL is enabled and the
@@ -73,7 +75,24 @@ def if_mkl_lnx_x64(if_true, if_false = []):
a select evaluating to either if_true or if_false as appropriate.
"""
return select({
- str(Label("//third_party/mkl:using_mkl_lnx_x64")): if_true,
+ str(Label("//third_party/mkl:build_with_mkl_lnx_x64")): if_true,
+ "//conditions:default": if_false,
+ })
+
+def if_enable_mkl(if_true, if_false = []):
+ """Shorthand to select() if we are building with MKL and MKL is enabled.
+
+ This is only effective when built with MKL.
+
+ Args:
+ if_true: expression to evaluate if building with MKL and MKL is enabled
+ if_false: expression to evaluate if building without MKL or MKL is not enabled.
+
+ Returns:
+ A select evaluating to either if_true or if_false as appropriate.
+ """
+ return select({
+ "//third_party/mkl:enable_mkl": if_true,
"//conditions:default": if_false,
})
@@ -87,9 +106,9 @@ def mkl_deps():
inclusion in the deps attribute of rules.
"""
return select({
- str(Label("//third_party/mkl_dnn:using_mkl_dnn_only")): ["@mkl_dnn"],
- str(Label("//third_party/mkl:using_mkl_ml_only")): ["//third_party/mkl:intel_binary_blob"],
- str(Label("//third_party/mkl:using_mkl")): [
+ str(Label("//third_party/mkl_dnn:build_with_mkl_dnn_only")): ["@mkl_dnn"],
+ str(Label("//third_party/mkl:build_with_mkl_ml_only")): ["//third_party/mkl:intel_binary_blob"],
+ str(Label("//third_party/mkl:build_with_mkl")): [
"//third_party/mkl:intel_binary_blob",
"@mkl_dnn",
],
diff --git a/third_party/mkl_dnn/BUILD b/third_party/mkl_dnn/BUILD
index 3e567fa9fc..58ecda55e6 100644
--- a/third_party/mkl_dnn/BUILD
+++ b/third_party/mkl_dnn/BUILD
@@ -3,10 +3,10 @@ licenses(["notice"])
exports_files(["LICENSE"])
config_setting(
- name = "using_mkl_dnn_only",
+ name = "build_with_mkl_dnn_only",
define_values = {
- "using_mkl": "true",
- "using_mkl_dnn_only": "true",
+ "build_with_mkl": "true",
+ "build_with_mkl_dnn_only": "true",
},
visibility = ["//visibility:public"],
)
diff --git a/third_party/mkl_dnn/build_defs.bzl b/third_party/mkl_dnn/build_defs.bzl
index 7ce2a7d9b0..6388f31971 100644
--- a/third_party/mkl_dnn/build_defs.bzl
+++ b/third_party/mkl_dnn/build_defs.bzl
@@ -8,6 +8,6 @@ def if_mkl_open_source_only(if_true, if_false = []):
"""
return select({
- str(Label("//third_party/mkl_dnn:using_mkl_dnn_only")): if_true,
+ str(Label("//third_party/mkl_dnn:build_with_mkl_dnn_only")): if_true,
"//conditions:default": if_false,
})