From d60aa589d59148dc15aea94ea75e4a13a8918f43 Mon Sep 17 00:00:00 2001 From: hong19860320 <9973393+hong19860320@users.noreply.github.com> Date: Mon, 13 Jan 2020 21:34:16 +0800 Subject: [PATCH] [LITE][NPU] Refine batch_norm and pool2d op bridges (#2762) --- lite/kernels/npu/bridges/batch_norm_op.cc | 6 +++++- lite/kernels/npu/bridges/pool_op.cc | 6 ++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lite/kernels/npu/bridges/batch_norm_op.cc b/lite/kernels/npu/bridges/batch_norm_op.cc index d151fd8d7b..d0e97161c5 100644 --- a/lite/kernels/npu/bridges/batch_norm_op.cc +++ b/lite/kernels/npu/bridges/batch_norm_op.cc @@ -64,7 +64,11 @@ int BatchNormConverter(void* ctx, OpLite* op, KernelBase* kernel) { float momentum = op_info->GetAttr("momentum"); float epsilon = op_info->GetAttr("epsilon"); int mode = 1; // bnScale, bnBias tensor dims are 1xCx1x1 - bool use_global_stats = op_info->GetAttr("use_global_stats"); + bool use_global_stats = !op_info->HasAttr("use_global_stats") || + op_info->GetAttr("use_global_stats"); + if (!use_global_stats) { + LOG(WARNING) << "[NPU] Only use_global_stats=true is supported by HiAI DDK"; + } // X node std::shared_ptr x_node = nullptr; diff --git a/lite/kernels/npu/bridges/pool_op.cc b/lite/kernels/npu/bridges/pool_op.cc index 42349d1839..ee90d81e50 100644 --- a/lite/kernels/npu/bridges/pool_op.cc +++ b/lite/kernels/npu/bridges/pool_op.cc @@ -61,8 +61,10 @@ int PoolConverter(void* ctx, OpLite* op, KernelBase* kernel) { mode = 0; } else if (pooling_type == "avg") { mode = 1; - CHECK(op_info->GetAttr("exclusive")) - << "[NPU] exclusive must be true in HiAI DDK"; + if (!op_info->GetAttr("exclusive")) { + LOG(WARNING) << "[NPU] Only exclusive=true is supported for the pooling " + "type 'avg' by HiAI DDK"; + } } else { LOG(WARNING) << "[NPU] Unsupported pooling type: " << pooling_type; return FAILED; -- GitLab