github.com/johnnyeven/libtools@v0.0.0-20191126065708-61829c1adf46/third_party/mkl_dnn/mkldnn.BUILD (about)

     1  exports_files(["LICENSE"])
     2  
     3  load(
     4      "@org_tensorflow//third_party/mkl_dnn:build_defs.bzl",
     5      "if_mkl_open_source_only",
     6      "if_mkl_v1_open_source_only",
     7  )
     8  load(
     9      "@org_tensorflow//third_party:common.bzl",
    10      "template_rule",
    11  )
    12  
    13  config_setting(
    14      name = "clang_linux_x86_64",
    15      values = {
    16          "cpu": "k8",
    17          "define": "using_clang=true",
    18      },
    19  )
    20  
    21  template_rule(
    22      name = "mkldnn_config_h",
    23      src = "include/mkldnn_config.h.in",
    24      out = "include/mkldnn_config.h",
    25      substitutions = {
    26          "#cmakedefine MKLDNN_CPU_BACKEND MKLDNN_BACKEND_${MKLDNN_CPU_BACKEND}": "#define MKLDNN_CPU_BACKEND MKLDNN_BACKEND_NATIVE",
    27          "#cmakedefine MKLDNN_GPU_BACKEND MKLDNN_BACKEND_${MKLDNN_GPU_BACKEND}": "#define MKLDNN_GPU_BACKEND MKLDNN_BACKEND_NONE",
    28      },
    29  )
    30  
    31  # Create the file mkldnn_version.h with MKL-DNN version numbers.
    32  # Currently, the version numbers are hard coded here. If MKL-DNN is upgraded then
    33  # the version numbers have to be updated manually. The version numbers can be
    34  # obtained from the PROJECT_VERSION settings in CMakeLists.txt. The variable is
    35  # set to "version_major.version_minor.version_patch". The git hash version can
    36  # be set to NA.
    37  # TODO(agramesh1) Automatically get the version numbers from CMakeLists.txt.
    38  # TODO(bhavanis): MKL-DNN minor version needs to be updated for MKL-DNN v1.x.
    39  # The current version numbers will work only if MKL-DNN v0.20 is used.
    40  
    41  template_rule(
    42      name = "mkldnn_version_h",
    43      src = "include/mkldnn_version.h.in",
    44      out = "include/mkldnn_version.h",
    45      substitutions = {
    46          "@MKLDNN_VERSION_MAJOR@": "0",
    47          "@MKLDNN_VERSION_MINOR@": "20",
    48          "@MKLDNN_VERSION_PATCH@": "3",
    49          "@MKLDNN_VERSION_HASH@": "N/A",
    50      },
    51  )
    52  
    53  cc_library(
    54      name = "mkl_dnn",
    55      srcs = glob([
    56          "src/common/*.cpp",
    57          "src/common/*.hpp",
    58          "src/cpu/*.cpp",
    59          "src/cpu/*.hpp",
    60          "src/cpu/**/*.cpp",
    61          "src/cpu/**/*.hpp",
    62          "src/cpu/xbyak/*.h",
    63      ]) + if_mkl_v1_open_source_only([
    64          ":mkldnn_config_h",
    65      ]) + [":mkldnn_version_h"],
    66      hdrs = glob(["include/*"]),
    67      copts = [
    68          "-fexceptions",
    69          "-DUSE_MKL",
    70          "-DUSE_CBLAS",
    71      ] + if_mkl_open_source_only([
    72          "-UUSE_MKL",
    73          "-UUSE_CBLAS",
    74      ]) + if_mkl_v1_open_source_only([
    75          "-UUSE_MKL",
    76          "-UUSE_CBLAS",
    77      ]) + select({
    78          "@org_tensorflow//tensorflow:linux_x86_64": [
    79              "-fopenmp",  # only works with gcc
    80          ],
    81          # TODO(ibiryukov): enable openmp with clang by including libomp as a
    82          # dependency.
    83          ":clang_linux_x86_64": [],
    84          "//conditions:default": [],
    85      }),
    86      includes = [
    87          "include",
    88          "src",
    89          "src/common",
    90          "src/cpu",
    91          "src/cpu/gemm",
    92          "src/cpu/xbyak",
    93      ],
    94      visibility = ["//visibility:public"],
    95      deps = select({
    96          "@org_tensorflow//tensorflow:linux_x86_64": [
    97              "@mkl_linux//:mkl_headers",
    98              "@mkl_linux//:mkl_libs_linux",
    99          ],
   100          "@org_tensorflow//tensorflow:macos": [
   101              "@mkl_darwin//:mkl_headers",
   102              "@mkl_darwin//:mkl_libs_darwin",
   103          ],
   104          "@org_tensorflow//tensorflow:windows": [
   105              "@mkl_windows//:mkl_headers",
   106              "@mkl_windows//:mkl_libs_windows",
   107          ],
   108          "//conditions:default": [],
   109      }),
   110  )
   111  
   112  cc_library(
   113      name = "mkldnn_single_threaded",
   114      srcs = glob([
   115          "src/common/*.cpp",
   116          "src/common/*.hpp",
   117          "src/cpu/*.cpp",
   118          "src/cpu/*.hpp",
   119          "src/cpu/**/*.cpp",
   120          "src/cpu/**/*.hpp",
   121          "src/cpu/xbyak/*.h",
   122      ]) + [":mkldnn_version_h"],
   123      hdrs = glob(["include/*"]),
   124      copts = [
   125          "-fexceptions",
   126          "-DMKLDNN_THR=MKLDNN_THR_SEQ",  # Disables threading.
   127      ],
   128      includes = [
   129          "include",
   130          "src",
   131          "src/common",
   132          "src/cpu",
   133          "src/cpu/gemm",
   134          "src/cpu/xbyak",
   135      ],
   136      visibility = ["//visibility:public"],
   137  )