Skip to content

Commit

Permalink
Android: support MIPS/MIPS64 ABI. Close Maratyszcza#66
Browse files Browse the repository at this point in the history
  • Loading branch information
Maratyszcza committed Apr 23, 2017
1 parent d02da48 commit 3ada270
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 13 deletions.
2 changes: 2 additions & 0 deletions include/nnpack/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#define NNP_BACKEND_PSIMD 1
#elif defined(__x86_64__)
#define NNP_BACKEND_X86_64 1
#elif defined(__ANDROID__) && defined(__mips__)
#define NNP_BACKEND_SCALAR 1
#else
#define NNP_BACKEND_PSIMD 1
#endif
Expand Down
23 changes: 20 additions & 3 deletions jni/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ include $(BUILD_STATIC_LIBRARY)

include $(CLEAR_VARS)
LOCAL_MODULE := nnpack_ukernels
ifeq ($(TARGET_ARCH_ABI),$(filter $(TARGET_ARCH_ABI),x86 x86_64 armeabi-v7a arm64-v8a))
LOCAL_SRC_FILES := \
$(LOCAL_PATH)/src/psimd/2d-fourier-8x8.c \
$(LOCAL_PATH)/src/psimd/2d-fourier-16x16.c \
$(LOCAL_PATH)/src/psimd/2d-winograd-8x8-3x3.c \
$(LOCAL_PATH)/src/psimd/relu.c \
$(LOCAL_PATH)/src/psimd/softmax.c \
$(LOCAL_PATH)/src/psimd/fft-block-mac.c \
$(LOCAL_PATH)/src/psimd/blas/shdotxf.c
ifeq ($(TARGET_ARCH_ABI),$(filter $(TARGET_ARCH_ABI),armeabi-v7a arm64-v8a))
LOCAL_SRC_FILES += \
Expand All @@ -50,7 +50,24 @@ LOCAL_SRC_FILES += \
$(LOCAL_PATH)/src/psimd/blas/sgemm.c \
$(LOCAL_PATH)/src/psimd/blas/sdotxf.c
endif
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/src $(LOCAL_PATH)/deps/fp16/include $(LOCAL_PATH)/deps/psimd/include
else
LOCAL_SRC_FILES := \
$(LOCAL_PATH)/src/scalar/2d-fourier-8x8.c \
$(LOCAL_PATH)/src/scalar/2d-fourier-16x16.c \
$(LOCAL_PATH)/src/scalar/2d-winograd-8x8-3x3.c \
$(LOCAL_PATH)/src/scalar/relu.c \
$(LOCAL_PATH)/src/scalar/softmax.c \
$(LOCAL_PATH)/src/scalar/blas/shdotxf.c \
$(LOCAL_PATH)/src/scalar/blas/conv1x1.c \
$(LOCAL_PATH)/src/scalar/blas/s2gemm.c \
$(LOCAL_PATH)/src/scalar/blas/cgemm.c \
$(LOCAL_PATH)/src/scalar/blas/cgemm-conjb.c \
$(LOCAL_PATH)/src/scalar/blas/s2gemm-transc.c \
$(LOCAL_PATH)/src/scalar/blas/cgemm-conjb-transc.c \
$(LOCAL_PATH)/src/scalar/blas/sgemm.c \
$(LOCAL_PATH)/src/scalar/blas/sdotxf.c
endif
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/src $(LOCAL_PATH)/deps/fp16/include $(LOCAL_PATH)/deps/psimd/include $(LOCAL_PATH)/deps/scalar/include
LOCAL_CFLAGS := -std=gnu99 -D__STDC_CONSTANT_MACROS=1
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_ARM_NEON := true
Expand All @@ -64,7 +81,7 @@ LOCAL_SRC_FILES := \
$(LOCAL_PATH)/src/init.c \
$(LOCAL_PATH)/src/convolution-output.c \
$(LOCAL_PATH)/src/convolution-input-gradient.c \
$(LOCAL_PATH)/src/convolution-kernel.c \
$(LOCAL_PATH)/src/convolution-kernel-gradient.c \
$(LOCAL_PATH)/src/convolution-inference.c \
$(LOCAL_PATH)/src/fully-connected-output.c \
$(LOCAL_PATH)/src/fully-connected-inference.c \
Expand Down
2 changes: 1 addition & 1 deletion jni/Application.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
APP_PLATFORM := android-14
APP_PIE := true
APP_ABI := x86 x86_64 armeabi-v7a arm64-v8a
APP_ABI := x86 x86_64 armeabi-v7a arm64-v8a mips mips64
APP_STL := c++_static
18 changes: 9 additions & 9 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,9 +373,9 @@ static void init_hwinfo(void) {
nnp_hwinfo.transforms.owt_f6x6_3x3 = nnp_owt8x8_3x3__avx2;
nnp_hwinfo.transforms.owt_f6x6_3x3_with_bias = nnp_owt8x8_3x3_with_bias__avx2;
nnp_hwinfo.transforms.owt_f6x6_3x3_with_bias_with_relu = nnp_owt8x8_3x3_with_bias_with_relu__avx2;
nnp_hwinfo.blockmac.fourier8x8_mac_with_conj = nnp_ft8x8gemmc__fma3;
nnp_hwinfo.blockmac.fourier16x16_mac_with_conj = nnp_ft16x16gemmc__fma3;
nnp_hwinfo.blockmac.winograd8x8_mac = nnp_s8x8gemm__fma3;
// nnp_hwinfo.blockmac.fourier8x8_mac_with_conj = nnp_ft8x8gemmc__fma3;
// nnp_hwinfo.blockmac.fourier16x16_mac_with_conj = nnp_ft16x16gemmc__fma3;
// nnp_hwinfo.blockmac.winograd8x8_mac = nnp_s8x8gemm__fma3;
nnp_hwinfo.activations.relu = nnp_relu__avx2;
nnp_hwinfo.activations.inplace_relu = nnp_inplace_relu__avx2;
nnp_hwinfo.activations.grad_relu = nnp_grad_relu__avx2;
Expand Down Expand Up @@ -444,9 +444,9 @@ static void init_hwinfo(void) {
nnp_hwinfo.transforms.owt_f6x6_3x3 = nnp_owt8x8_3x3__psimd;
nnp_hwinfo.transforms.owt_f6x6_3x3_with_bias = nnp_owt8x8_3x3_with_bias__psimd;
nnp_hwinfo.transforms.owt_f6x6_3x3_with_bias_with_relu = nnp_owt8x8_3x3_with_bias_with_relu__psimd;
nnp_hwinfo.blockmac.fourier8x8_mac_with_conj = nnp_ft8x8gemmc__psimd;
nnp_hwinfo.blockmac.fourier16x16_mac_with_conj = nnp_ft16x16gemmc__psimd;
nnp_hwinfo.blockmac.winograd8x8_mac = nnp_s8x8gemm__psimd;
// nnp_hwinfo.blockmac.fourier8x8_mac_with_conj = nnp_ft8x8gemmc__psimd;
// nnp_hwinfo.blockmac.fourier16x16_mac_with_conj = nnp_ft16x16gemmc__psimd;
// nnp_hwinfo.blockmac.winograd8x8_mac = nnp_s8x8gemm__psimd;
nnp_hwinfo.activations.relu = nnp_relu__psimd;
nnp_hwinfo.activations.inplace_relu = nnp_inplace_relu__psimd;
nnp_hwinfo.activations.grad_relu = nnp_grad_relu__psimd;
Expand Down Expand Up @@ -514,9 +514,9 @@ static void init_hwinfo(void) {
nnp_hwinfo.transforms.owt_f6x6_3x3 = nnp_owt8x8_3x3__psimd;
nnp_hwinfo.transforms.owt_f6x6_3x3_with_bias = nnp_owt8x8_3x3_with_bias__psimd;
nnp_hwinfo.transforms.owt_f6x6_3x3_with_bias_with_relu = nnp_owt8x8_3x3_with_bias_with_relu__psimd;
nnp_hwinfo.blockmac.fourier8x8_mac_with_conj = nnp_ft8x8gemmc__psimd;
nnp_hwinfo.blockmac.fourier16x16_mac_with_conj = nnp_ft16x16gemmc__psimd;
nnp_hwinfo.blockmac.winograd8x8_mac = nnp_s8x8gemm__psimd;
// nnp_hwinfo.blockmac.fourier8x8_mac_with_conj = nnp_ft8x8gemmc__psimd;
// nnp_hwinfo.blockmac.fourier16x16_mac_with_conj = nnp_ft16x16gemmc__psimd;
// nnp_hwinfo.blockmac.winograd8x8_mac = nnp_s8x8gemm__psimd;
nnp_hwinfo.activations.relu = nnp_relu__psimd;
nnp_hwinfo.activations.inplace_relu = nnp_inplace_relu__psimd;
nnp_hwinfo.activations.grad_relu = nnp_grad_relu__psimd;
Expand Down

0 comments on commit 3ada270

Please sign in to comment.