Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
6d4c4405
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
6d4c4405
编写于
9月 13, 2017
作者:
Y
yangyaming
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' of
https://github.com/PaddlePaddle/Paddle
into fix-3923-c
上级
ec92588a
aed51dde
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
136 addition
and
23 deletion
+136
-23
CMakeLists.txt
CMakeLists.txt
+3
-0
Dockerfile.android
Dockerfile.android
+6
-7
cmake/external/gflags.cmake
cmake/external/gflags.cmake
+11
-2
cmake/external/glog.cmake
cmake/external/glog.cmake
+11
-2
cmake/external/openblas.cmake
cmake/external/openblas.cmake
+20
-0
cmake/external/protobuf.cmake
cmake/external/protobuf.cmake
+9
-0
cmake/external/zlib.cmake
cmake/external/zlib.cmake
+9
-0
paddle/capi/CMakeLists.txt
paddle/capi/CMakeLists.txt
+20
-0
paddle/function/neon/NeonDepthwiseConv.h
paddle/function/neon/NeonDepthwiseConv.h
+1
-1
paddle/scripts/docker/build_android.sh
paddle/scripts/docker/build_android.sh
+32
-5
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+1
-0
python/paddle/v2/framework/tests/op_test.py
python/paddle/v2/framework/tests/op_test.py
+11
-5
python/paddle/v2/framework/tests/test_gradient_checker.py
python/paddle/v2/framework/tests/test_gradient_checker.py
+2
-1
未找到文件。
CMakeLists.txt
浏览文件 @
6d4c4405
...
...
@@ -67,6 +67,9 @@ endif()
if
(
ANDROID
)
if
(
${
CMAKE_SYSTEM_VERSION
}
VERSION_LESS
"16"
)
message
(
FATAL_ERROR
"Unsupport standalone toolchains with Android API level lower than 16"
)
elseif
(
${
CMAKE_SYSTEM_VERSION
}
VERSION_LESS
"21"
)
# TODO: support glog for Android api 16 ~ 19 in the future
message
(
WARNING
"Using the unofficial git repository <https://github.com/Xreki/glog.git> instead"
)
endif
()
set
(
WITH_GPU OFF CACHE STRING
...
...
Dockerfile.android
浏览文件 @
6d4c4405
...
...
@@ -6,13 +6,14 @@ RUN /bin/bash -c 'if [[ -n ${UBUNTU_MIRROR} ]]; then sed -i 's#http://archive.ub
# ENV variables
ARG ANDROID_ABI
ARG ANDROID_API
ENV ANDROID_ABI=${ANDROID_ABI:-"armeabi-v7a"}
ENV ANDROID_API=${ANDROID_API:-21}
ENV HOME=/root \
ANDROID_NDK_HOME=/opt/android-ndk-linux \
ANDROID_ARM_STANDALONE_TOOLCHAIN=/opt/arm-toolchain \
ANDROID_ARM64_STANDALONE_TOOLCHAIN=/opt/arm64-toolchain
ANDROID_TOOLCHAINS_DIR=/opt/toolchains
RUN apt-get update && \
apt-get install -y \
...
...
@@ -42,14 +43,12 @@ RUN pip install --upgrade pip && \
pip install pre-commit
# Android NDK
RUN mkdir /opt/android-ndk-tmp && \
RUN mkdir -p ${ANDROID_TOOLCHAINS_DIR} && \
mkdir -p /opt/android-ndk-tmp && \
cd /opt/android-ndk-tmp && \
wget -q https://dl.google.com/android/repository/android-ndk-r14b-linux-x86_64.zip && \
unzip -q android-ndk-r14b-linux-x86_64.zip && \
mv android-ndk-r14b ${ANDROID_NDK_HOME} && \
${ANDROID_NDK_HOME}/build/tools/make-standalone-toolchain.sh --arch=arm --platform=android-23 --install-dir=${ANDROID_ARM_STANDALONE_TOOLCHAIN} && \
${ANDROID_NDK_HOME}/build/tools/make-standalone-toolchain.sh --arch=arm64 --platform=android-23 --install-dir=${ANDROID_ARM64_STANDALONE_TOOLCHAIN} && \
rm -rf /opt/android-ndk-tmp && \
rm -rf ${ANDROID_NDK_HOME}
rm -rf /opt/android-ndk-tmp
CMD ["bash", "/paddle/paddle/scripts/docker/build_android.sh"]
cmake/external/gflags.cmake
浏览文件 @
6d4c4405
...
...
@@ -18,9 +18,9 @@ SET(GFLAGS_SOURCES_DIR ${THIRD_PARTY_PATH}/gflags)
SET
(
GFLAGS_INSTALL_DIR
${
THIRD_PARTY_PATH
}
/install/gflags
)
SET
(
GFLAGS_INCLUDE_DIR
"
${
GFLAGS_INSTALL_DIR
}
/include"
CACHE PATH
"gflags include directory."
FORCE
)
IF
(
WIN32
)
set
(
GFLAGS_LIBRARIES
"
${
GFLAGS_INSTALL_DIR
}
/lib/gflags.lib"
CACHE FILEPATH
"GFLAGS_LIBRARIES"
FORCE
)
set
(
GFLAGS_LIBRARIES
"
${
GFLAGS_INSTALL_DIR
}
/lib/gflags.lib"
CACHE FILEPATH
"GFLAGS_LIBRARIES"
FORCE
)
ELSE
(
WIN32
)
set
(
GFLAGS_LIBRARIES
"
${
GFLAGS_INSTALL_DIR
}
/lib/libgflags.a"
CACHE FILEPATH
"GFLAGS_LIBRARIES"
FORCE
)
set
(
GFLAGS_LIBRARIES
"
${
GFLAGS_INSTALL_DIR
}
/lib/libgflags.a"
CACHE FILEPATH
"GFLAGS_LIBRARIES"
FORCE
)
ENDIF
(
WIN32
)
INCLUDE_DIRECTORIES
(
${
GFLAGS_INCLUDE_DIR
}
)
...
...
@@ -56,3 +56,12 @@ SET_PROPERTY(TARGET gflags PROPERTY IMPORTED_LOCATION ${GFLAGS_LIBRARIES})
ADD_DEPENDENCIES
(
gflags extern_gflags
)
LIST
(
APPEND external_project_dependencies gflags
)
IF
(
WITH_C_API
)
INSTALL
(
DIRECTORY
${
GFLAGS_INCLUDE_DIR
}
DESTINATION third_party/gflags
)
IF
(
ANDROID
)
INSTALL
(
FILES
${
GFLAGS_LIBRARIES
}
DESTINATION third_party/gflags/lib/
${
ANDROID_ABI
}
)
ELSE
()
INSTALL
(
FILES
${
GFLAGS_LIBRARIES
}
DESTINATION third_party/gflags/lib
)
ENDIF
()
ENDIF
()
cmake/external/glog.cmake
浏览文件 @
6d4c4405
...
...
@@ -19,9 +19,9 @@ SET(GLOG_INSTALL_DIR ${THIRD_PARTY_PATH}/install/glog)
SET
(
GLOG_INCLUDE_DIR
"
${
GLOG_INSTALL_DIR
}
/include"
CACHE PATH
"glog include directory."
FORCE
)
IF
(
WIN32
)
SET
(
GLOG_LIBRARIES
"
${
GLOG_INSTALL_DIR
}
/lib/libglog.lib"
CACHE FILEPATH
"glog library."
FORCE
)
SET
(
GLOG_LIBRARIES
"
${
GLOG_INSTALL_DIR
}
/lib/libglog.lib"
CACHE FILEPATH
"glog library."
FORCE
)
ELSE
(
WIN32
)
SET
(
GLOG_LIBRARIES
"
${
GLOG_INSTALL_DIR
}
/lib/libglog.a"
CACHE FILEPATH
"glog library."
FORCE
)
SET
(
GLOG_LIBRARIES
"
${
GLOG_INSTALL_DIR
}
/lib/libglog.a"
CACHE FILEPATH
"glog library."
FORCE
)
ENDIF
(
WIN32
)
INCLUDE_DIRECTORIES
(
${
GLOG_INCLUDE_DIR
}
)
...
...
@@ -56,3 +56,12 @@ ADD_DEPENDENCIES(glog extern_glog gflags)
LINK_LIBRARIES
(
glog gflags
)
LIST
(
APPEND external_project_dependencies glog
)
IF
(
WITH_C_API
)
INSTALL
(
DIRECTORY
${
GLOG_INCLUDE_DIR
}
DESTINATION third_party/glog
)
IF
(
ANDROID
)
INSTALL
(
FILES
${
GLOG_LIBRARIES
}
DESTINATION third_party/glog/lib/
${
ANDROID_ABI
}
)
ELSE
()
INSTALL
(
FILES
${
GLOG_LIBRARIES
}
DESTINATION third_party/glog/lib
)
ENDIF
()
ENDIF
()
cmake/external/openblas.cmake
浏览文件 @
6d4c4405
...
...
@@ -73,6 +73,26 @@ IF(NOT ${CBLAS_FOUND})
UPDATE_COMMAND
""
CONFIGURE_COMMAND
""
)
IF
(
WITH_C_API
)
INSTALL
(
DIRECTORY
${
CBLAS_INC_DIR
}
DESTINATION third_party/openblas
)
# Because libopenblas.a is a symbolic link of another library, thus need to
# install the whole directory.
IF
(
ANDROID
)
SET
(
TMP_INSTALL_DIR third_party/openblas/lib/
${
ANDROID_ABI
}
)
ELSE
()
SET
(
TMP_INSTALL_DIR third_party/openblas/lib
)
ENDIF
()
INSTALL
(
CODE
"execute_process(
COMMAND
${
CMAKE_COMMAND
}
-E copy_directory
${
CBLAS_INSTALL_DIR
}
/lib
destination
${
CMAKE_INSTALL_PREFIX
}
/
${
TMP_INSTALL_DIR
}
)"
)
INSTALL
(
CODE
"MESSAGE(STATUS
\"
Installing:
\"
\"
${
CBLAS_INSTALL_DIR
}
/lib ->
${
CMAKE_INSTALL_PREFIX
}
/
${
TMP_INSTALL_DIR
}
\"
)"
)
ENDIF
()
ENDIF
(
NOT
${
CBLAS_FOUND
}
)
MESSAGE
(
STATUS
"BLAS library:
${
CBLAS_LIBRARIES
}
"
)
...
...
cmake/external/protobuf.cmake
浏览文件 @
6d4c4405
...
...
@@ -223,6 +223,15 @@ IF(NOT PROTOBUF_FOUND)
SET
(
PROTOBUF_PROTOC_LIBRARY
${
extern_protobuf_PROTOC_LIBRARY
}
CACHE FILEPATH
"protoc library."
FORCE
)
IF
(
WITH_C_API
)
INSTALL
(
DIRECTORY
${
PROTOBUF_INCLUDE_DIR
}
DESTINATION third_party/protobuf
)
IF
(
ANDROID
)
INSTALL
(
FILES
${
PROTOBUF_LIBRARY
}
DESTINATION third_party/protobuf/lib/
${
ANDROID_ABI
}
)
ELSE
()
INSTALL
(
FILES
${
PROTOBUF_LIBRARY
}
DESTINATION third_party/protobuf/lib
)
ENDIF
()
ENDIF
()
IF
(
CMAKE_CROSSCOMPILING
)
PROMPT_PROTOBUF_LIB
(
protobuf_host extern_protobuf
)
ELSE
()
...
...
cmake/external/zlib.cmake
浏览文件 @
6d4c4405
...
...
@@ -49,3 +49,12 @@ ExternalProject_Add(
)
LIST
(
APPEND external_project_dependencies zlib
)
IF
(
WITH_C_API
)
INSTALL
(
DIRECTORY
${
ZLIB_INCLUDE_DIR
}
DESTINATION third_party/zlib
)
IF
(
ANDROID
)
INSTALL
(
FILES
${
ZLIB_LIBRARIES
}
DESTINATION third_party/zlib/lib/
${
ANDROID_ABI
}
)
ELSE
()
INSTALL
(
FILES
${
ZLIB_LIBRARIES
}
DESTINATION third_party/zlib/lib
)
ENDIF
()
ENDIF
()
paddle/capi/CMakeLists.txt
浏览文件 @
6d4c4405
...
...
@@ -64,9 +64,29 @@ link_paddle_exe(paddle_capi_shared)
install
(
FILES
${
CAPI_HEADERS
}
DESTINATION include/paddle
)
install
(
FILES
${
CMAKE_CURRENT_BINARY_DIR
}
/config.h DESTINATION include/paddle
)
if
(
ANDROID
)
execute_process
(
COMMAND
${
GIT_EXECUTABLE
}
log --pretty=oneline -1
OUTPUT_VARIABLE GIT_COMMITS_LIST
RESULT_VARIABLE GIT_COMMITS_LIST_RESULT
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
if
(
${
GIT_COMMITS_LIST_RESULT
}
)
set
(
GIT_COMMITS_LIST
"No commits."
)
endif
()
install
(
FILES
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
capi_whole_library
}
DESTINATION lib/
${
ANDROID_ABI
}
)
install
(
TARGETS paddle_capi_shared DESTINATION lib/
${
ANDROID_ABI
}
)
install
(
CODE
"FILE(WRITE
${
CMAKE_INSTALL_PREFIX
}
/lib/
${
ANDROID_ABI
}
/BUILD.txt
\"
Compiler:
\n\"
\"\\
t
${
CMAKE_C_COMPILER
}
\\
n
\"
\"\\
t
${
CMAKE_CXX_COMPILER
}
\\
n
\"
\"
Compiler Flags:
\\
n
\"
\"\\
t
${
CMAKE_F_FLAGS
}
\\
n
\"
\"\\
t
${
CMAKE_CXX_FLAGS
}
\\
n
\"
\"
Android API:
${
CMAKE_SYSTEM_VERSION
}
\\
n
\"
\"
Lastest commit:
\\
n
\"
\"\\
t
${
GIT_COMMITS_LIST
}
\\
n
\"
)"
)
else
(
ANDROID
)
install
(
FILES
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
capi_whole_library
}
DESTINATION lib
)
install
(
TARGETS paddle_capi_shared DESTINATION lib
)
...
...
paddle/function/neon/NeonDepthwiseConv.h
浏览文件 @
6d4c4405
...
...
@@ -594,7 +594,7 @@ struct StridePadding {
float32x4_t
s1
=
vdupq_n_f32
(
0.
f
);
for
(
int
s
=
0
;
s
<
step
;
s
++
)
{
float32x4_t
s0
=
vld1q_f32
(
input
);
float32x4x2_t
v
=
{
s0
,
s1
};
float32x4x2_t
v
=
{
{
s0
,
s1
}
};
vst2q_f32
(
inputPadding
,
v
);
input
+=
4
;
inputPadding
+=
8
;
...
...
paddle/scripts/docker/build_android.sh
浏览文件 @
6d4c4405
...
...
@@ -2,8 +2,30 @@
set
-xe
if
[
$ANDROID_ABI
==
"arm64-v8a"
]
;
then
ANDROID_ARCH
=
arm64
else
# armeabi, armeabi-v7a
ANDROID_ARCH
=
arm
fi
ANDROID_STANDALONE_TOOLCHAIN
=
$ANDROID_TOOLCHAINS_DIR
/
$ANDROID_ARCH
-android-
$ANDROID_API
cat
<<
EOF
============================================
Generating the standalone toolchain ...
${
ANDROID_NDK_HOME
}
/build/tools/make-standalone-toolchain.sh
--arch=
$ANDROID_ARCH
--platform=android-
$ANDROID_API
--install-dir=
${
ANDROID_STANDALONE_TOOLCHAIN
}
============================================
EOF
${
ANDROID_NDK_HOME
}
/build/tools/make-standalone-toolchain.sh
\
--arch
=
$ANDROID_ARCH
\
--platform
=
android-
$ANDROID_API
\
--install-dir
=
$ANDROID_STANDALONE_TOOLCHAIN
BUILD_ROOT
=
/paddle/build_android
DEST_ROOT
=
/paddle/install
DEST_ROOT
=
/paddle/install
_android
rm
-rf
$BUILD_ROOT
2>/dev/null
||
true
mkdir
-p
$BUILD_ROOT
...
...
@@ -11,7 +33,7 @@ cd $BUILD_ROOT
if
[
$ANDROID_ABI
==
"armeabi-v7a"
]
;
then
cmake
-DCMAKE_SYSTEM_NAME
=
Android
\
-DANDROID_STANDALONE_TOOLCHAIN
=
$ANDROID_
ARM_
STANDALONE_TOOLCHAIN
\
-DANDROID_STANDALONE_TOOLCHAIN
=
$ANDROID_STANDALONE_TOOLCHAIN
\
-DANDROID_ABI
=
$ANDROID_ABI
\
-DANDROID_ARM_NEON
=
ON
\
-DANDROID_ARM_MODE
=
ON
\
...
...
@@ -26,7 +48,7 @@ if [ $ANDROID_ABI == "armeabi-v7a" ]; then
..
elif
[
$ANDROID_ABI
==
"arm64-v8a"
]
;
then
cmake
-DCMAKE_SYSTEM_NAME
=
Android
\
-DANDROID_STANDALONE_TOOLCHAIN
=
$ANDROID_
ARM64_
STANDALONE_TOOLCHAIN
\
-DANDROID_STANDALONE_TOOLCHAIN
=
$ANDROID_STANDALONE_TOOLCHAIN
\
-DANDROID_ABI
=
$ANDROID_ABI
\
-DANDROID_ARM_MODE
=
ON
\
-DHOST_C_COMPILER
=
/usr/bin/gcc
\
...
...
@@ -40,12 +62,12 @@ elif [ $ANDROID_ABI == "arm64-v8a" ]; then
..
elif
[
$ANDROID_ABI
==
"armeabi"
]
;
then
cmake
-DCMAKE_SYSTEM_NAME
=
Android
\
-DANDROID_STANDALONE_TOOLCHAIN
=
$ANDROID_
ARM_
STANDALONE_TOOLCHAIN
\
-DANDROID_STANDALONE_TOOLCHAIN
=
$ANDROID_STANDALONE_TOOLCHAIN
\
-DANDROID_ABI
=
$ANDROID_ABI
\
-DANDROID_ARM_MODE
=
ON
\
-DHOST_C_COMPILER
=
/usr/bin/gcc
\
-DHOST_CXX_COMPILER
=
/usr/bin/g++
\
-DCMAKE_INSTALL_PREFIX
=
/paddle/install
\
-DCMAKE_INSTALL_PREFIX
=
$DEST_ROOT
\
-DCMAKE_BUILD_TYPE
=
Release
\
-DWITH_C_API
=
ON
\
-DWITH_SWIG_PY
=
OFF
\
...
...
@@ -55,5 +77,10 @@ else
echo
"Invalid ANDROID_ABI:
$ANDROID_ABI
"
fi
cat
<<
EOF
============================================
Building in
$BUILD_ROOT
...
============================================
EOF
make
-j
`
nproc
`
make
install
-j
`
nproc
`
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
6d4c4405
...
...
@@ -169,6 +169,7 @@ class LayerType(object):
EXCONV_LAYER
=
'exconv'
EXCONVTRANS_LAYER
=
'exconvt'
CUDNNCONV_LAYER
=
'cudnn_conv'
CUDNNCONVTRANS_LAYER
=
'cudnn_convt'
POOL_LAYER
=
'pool'
POOL3D_LAYER
=
'pool3d'
BATCH_NORM_LAYER
=
'batch_norm'
...
...
python/paddle/v2/framework/tests/op_test.py
浏览文件 @
6d4c4405
...
...
@@ -85,7 +85,7 @@ def get_numeric_gradient(scope,
op
,
inputs
,
input_to_check
,
output_name
,
output_name
s
,
delta
=
0.005
,
in_place
=
False
):
...
...
@@ -100,8 +100,11 @@ def get_numeric_gradient(scope,
ctx
=
core
.
DeviceContext
.
create
(
core
.
CPUPlace
())
def
get_output
():
op
.
run
(
scope
,
ctx
)
return
np
.
array
(
scope
.
find_var
(
output_name
).
get_tensor
()).
sum
()
sum
=
0.0
for
output_name
in
output_names
:
op
.
run
(
scope
,
ctx
)
sum
+=
np
.
array
(
scope
.
find_var
(
output_name
).
get_tensor
()).
sum
()
return
sum
tensor_to_check
=
scope
.
find_var
(
input_to_check
).
get_tensor
()
tensor_size
=
product
(
tensor_to_check
.
get_dims
())
...
...
@@ -225,7 +228,7 @@ class OpTest(unittest.TestCase):
def
check_grad
(
self
,
inputs_to_check
,
output_name
,
output_name
s
,
no_grad_set
=
None
,
in_place
=
False
,
max_relative_error
=
0.005
):
...
...
@@ -237,13 +240,16 @@ class OpTest(unittest.TestCase):
if
no_grad_set
is
None
:
no_grad_set
=
set
()
if
not
type
(
output_names
)
is
list
:
output_names
=
[
output_names
]
numeric_grads
=
[
get_numeric_gradient
(
self
.
scope
,
self
.
op
,
self
.
inputs
,
input_to_check
,
output_name
,
output_name
s
,
in_place
=
in_place
)
for
input_to_check
in
inputs_to_check
]
grad_names
=
[
...
...
python/paddle/v2/framework/tests/test_gradient_checker.py
浏览文件 @
6d4c4405
...
...
@@ -12,7 +12,8 @@ class GetNumericGradientTest(unittest.TestCase):
z
=
x
+
y
scope
=
core
.
Scope
()
add_op
=
create_op
(
scope
,
"add"
,
{
'X'
:
x
,
'Y'
:
y
},
{
'Out'
:
z
},
dict
())
arr
=
get_numeric_gradient
(
scope
,
add_op
,
{
'X'
:
x
,
'Y'
:
y
},
'X'
,
'Out'
)
arr
=
get_numeric_gradient
(
scope
,
add_op
,
{
'X'
:
x
,
'Y'
:
y
},
'X'
,
[
'Out'
])
self
.
assertAlmostEqual
(
arr
.
mean
(),
1.0
,
delta
=
1e-4
)
def
test_softmax_op
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录