From 5c9894d38929541963dca5c416312ea8ab4504f7 Mon Sep 17 00:00:00 2001 From: nhzlx Date: Fri, 28 Jun 2019 04:16:54 +0000 Subject: [PATCH] Refine INT8 conv compute --- paddle/fluid/lite/api/cxx_api_bin_int8.cc | 12 ++++++++++-- paddle/fluid/lite/kernels/arm/conv_compute.cc | 5 ++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/lite/api/cxx_api_bin_int8.cc b/paddle/fluid/lite/api/cxx_api_bin_int8.cc index 0b14b8fbc6..4e30cb88b1 100644 --- a/paddle/fluid/lite/api/cxx_api_bin_int8.cc +++ b/paddle/fluid/lite/api/cxx_api_bin_int8.cc @@ -34,6 +34,7 @@ double time_diff(Time t1, Time t2) { void Run(const char* model_dir, int repeat) { #ifdef LITE_WITH_ARM DeviceInfo::Init(); + DeviceInfo::Global().SetRunMode(LITE_POWER_HIGH, 1); #endif lite::Predictor predictor; std::vector valid_places({ @@ -52,6 +53,7 @@ void Run(const char* model_dir, int repeat) { data[i] = 1; } + for (int i = 0; i < 10; i++) predictor.Run(); auto time1 = time(); for (int i = 0; i < repeat; i++) predictor.Run(); auto time2 = time(); @@ -60,10 +62,16 @@ void Run(const char* model_dir, int repeat) { auto* out = predictor.GetOutput(0); LOG(INFO) << out << " memory size " << out->data_size(); - LOG(INFO) << "out " << out->data()[0]; - LOG(INFO) << "out " << out->data()[1]; LOG(INFO) << "dims " << out->dims(); LOG(INFO) << "out data size: " << out->data_size(); + /* + float sum = 0.; + for (int i = 0; i < out->data_size(); i++) { + LOG(INFO) << "out " << out->data()[i]; + sum += out->data()[i]; + } + LOG(INFO) << sum; + */ } } // namespace lite diff --git a/paddle/fluid/lite/kernels/arm/conv_compute.cc b/paddle/fluid/lite/kernels/arm/conv_compute.cc index 0854ba65c7..29a88ba1a1 100644 --- a/paddle/fluid/lite/kernels/arm/conv_compute.cc +++ b/paddle/fluid/lite/kernels/arm/conv_compute.cc @@ -74,7 +74,7 @@ void ConvCompute::PrepareForRun() { } else if (param.groups == 1 && kw == 3 && stride == 2 && kps_equal && no_dilation) { // direct conv impl - impl_ = new lite::arm::math::DirectConv; + impl_ = new lite::arm::math::GemmLikeConv; VLOG(3) << "invoking direct conv"; } else { impl_ = new lite::arm::math::GemmLikeConv; @@ -123,8 +123,7 @@ void ConvComputeInt8::PrepareForRun() { // weigth is int8 and bias is int32 so do not need trans if (param.groups == ic && ic == oc && kps_equal && no_dilation && flag_dw) { - // impl_ = new lite::arm::math::DepthwiseConvInt8; - impl_ = new lite::arm::math::GemmLikeConvInt8; + impl_ = new lite::arm::math::DepthwiseConvInt8; VLOG(3) << "Run DepthwiseConv Int8"; } else if (param.groups == 1 && kw == 3 && (sw == 1 || sw == 2) && kps_equal && no_dilation) { -- GitLab