From 619de9853ebc3a197f26a9649443efdbe64c83d7 Mon Sep 17 00:00:00 2001 From: Hu Shiwen Date: Fri, 19 Apr 2019 15:59:11 +0800 Subject: [PATCH] change mxnet_option behavior fix omp with msvc with mkldnn --- CMakeLists.txt | 2 +- cmake/Utils.cmake | 2 +- .../quantization/mkldnn/mkldnn_quantized_fully_connected.cc | 2 +- src/operator/subgraph/mkldnn/mkldnn_fc.cc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9cd68e14093c..7f320f3f654a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ mxnet_option(USE_SSE "Build with x86 SSE instruction support" ON IF mxnet_option(USE_F16C "Build with x86 F16C instruction support" ON) # autodetects support if ON mxnet_option(USE_LAPACK "Build with lapack support" ON) mxnet_option(USE_MKL_IF_AVAILABLE "Use MKL if found" ON) -mxnet_option(USE_MKLML_MKL "Use MKLDNN variant of MKL (if MKL found)" ON IF USE_MKL_IF_AVAILABLE AND (NOT APPLE)) +mxnet_option(USE_MKLML_MKL "Use MKLDNN variant of MKL (if MKL found)" ON IF USE_MKL_IF_AVAILABLE AND (NOT APPLE) AND (NOT MSVC) ) mxnet_option(USE_MKLDNN "Use MKLDNN variant of MKL (if MKL found)" ON IF USE_MKL_IF_AVAILABLE AND (NOT APPLE) AND (NOT MSVC) AND (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64") AND (NOT CMAKE_CROSSCOMPILING)) mxnet_option(USE_OPERATOR_TUNING "Enable auto-tuning of operators" ON IF NOT MSVC) mxnet_option(USE_GPERFTOOLS "Build with GPerfTools support" OFF) diff --git a/cmake/Utils.cmake b/cmake/Utils.cmake index ac6ce3926c37..6b427db85ec9 100644 --- a/cmake/Utils.cmake +++ b/cmake/Utils.cmake @@ -216,7 +216,7 @@ function(mxnet_option variable description value) option(${variable} "${description}" ${__value}) endif() else() - unset(${variable} CACHE) + option(${variable} "${description}" OFF) endif() endfunction() diff --git a/src/operator/quantization/mkldnn/mkldnn_quantized_fully_connected.cc b/src/operator/quantization/mkldnn/mkldnn_quantized_fully_connected.cc index 71daf2ec2c16..752e7b9c65e0 100644 --- a/src/operator/quantization/mkldnn/mkldnn_quantized_fully_connected.cc +++ b/src/operator/quantization/mkldnn/mkldnn_quantized_fully_connected.cc @@ -74,7 +74,7 @@ void MKLDNNQuantizedFullyConnectedForward(const nnvm::NodeAttrs &attrs, int32_t *quantized_bias_ptr = quantized_bias.data().dptr(); size_t bias_size = bias.shape().Size(); #pragma omp parallel for num_threads(engine::OpenMP::Get()->GetRecommendedOMPThreadCount()) - for (size_t i = 0; i < bias_size; ++i) { + for (int i = 0; i < bias_size; ++i) { quantized_bias_ptr[i] = bias_ptr[i] * bias_int32_rescale; } } diff --git a/src/operator/subgraph/mkldnn/mkldnn_fc.cc b/src/operator/subgraph/mkldnn/mkldnn_fc.cc index 0ec05a2af087..6f0621d456cf 100644 --- a/src/operator/subgraph/mkldnn/mkldnn_fc.cc +++ b/src/operator/subgraph/mkldnn/mkldnn_fc.cc @@ -156,7 +156,7 @@ void SgMKLDNNFCOp::Forward(const OpContext &ctx, int32_t *quantized_bias_ptr = cached_bias_.data().dptr(); size_t bias_size = bias.shape().Size(); #pragma omp parallel for num_threads(engine::OpenMP::Get()->GetRecommendedOMPThreadCount()) - for (size_t i = 0; i < bias_size; ++i) { + for (int i = 0; i < bias_size; ++i) { quantized_bias_ptr[i] = bias_ptr[i] * bias_int32_rescale; } }