From 7e2ecbd65008571abd952308f7d2c46c13c47c1f Mon Sep 17 00:00:00 2001 From: nhzlx Date: Fri, 21 Jun 2019 02:51:45 +0000 Subject: [PATCH] add some int8 option --- paddle/fluid/lite/api/cxx_api.h | 1 + paddle/fluid/lite/core/mir/fusion/quant_dequant_op_fuser.h | 2 +- paddle/fluid/lite/core/mir/pattern_matcher_high_api.cc | 2 +- paddle/fluid/lite/core/op_registry.cc | 1 + paddle/fluid/lite/core/op_registry.h | 2 ++ paddle/fluid/lite/core/optimizer.h | 1 - 6 files changed, 6 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/lite/api/cxx_api.h b/paddle/fluid/lite/api/cxx_api.h index ba2d784b942..915a469a587 100644 --- a/paddle/fluid/lite/api/cxx_api.h +++ b/paddle/fluid/lite/api/cxx_api.h @@ -50,6 +50,7 @@ class ExecutorLite { optimizer_.KernelPickPreferPlace(prefer_place); core::KernelPickFactor factor; factor.ConsiderTarget(); + factor.ConsiderPrecision(); optimizer_.Run(std::move(program), valid_places, factor); program_ = optimizer_.GenRuntimeProgram(); } diff --git a/paddle/fluid/lite/core/mir/fusion/quant_dequant_op_fuser.h b/paddle/fluid/lite/core/mir/fusion/quant_dequant_op_fuser.h index b4778aab182..29ff767e772 100644 --- a/paddle/fluid/lite/core/mir/fusion/quant_dequant_op_fuser.h +++ b/paddle/fluid/lite/core/mir/fusion/quant_dequant_op_fuser.h @@ -25,7 +25,7 @@ namespace fusion { /* The model trained by fluid quantization is a simulation of real int8. * The quantized Ops(conv2d, mul, depthwise conv2d etc) have fake_quantop - * in front and fake_dequantop behind. + * in front and fake_dequantop behind. * * When in int8 mode, the pattern like "fake_quant + quantized_op + * fake_dequant" diff --git a/paddle/fluid/lite/core/mir/pattern_matcher_high_api.cc b/paddle/fluid/lite/core/mir/pattern_matcher_high_api.cc index 9f0b2e1f322..322ddb29064 100644 --- a/paddle/fluid/lite/core/mir/pattern_matcher_high_api.cc +++ b/paddle/fluid/lite/core/mir/pattern_matcher_high_api.cc @@ -41,7 +41,7 @@ void FuseBase::DeleteInterNodes(SSAGraph *graph) { } } - LOG(INFO) << "keys: " << key2nodes_.size(); + VLOG(4) << "keys: " << key2nodes_.size(); std::unordered_set nodes2rm; for (auto &matched : key2nodes_) { for (const auto &key : keys) { diff --git a/paddle/fluid/lite/core/op_registry.cc b/paddle/fluid/lite/core/op_registry.cc index 8c3e44733df..131bdc641d0 100644 --- a/paddle/fluid/lite/core/op_registry.cc +++ b/paddle/fluid/lite/core/op_registry.cc @@ -96,6 +96,7 @@ KernelRegistry::KernelRegistry() INIT_FOR(kX86, kAny, kAny); INIT_FOR(kARM, kFloat, kNCHW); + INIT_FOR(kARM, kInt8, kNCHW); INIT_FOR(kARM, kAny, kNCHW); INIT_FOR(kARM, kAny, kAny); #undef INIT_FOR diff --git a/paddle/fluid/lite/core/op_registry.h b/paddle/fluid/lite/core/op_registry.h index 1052419ecda..fc4cd25fa56 100644 --- a/paddle/fluid/lite/core/op_registry.h +++ b/paddle/fluid/lite/core/op_registry.h @@ -80,6 +80,8 @@ class KernelRegistry final { KernelRegistryForTarget *, // KernelRegistryForTarget *, // + KernelRegistryForTarget * // >; diff --git a/paddle/fluid/lite/core/optimizer.h b/paddle/fluid/lite/core/optimizer.h index ea65329b668..c42699ff10a 100644 --- a/paddle/fluid/lite/core/optimizer.h +++ b/paddle/fluid/lite/core/optimizer.h @@ -58,7 +58,6 @@ class Optimizer { #ifdef LITE_WITH_LIGHT_WEIGHT_FRAMEWORK "lite_elementwise_add_activation_fuse_pass", // #endif - "lite_fc_fuse_pass", // "static_kernel_pick_pass", // "variable_place_inference_pass", // "argument_type_display_pass", // -- GitLab