From c2be5da380fbb440d7e80bb57d1ffb3f769d2bd6 Mon Sep 17 00:00:00 2001 From: yuanshuai Date: Mon, 24 Jun 2019 11:05:39 +0000 Subject: [PATCH] [LITE][CI] Enable android armv7 CI, Fix mul, fc bug --- paddle/fluid/lite/kernels/arm/fc_compute.cc | 8 +++++- paddle/fluid/lite/kernels/arm/mul_compute.cc | 28 +++++++++++--------- paddle/fluid/lite/kernels/arm/mul_compute.h | 3 +++ paddle/fluid/lite/tools/build.sh | 9 +------ 4 files changed, 27 insertions(+), 21 deletions(-) diff --git a/paddle/fluid/lite/kernels/arm/fc_compute.cc b/paddle/fluid/lite/kernels/arm/fc_compute.cc index 2e6f46a0e07..24619ed9261 100644 --- a/paddle/fluid/lite/kernels/arm/fc_compute.cc +++ b/paddle/fluid/lite/kernels/arm/fc_compute.cc @@ -13,10 +13,10 @@ // limitations under the License. #include "paddle/fluid/lite/kernels/arm/fc_compute.h" +#include #include "paddle/fluid/lite/arm/math/funcs.h" #include "paddle/fluid/lite/core/op_registry.h" #include "paddle/fluid/lite/core/type_system.h" - namespace paddle { namespace lite { namespace kernels { @@ -53,6 +53,12 @@ void FcCompute::PrepareForRun() { } } } + + if (m_ > 1) { + int hblock = lite::arm::math::get_hblock(ctx.arch()); + int m_round = hblock * ((m_ + hblock - 1) / hblock); + ctx.ExtendWorkspace(DDimLite(std::vector({m_round * k_}))); + } } void FcCompute::Run() { diff --git a/paddle/fluid/lite/kernels/arm/mul_compute.cc b/paddle/fluid/lite/kernels/arm/mul_compute.cc index 57c28e63bbf..c721e8046e7 100644 --- a/paddle/fluid/lite/kernels/arm/mul_compute.cc +++ b/paddle/fluid/lite/kernels/arm/mul_compute.cc @@ -13,6 +13,7 @@ // limitations under the License. #include "paddle/fluid/lite/kernels/arm/mul_compute.h" +#include #include "paddle/fluid/lite/arm/math/funcs.h" #include "paddle/fluid/lite/core/op_registry.h" #include "paddle/fluid/lite/core/type_system.h" @@ -33,7 +34,7 @@ void MulCompute::Run() { const auto* y_data = param.y->data(); auto* o_data = param.output->mutable_data(); - int m = static_cast( + m_ = static_cast( param.x->dims().Slice(0, param.x_num_col_dims).production()); int x_w = static_cast(param.x->dims() @@ -41,26 +42,29 @@ void MulCompute::Run() { .production()); int y_h = static_cast( param.y->dims().Slice(0, param.y_num_col_dims).production()); - int n = - static_cast(param.y->dims() - .Slice(param.y_num_col_dims, param.y->dims().size()) - .production()); + n_ = static_cast(param.y->dims() + .Slice(param.y_num_col_dims, param.y->dims().size()) + .production()); CHECK_EQ(x_w, y_h) << "x_w must be equal with y_h"; - auto k = x_w; - if (n == 1) { - lite::arm::math::sgemv(x_data, y_data, o_data, false, m, k, false, nullptr, - false); + k_ = x_w; + + if (n_ == 1) { + lite::arm::math::sgemv(x_data, y_data, o_data, false, m_, k_, false, + nullptr, false); } else { constexpr bool is_tranposed_y = false; auto& ctx = this->ctx_->template As(); + int hblock = lite::arm::math::get_hblock(ctx.arch()); + int m_round = hblock * ((m_ + hblock - 1) / hblock); + ctx.ExtendWorkspace(DDimLite(std::vector({m_round * k_}))); float* packed_x = static_cast(ctx.workspace_data()) + ctx.l2_cache_size() / sizeof(float); - lite::arm::math::prepackA(packed_x, x_data, k, 0, m, 0, k, false, &ctx); - lite::arm::math::sgemm_prepack(packed_x, y_data, nullptr, o_data, m, n, k, - false, false, is_tranposed_y, &ctx); + lite::arm::math::prepackA(packed_x, x_data, k_, 0, m_, 0, k_, false, &ctx); + lite::arm::math::sgemm_prepack(packed_x, y_data, nullptr, o_data, m_, n_, + k_, false, false, is_tranposed_y, &ctx); } } diff --git a/paddle/fluid/lite/kernels/arm/mul_compute.h b/paddle/fluid/lite/kernels/arm/mul_compute.h index c18995e5a5c..64c8f813d4e 100644 --- a/paddle/fluid/lite/kernels/arm/mul_compute.h +++ b/paddle/fluid/lite/kernels/arm/mul_compute.h @@ -31,6 +31,9 @@ class MulCompute : public KernelLite { void Run() override; virtual ~MulCompute() = default; + + private: + int m_, n_, k_; }; } // namespace arm diff --git a/paddle/fluid/lite/tools/build.sh b/paddle/fluid/lite/tools/build.sh index a88e7786c01..49dff53bfa5 100755 --- a/paddle/fluid/lite/tools/build.sh +++ b/paddle/fluid/lite/tools/build.sh @@ -246,14 +246,7 @@ function test_arm { echo "android do not need armv7hf" return 0 fi - - # TODO(yuanshuai): enable armv7 on android - if [[ ${abi} == "armv7" ]]; then - echo "skip android v7 test yet" - return 0 - fi - - + echo "test file: ${TESTS_FILE}" for _test in $(cat $TESTS_FILE); do test_arm_android $_test $port -- GitLab