Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update cfan.cpp #145

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions FaceAlignment/examples/android/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := FaceAlignment

DIRS = FaceAlignment/src \
FaceAlignment/src/classifier \
FaceAlignment/src/feat \
FaceAlignment/src/io \
FaceAlignment/src/util \
FaceAlignment/include

INC = $(foreach dir,$(DIRS),$(LOCAL_PATH)/$(dir))
SRC = $(foreach dir,$(DIRS),$(wildcard $(LOCAL_PATH)/$(dir)/*.c))
SRC += $(foreach dir,$(DIRS),$(wildcard $(LOCAL_PATH)/$(dir)/*.cpp))

LOCAL_SRC_FILES := $(SRC:$(LOCAL_PATH)/%=%)

LOCAL_C_INCLUDES := $(INC)

LOCAL_CFLAGS := -Wall

include $(BUILD_STATIC_LIBRARY)
5 changes: 5 additions & 0 deletions FaceAlignment/examples/android/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
APP_MODULES := FaceAlignment
APP_PLATFORM := android-9
APP_ABI := armeabi
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions -std=c++11 -O2
1 change: 1 addition & 0 deletions FaceAlignment/examples/android/jni/FaceAlignment
2 changes: 1 addition & 1 deletion FaceAlignment/src/cfan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ CCFAN::~CCFAN(void)
void CCFAN::InitModel(const char *model_path)
{
/*Open the model file*/
FILE *fp = fopen(model_path, "rb+");
FILE *fp = fopen(model_path, "rb");
mean_shape_ = new float[pts_num_ * 2];
fread(mean_shape_, sizeof(float), pts_num_ * 2, fp);

Expand Down
27 changes: 27 additions & 0 deletions FaceDetection/examples/android/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := FaceDetection

DIRS = FaceDetection/src \
FaceDetection/src/classifier \
FaceDetection/src/feat \
FaceDetection/src/io \
FaceDetection/src/util \
FaceDetection/include

INC = $(foreach dir,$(DIRS),$(LOCAL_PATH)/$(dir))
SRC = $(foreach dir,$(DIRS),$(wildcard $(LOCAL_PATH)/$(dir)/*.c))
SRC += $(foreach dir,$(DIRS),$(wildcard $(LOCAL_PATH)/$(dir)/*.cpp))

LOCAL_SRC_FILES := $(SRC:$(LOCAL_PATH)/%=%)

LOCAL_C_INCLUDES := $(INC) $(LOCAL_PATH)/include

LOCAL_CFLAGS := -mfloat-abi=softfp -mfpu=neon-vfpv4 -march=armv7-a
LOCAL_ARM_NEON := true
TARGET_ARCH_ABI := armeabi-v7a
LOCAL_ARM_MODE := arm

include $(BUILD_STATIC_LIBRARY)
5 changes: 5 additions & 0 deletions FaceDetection/examples/android/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
APP_MODULES := FaceDetection
APP_PLATFORM := android-9
APP_ABI := armeabi-v7a
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions -std=c++11 -O2
1 change: 1 addition & 0 deletions FaceDetection/examples/android/jni/FaceDetection
35 changes: 35 additions & 0 deletions FaceIdentification/examples/android/jni/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := FaceIdentification

DIRS = src tools

LOCAL_SRC_FILES := FaceIdentification/src/blob.cpp \
FaceIdentification/src/common_net.cpp \
FaceIdentification/src/bias_adder_net.cpp \
FaceIdentification/src/bn_net.cpp \
FaceIdentification/src/conv_net.cpp \
FaceIdentification/src/eltwise_net.cpp \
FaceIdentification/src/inner_product_net.cpp \
FaceIdentification/src/max_pooling_net.cpp \
FaceIdentification/src/pad_net.cpp \
FaceIdentification/src/spatial_transform_net.cpp \
FaceIdentification/src/tform_maker_net.cpp \
FaceIdentification/src/net.cpp \
FaceIdentification/src/math_functions.cpp \
FaceIdentification/src/log.cpp \
FaceIdentification/tools/aligner.cpp \
FaceIdentification/tools/face_identification.cpp

LOCAL_C_INCLUDES := $(LOCAL_PATH)/FaceIdentification/include \
$(LOCAL_PATH)/FaceIdentification/src \
$(LOCAL_PATH)/FaceIdentification/tools

LOCAL_CFLAGS := -mfloat-abi=softfp -mfpu=neon-vfpv4 -march=armv7-a
LOCAL_ARM_NEON := true
TARGET_ARCH_ABI := armeabi-v7a
LOCAL_ARM_MODE := arm

include $(BUILD_STATIC_LIBRARY)
7 changes: 7 additions & 0 deletions FaceIdentification/examples/android/jni/Application.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
APP_MODULES := FaceIdentification
APP_PLATFORM := android-9
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions -std=c++11 -O2
APP_ABI := armeabi-v7a

#APP_CPPFLAGS += -D__VIPL_LOG__
1 change: 1 addition & 0 deletions FaceIdentification/examples/android/jni/FaceIdentification
42 changes: 42 additions & 0 deletions FaceIdentification/src/math_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,51 @@
#include <xmmintrin.h>
#include <cstdint>

#ifdef __ARM_EABI__
#include "arm_neon.h"
#else
#ifdef _WIN32
#include <intrin.h>
#else
#include <x86intrin.h>
#endif
#endif

#ifdef __ARM_EABI__

#ifdef __ARM_NEON__

float simd_dot(const float* src1, const float* src2, const long& count) {
long i = 0;

float32x4_t sum_vec = vdupq_n_f32(0);
float32x4_t data_a, data_b;
for (; i <count-3; i+=4){
data_a = vld1q_f32(&src1[i]);
data_b = vld1q_f32(&src2[i]);
sum_vec = vaddq_f32(sum_vec, vmulq_f32(data_a, data_b));
}

float sum = sum_vec[0] + sum_vec[1] + sum_vec[2] + sum_vec[3];
for (; i < count; i++){
sum += src1[i] * src2[i];
}
return sum;
}

#else // __ARM_NEON__

float simd_dot(const float* x, const float* y, const long& len) {
float inner_prod = 0.0f;
for (long i = 0; i < len; i++) {
inner_prod += x[i] * y[i];
}
return inner_prod;
}

#endif // end __ARM_NEON__

#else // __ARM_EABI__

float simd_dot(const float* x, const float* y, const long& len) {
float inner_prod = 0.0f;
Expand All @@ -61,6 +101,8 @@ float simd_dot(const float* x, const float* y, const long& len) {
return inner_prod;
}

#endif // end __ARM_EABI__

void matrix_procuct(const float* A, const float* B, float* C, const int n,
const int m, const int k, bool ta, bool tb) {
#ifdef _BLAS
Expand Down