From db43e2e4329f85a5608752ee48fcd4050b2c0e4c Mon Sep 17 00:00:00 2001 From: FlyingQianMM <245467267@qq.com> Date: Tue, 8 Sep 2020 07:19:31 +0000 Subject: [PATCH] clse mkldnn for ppyolo --- deploy/cpp/src/paddlex.cpp | 11 ++++++++--- paddlex/deploy.py | 7 ++++++- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/deploy/cpp/src/paddlex.cpp b/deploy/cpp/src/paddlex.cpp index 1bc96d8..e1c023d 100644 --- a/deploy/cpp/src/paddlex.cpp +++ b/deploy/cpp/src/paddlex.cpp @@ -66,9 +66,14 @@ void Model::create_predictor(const std::string& model_dir, if (key == "") { config.SetModel(model_file, params_file); } - if (use_mkl && name != "HRNet" && name != "DeepLabv3p") { - config.EnableMKLDNN(); - config.SetCpuMathLibraryNumThreads(mkl_thread_num); + if (use_mkl) { + if (name != "HRNet" && name != "DeepLabv3p" && name != "PPYOLO") { + config.EnableMKLDNN(); + config.SetCpuMathLibraryNumThreads(mkl_thread_num); + } else { + std::cerr << "HRNet/DeepLabv3p/PPYOLO are not supported " + << "for the use of mkldnn" << std::endl; + } } if (use_gpu) { config.EnableUseGpu(100, gpu_id); diff --git a/paddlex/deploy.py b/paddlex/deploy.py index f69d8ee..12570be 100644 --- a/paddlex/deploy.py +++ b/paddlex/deploy.py @@ -23,6 +23,7 @@ from paddlex.cv.transforms import build_transforms from paddlex.cv.models import BaseClassifier from paddlex.cv.models import PPYOLO, FasterRCNN, MaskRCNN from paddlex.cv.models import DeepLabv3p +import paddlex.utils.logging as logging class Predictor: @@ -108,9 +109,13 @@ class Predictor: else: config.disable_gpu() if use_mkl: - if self.model_name not in ["HRNet", "DeepLabv3p"]: + if self.model_name not in ["HRNet", "DeepLabv3p", "PPYOLO"]: config.enable_mkldnn() config.set_cpu_math_library_num_threads(mkl_thread_num) + else: + logging.warning( + "HRNet/DeepLabv3p/PPYOLO are not supported for the use of mkldnn\n" + ) if use_glog: config.enable_glog_info() else: -- GitLab