提交 08f0306d 编写于 作者: T tensor-tang 提交者: GitHub

[lite] fix fc bias and enable armv7 fc (#17695)

上级 9654b2d8
...@@ -45,7 +45,8 @@ if (NOT ANDROID_ARCH_ABI IN_LIST ANDROID_ARCH_ABI_LIST) ...@@ -45,7 +45,8 @@ if (NOT ANDROID_ARCH_ABI IN_LIST ANDROID_ARCH_ABI_LIST)
endif() endif()
if(ANDROID_ARCH_ABI STREQUAL "armeabi-v7a") if(ANDROID_ARCH_ABI STREQUAL "armeabi-v7a")
message(STATUS "NEON is enabled on arm-v7a") set(CMAKE_ANDROID_ARM_NEON ON)
message(STATUS "NEON is enabled on arm-v7a with softfp")
endif() endif()
set(ANDROID_STL_TYPE_LITS "gnustl_static" "c++_static") set(ANDROID_STL_TYPE_LITS "gnustl_static" "c++_static")
......
...@@ -20,7 +20,7 @@ namespace lite { ...@@ -20,7 +20,7 @@ namespace lite {
#ifdef LITE_WITH_ARM #ifdef LITE_WITH_ARM
void DeviceInfo::get_info(DeviceInfo* dev) { void DeviceInfo::InitInternal(DeviceInfo* dev) {
set_default_cache(dev); set_default_cache(dev);
dev->compute_core_num_ = arm_get_cpucount(); dev->compute_core_num_ = arm_get_cpucount();
dev->max_memory_ = arm_get_meminfo(); dev->max_memory_ = arm_get_meminfo();
......
...@@ -85,14 +85,14 @@ class DeviceInfo { ...@@ -85,14 +85,14 @@ class DeviceInfo {
return *x; return *x;
} }
static void init_info() { static void Init() {
auto& info = Global(); auto& info = Global();
get_info(&info); InitInternal(&info);
} }
private: private:
DeviceInfo() = default; DeviceInfo() = default;
static void get_info(DeviceInfo* dev); static void InitInternal(DeviceInfo* dev);
}; };
size_t arm_get_meminfo(); size_t arm_get_meminfo();
......
...@@ -64,7 +64,7 @@ class RuntimeContextAssignPass : public StmtPass { ...@@ -64,7 +64,7 @@ class RuntimeContextAssignPass : public StmtPass {
#ifdef LITE_WITH_ARM #ifdef LITE_WITH_ARM
std::unique_ptr<KernelContext> NewARMContext() { std::unique_ptr<KernelContext> NewARMContext() {
DeviceInfo::init_info(); DeviceInfo::Init();
std::unique_ptr<KernelContext> ctx(new KernelContext); std::unique_ptr<KernelContext> ctx(new KernelContext);
ctx->As<ARMContext>(); ctx->As<ARMContext>();
return ctx; return ctx;
......
...@@ -9,7 +9,7 @@ cc_library(relu_compute_arm SRCS relu_compute.cc DEPS ${lite_kernel_deps}) ...@@ -9,7 +9,7 @@ cc_library(relu_compute_arm SRCS relu_compute.cc DEPS ${lite_kernel_deps})
cc_library(mul_compute_arm SRCS mul_compute.cc DEPS ${lite_kernel_deps} eigen3) cc_library(mul_compute_arm SRCS mul_compute.cc DEPS ${lite_kernel_deps} eigen3)
cc_library(scale_compute_arm SRCS scale_compute.cc DEPS ${lite_kernel_deps} eigen3) cc_library(scale_compute_arm SRCS scale_compute.cc DEPS ${lite_kernel_deps} eigen3)
lite_cc_test(test_fc_compute_arm SRCS fc_compute_test.cc DEPS fc_compute_arm eigen3) lite_cc_test(test_fc_compute_arm SRCS fc_compute_test.cc DEPS fc_compute_arm math_arm)
set(arm_kernels set(arm_kernels
fc_compute_arm fc_compute_arm
......
...@@ -61,8 +61,6 @@ TEST(fc_arm, compare_test) { ...@@ -61,8 +61,6 @@ TEST(fc_arm, compare_test) {
b_data[i] = static_cast<float>(i); b_data[i] = static_cast<float>(i);
} }
// TODO(TJ): enable bias soon
b_data = nullptr;
lite::arm::math::fc_compute_eigen(x_data, batch_size, 3, // lite::arm::math::fc_compute_eigen(x_data, batch_size, 3, //
w_data, 3, 4, // w_data, 3, 4, //
b_data, ref_data); b_data, ref_data);
...@@ -74,11 +72,11 @@ TEST(fc_arm, compare_test) { ...@@ -74,11 +72,11 @@ TEST(fc_arm, compare_test) {
param.in_num_col_dims = 1; param.in_num_col_dims = 1;
param.input = &x; param.input = &x;
param.w = &w; param.w = &w;
param.bias = nullptr; param.bias = &b;
param.output = &out; param.output = &out;
param.in_mat_dims = x.dims(); param.in_mat_dims = x.dims();
DeviceInfo::init_info(); DeviceInfo::Init();
std::unique_ptr<KernelContext> ctx(new KernelContext); std::unique_ptr<KernelContext> ctx(new KernelContext);
ctx->As<ARMContext>(); ctx->As<ARMContext>();
fc.SetParam(param); fc.SetParam(param);
...@@ -136,7 +134,7 @@ TEST(fc_arm, num_col_dims) { ...@@ -136,7 +134,7 @@ TEST(fc_arm, num_col_dims) {
std::unique_ptr<KernelContext> ctx(new KernelContext); std::unique_ptr<KernelContext> ctx(new KernelContext);
ctx->As<ARMContext>(); ctx->As<ARMContext>();
DeviceInfo::init_info(); DeviceInfo::Init();
fc.SetParam(param); fc.SetParam(param);
fc.SetContext(std::move(ctx)); fc.SetContext(std::move(ctx));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册