Skip to content

Commit a8e78e2

Browse files
Rename MKL-related feature macros.
The existing feature macros are named INTEL_MKL to indicate that any flavor of MKL is available, INTEL_MKL_ML to indicate that *only* MKL-ML is available (i.e. MKL-DNN is not), and DO_NOT_USE_ML to indicate that *only* MKL-DNN is available (i.e. MKL-ML is not). This change renames INTEL_MKL_ML to INTEL_MKL_ML_ONLY and DO_NOT_USE_ML to INTEL_MKL_DNN_ONLY. The meanings of the macros have not changed. This change also adds a few sanity checks to mkl_util.h that ensures that the combination of INTEL_MKL, INTEL_MKL_ML_ONLY, and INTEL_MKL_DNN_ONLY is logically consistent: the *_ONLY macros may not both be defined, and if either of them is defined, bare INTEL_MKL must also be defined. PiperOrigin-RevId: 208313735
1 parent f97e945 commit a8e78e2

33 files changed

Lines changed: 125 additions & 125 deletions

tensorflow/compiler/xla/service/cpu/runtime_matmul_mkl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515

16-
#if defined(INTEL_MKL) && !defined(DO_NOT_USE_ML)
16+
#if defined(INTEL_MKL) && !defined(INTEL_MKL_DNN_ONLY)
1717
#include "tensorflow/compiler/xla/service/cpu/runtime_matmul_mkl.h"
1818
#include "third_party/intel_mkl_ml/include/mkl_cblas.h"
1919
#include "third_party/intel_mkl_ml/include/mkl_service.h"

tensorflow/core/common_runtime/mkl_cpu_allocator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ limitations under the License.
2828
#include "tensorflow/core/lib/strings/str_util.h"
2929
#include "tensorflow/core/platform/mem.h"
3030

31-
#ifndef DO_NOT_USE_ML
31+
#ifndef INTEL_MKL_DNN_ONLY
3232
#include "i_malloc.h"
3333
#endif
3434

@@ -98,7 +98,7 @@ class MklCPUAllocator : public VisitableAllocator {
9898
VLOG(1) << "MklCPUAllocator: Setting max_mem_bytes: " << max_mem_bytes;
9999
allocator_ = new BFCAllocator(new MklSubAllocator, max_mem_bytes,
100100
kAllowGrowth, kName);
101-
#ifndef DO_NOT_USE_ML
101+
#ifndef INTEL_MKL_DNN_ONLY
102102
// For redirecting all allocations from MKL to this allocator
103103
// From: http://software.intel.com/en-us/node/528565
104104
i_malloc = MallocHook;

tensorflow/core/graph/mkl_layout_pass.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ limitations under the License.
4343

4444
namespace tensorflow {
4545

46-
#ifdef INTEL_MKL_ML
46+
#ifdef INTEL_MKL_ML_ONLY
4747

4848
// This pass implements rewriting of graph to support following scenarios:
4949
// (A) Merging nodes in the graph
@@ -2211,7 +2211,7 @@ Status MklLayoutRewritePass::Run(const GraphOptimizationPassOptions& options) {
22112211
return Status::OK();
22122212
}
22132213

2214-
#else // INTEL_MKL_ML
2214+
#else // INTEL_MKL_ML_ONLY
22152215

22162216
// This pass implements rewriting of graph to support following scenarios:
22172217
// (A) Merging nodes in the graph
@@ -4474,7 +4474,7 @@ Status MklLayoutRewritePass::Run(const GraphOptimizationPassOptions& options) {
44744474

44754475
return Status::OK();
44764476
}
4477-
#endif // INTEL_MKL_ML
4477+
#endif // INTEL_MKL_ML_ONLY
44784478
} // namespace tensorflow
44794479

44804480
#endif

tensorflow/core/graph/mkl_layout_pass_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ limitations under the License.
3737

3838
namespace tensorflow {
3939

40-
#ifdef INTEL_MKL_ML
40+
#ifdef INTEL_MKL_ML_ONLY
4141

4242
namespace {
4343

@@ -1898,7 +1898,7 @@ BENCHMARK(BM_MklLayoutRewritePass)->Arg(1000)->Arg(10000);
18981898

18991899
} // namespace
19001900

1901-
#else // INTEL_MKL_ML
1901+
#else // INTEL_MKL_ML_ONLY
19021902

19031903
// NOTE: Unit tests in this file rely on a topological sorted graph for
19041904
// printing. But since sibling nodes of a node in the topologically sorted graph
@@ -3582,7 +3582,7 @@ BENCHMARK(BM_MklLayoutRewritePass)->Arg(1000)->Arg(10000);
35823582

35833583
} // namespace
35843584

3585-
#endif // INTEL_MKL_ML
3585+
#endif // INTEL_MKL_ML_ONLY
35863586

35873587
} // namespace tensorflow
35883588

tensorflow/core/kernels/batch_matmul_op_complex.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717

1818
namespace tensorflow {
1919

20-
#if !defined(INTEL_MKL) || defined(DO_NOT_USE_ML)
20+
#if !defined(INTEL_MKL) || defined(INTEL_MKL_DNN_ONLY)
2121
TF_CALL_complex64(REGISTER_BATCH_MATMUL_CPU);
2222
TF_CALL_complex128(REGISTER_BATCH_MATMUL_CPU);
2323
#endif

tensorflow/core/kernels/batch_matmul_op_real.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ limitations under the License.
2121

2222
namespace tensorflow {
2323

24-
#if !defined(INTEL_MKL) || defined(DO_NOT_USE_ML)
24+
#if !defined(INTEL_MKL) || defined(INTEL_MKL_DNN_ONLY)
2525
TF_CALL_float(REGISTER_BATCH_MATMUL_CPU);
2626
TF_CALL_double(REGISTER_BATCH_MATMUL_CPU);
2727
#endif

tensorflow/core/kernels/matmul_op.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,11 +598,11 @@ TF_CALL_float(REGISTER_CPU_EIGEN);
598598
// to use only opensource MKL DNN then use default implementation for these
599599
// types otherwise use GEMM from MKL ML binary
600600

601-
#if defined(DO_NOT_USE_ML)
601+
#if defined(INTEL_MKL_DNN_ONLY)
602602
TF_CALL_complex64(REGISTER_CPU);
603603
TF_CALL_complex128(REGISTER_CPU);
604604
TF_CALL_double(REGISTER_CPU);
605-
#else // DO_NOT_USE_ML
605+
#else // INTEL_MKL_DNN_ONLY
606606
TF_CALL_complex64(REGISTER_CPU_EIGEN);
607607
TF_CALL_complex128(REGISTER_CPU_EIGEN);
608608
TF_CALL_double(REGISTER_CPU_EIGEN);

tensorflow/core/kernels/mkl_aggregate_ops.cc

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ limitations under the License.
2424
#include "tensorflow/core/lib/gtl/inlined_vector.h"
2525
#include "tensorflow/core/platform/logging.h"
2626

27-
28-
#ifndef INTEL_MKL_ML
27+
#ifndef INTEL_MKL_ML_ONLY
2928
#include "mkldnn.hpp"
3029
using mkldnn::stream;
3130
using mkldnn::sum;
@@ -38,7 +37,7 @@ using mkldnn::sum;
3837
namespace tensorflow {
3938
typedef Eigen::ThreadPoolDevice CPUDevice;
4039

41-
#ifdef INTEL_MKL_ML
40+
#ifdef INTEL_MKL_ML_ONLY
4241

4342
template <typename Device, typename T>
4443
class MklAddNOp : public OpKernel {
@@ -286,7 +285,7 @@ class MklAddNOp : public OpKernel {
286285
} MklAddNOpContext;
287286
};
288287

289-
#else // INTEL_MKL_ML
288+
#else // INTEL_MKL_ML_ONLY
290289
template <typename Device, typename T>
291290
class MklAddNOp : public OpKernel {
292291
public:

tensorflow/core/kernels/mkl_avgpooling_op.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
#include "tensorflow/core/kernels/mkl_pooling_ops_common.h"
2626

27-
#ifndef INTEL_MKL_ML
27+
#ifndef INTEL_MKL_ML_ONLY
2828
#include "mkldnn.hpp"
2929
using mkldnn::algorithm;
3030
using mkldnn::engine;
@@ -40,7 +40,7 @@ namespace tensorflow {
4040

4141
typedef Eigen::ThreadPoolDevice CPUDevice;
4242

43-
#ifdef INTEL_MKL_ML
43+
#ifdef INTEL_MKL_ML_ONLY
4444

4545
template <typename Device, typename T>
4646
class MklAvgPoolingOp : public OpKernel {
@@ -664,7 +664,7 @@ class MklAvgPoolingGradOp : public MklPoolingBackwardOpBase<T> {
664664
}
665665
}; // MklAvgPoolingGradOp
666666

667-
#endif // INTEL_MKL_ML
667+
#endif // INTEL_MKL_ML_ONLY
668668

669669
REGISTER_KERNEL_BUILDER(Name("_MklAvgPool")
670670
.Device(DEVICE_CPU)

tensorflow/core/kernels/mkl_batch_matmul_op.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ limitations under the License.
2525

2626
#define EIGEN_USE_THREADS
2727

28-
#if defined(INTEL_MKL) && !defined(DO_NOT_USE_ML)
28+
#if defined(INTEL_MKL) && !defined(INTEL_MKL_DNN_ONLY)
2929
#include <vector>
3030
#include "mkl_cblas.h"
3131
#include "third_party/eigen3/unsupported/Eigen/CXX11/Tensor"

0 commit comments

Comments
 (0)