Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
csdn_franckjun
Paddle
提交
f146b03b
P
Paddle
项目概览
csdn_franckjun
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f146b03b
编写于
7月 18, 2017
作者:
H
hedaoyuan
提交者:
GitHub
7月 18, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2824 from hedaoyuan/fix_nnpack
Fix some link errors about NNPACK.
上级
efd98097
891e5dcc
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
30 addition
and
13 deletion
+30
-13
CMakeLists.txt
CMakeLists.txt
+2
-1
cmake/external/nnpack.cmake
cmake/external/nnpack.cmake
+14
-0
paddle/function/CMakeLists.txt
paddle/function/CMakeLists.txt
+0
-1
paddle/function/nnpack/NNPACKConvOp.cpp
paddle/function/nnpack/NNPACKConvOp.cpp
+14
-11
未找到文件。
CMakeLists.txt
浏览文件 @
f146b03b
...
...
@@ -137,7 +137,8 @@ if(WITH_GPU)
endif
(
WITH_GPU
)
if
(
USE_NNPACK
)
list
(
APPEND EXTERNAL_LIBS
${
NNPACK_LIB
}
${
PTHREADPOOL_LIB
}
"rt"
)
include
(
external/nnpack
)
list
(
APPEND EXTERNAL_LIBS
${
NNPACK_LIBS
}
)
endif
(
USE_NNPACK
)
add_subdirectory
(
proto
)
...
...
paddle/function/nnpack
/nnpack.cmake
→
cmake/external
/nnpack.cmake
浏览文件 @
f146b03b
...
...
@@ -7,10 +7,24 @@ set(NNPACK_ROOT $ENV{NNPACK_ROOT} CACHE PATH "Folder contains NNPACK")
find_path
(
NNPACK_INC_DIR nnpack.h PATHS
${
NNPACK_ROOT
}
/include
)
find_library
(
NNPACK_LIB NAMES nnpack PATHS
${
NNPACK_ROOT
}
/lib
)
find_library
(
PTHREADPOOL_LIB NAMES pthreadpool PATHS
${
NNPACK_ROOT
}
/lib
)
find_library
(
NNPACK_UKERNELS_LIB NAMES nnpack_ukernels PATHS
${
NNPACK_ROOT
}
/lib
)
find_library
(
NNPACK_CPUFEATURES_LIB NAMES cpufeatures PATHS
${
NNPACK_ROOT
}
/lib
)
if
(
NNPACK_INC_DIR AND NNPACK_LIB AND PTHREADPOOL_LIB
)
set
(
NNPACK_FOUND ON
)
INCLUDE_DIRECTORIES
(
${
NNPACK_INC_DIR
}
)
set
(
NNPACK_LIBS
)
list
(
APPEND NNPACK_LIBS
${
NNPACK_LIB
}
${
PTHREADPOOL_LIB
}
)
if
(
NNPACK_UKERNELS_LIB
)
list
(
APPEND NNPACK_LIBS
${
NNPACK_UKERNELS_LIB
}
)
endif
()
if
(
NNPACK_CPUFEATURES_LIB
)
list
(
APPEND NNPACK_LIBS
${
NNPACK_CPUFEATURES_LIB
}
)
endif
()
if
(
NOT ANDROID
)
list
(
APPEND NNPACK_LIBS
"rt"
)
endif
()
else
()
message
(
FATAL_ERROR
"Cannot find NNPACK in (
${
NNPACK_ROOT
}
)"
)
endif
()
paddle/function/CMakeLists.txt
浏览文件 @
f146b03b
...
...
@@ -11,7 +11,6 @@ if(WITH_GPU)
endif
()
if
(
USE_NNPACK
)
include
(
nnpack/nnpack.cmake
)
list
(
APPEND cpp_files nnpack/NNPACKConvOp.cpp
)
if
(
WITH_TESTING
)
add_unittest
(
NNPACKConvOpTest nnpack/NNPACKConvOpTest.cpp
)
...
...
paddle/function/nnpack/NNPACKConvOp.cpp
浏览文件 @
f146b03b
...
...
@@ -16,7 +16,7 @@ limitations under the License. */
#include "paddle/function/ConvOp.h"
DEFINE_bool
(
nnpack_allocate_outside
,
fals
e
,
tru
e
,
"Allocate and free workspace memory outside the NNPACK interface."
);
DEFINE_int32
(
nnpack_num_threads
,
0
,
...
...
@@ -58,18 +58,10 @@ public:
workspaceBuffer_
=
nullptr
;
workspaceSize_
=
0
;
threadpool_
=
nullptr
;
if
(
FLAGS_nnpack_num_threads
)
{
threadpool_
=
pthreadpool_create
(
FLAGS_nnpack_num_threads
);
VLOG
(
3
)
<<
"Number of threads "
<<
pthreadpool_get_threads_count
(
threadpool_
);
}
create_nnpack_threadpool
();
}
~
NNPACKConvFunction
()
{
if
(
threadpool_
)
{
pthreadpool_destroy
(
threadpool_
);
}
if
(
workspaceBuffer_
)
{
free
(
workspaceBuffer_
);
}
...
...
@@ -225,14 +217,25 @@ public:
}
}
static
void
create_nnpack_threadpool
()
{
if
(
FLAGS_nnpack_num_threads
&&
threadpool_
==
nullptr
)
{
threadpool_
=
pthreadpool_create
(
FLAGS_nnpack_num_threads
);
VLOG
(
3
)
<<
"Number of threads "
<<
pthreadpool_get_threads_count
(
threadpool_
);
}
}
private:
nnp_convolution_algorithm
algorithm_
;
nnp_convolution_transform_strategy
transform_strategy_
;
void
*
workspaceBuffer_
;
size_t
workspaceSize_
;
pthreadpool_t
threadpool_
;
static
pthreadpool_t
threadpool_
;
};
template
<
DeviceType
Device
>
pthreadpool_t
NNPACKConvFunction
<
Device
>::
threadpool_
=
nullptr
;
REGISTER_TYPED_FUNC
(
NNPACKConv
,
CPU
,
NNPACKConvFunction
);
}
// namespace paddle
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录