Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
7062be0f
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
7062be0f
编写于
6月 28, 2017
作者:
H
hedaoyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add cmake for compile NNPACKConvOp.cpp.
上级
2e02952b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
46 addition
and
9 deletion
+46
-9
CMakeLists.txt
CMakeLists.txt
+5
-0
paddle/function/CMakeLists.txt
paddle/function/CMakeLists.txt
+5
-0
paddle/function/nnpack/NNPACKConvOp.cpp
paddle/function/nnpack/NNPACKConvOp.cpp
+20
-9
paddle/function/nnpack/nnpack.cmake
paddle/function/nnpack/nnpack.cmake
+16
-0
未找到文件。
CMakeLists.txt
浏览文件 @
7062be0f
...
...
@@ -48,6 +48,7 @@ option(COVERALLS_UPLOAD "Package code coverage data to coveralls" OFF)
option
(
ON_TRAVIS
"Exclude special unit test on Travis CI"
OFF
)
option
(
WITH_C_API
"Compile PaddlePaddle with C-API(Prediction)"
OFF
)
option
(
WITH_GOLANG
"Compile PaddlePaddle with GOLANG"
OFF
)
option
(
USE_NNPACK
"Compile PaddlePaddle with NNPACK library"
OFF
)
# CMAKE_BUILD_TYPE
if
(
NOT CMAKE_BUILD_TYPE
)
...
...
@@ -126,6 +127,10 @@ if(WITH_GPU)
endif
(
NOT WITH_DSO
)
endif
(
WITH_GPU
)
if
(
USE_NNPACK
)
list
(
APPEND EXTERNAL_LIBS
${
NNPACK_LIB
}
${
PTHREADPOOL_LIB
}
"rt"
)
endif
(
USE_NNPACK
)
add_subdirectory
(
proto
)
add_subdirectory
(
paddle
)
add_subdirectory
(
python
)
...
...
paddle/function/CMakeLists.txt
浏览文件 @
7062be0f
...
...
@@ -10,6 +10,11 @@ if(WITH_GPU)
cuda_compile
(
cu_objs
${
cu_files
}
)
endif
()
if
(
USE_NNPACK
)
include
(
nnpack/nnpack.cmake
)
list
(
APPEND cpp_files nnpack/NNPACKConvOp.cpp
)
endif
()
add_library
(
paddle_function STATIC
${
cpp_files
}
${
cu_objs
}
)
add_dependencies
(
paddle_function
${
external_project_dependencies
}
)
add_dependencies
(
paddle_function gen_proto_cpp
)
...
...
paddle/function/nnpack/NNPACKConvOp.cpp
浏览文件 @
7062be0f
...
...
@@ -12,8 +12,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include "ConvOp.h"
#include "nnpack.h"
#include "paddle/function/ConvOp.h"
DEFINE_bool
(
nnpack_allocate_outside
,
false
,
...
...
@@ -72,14 +72,22 @@ public:
}
}
virtual
void
check
(
const
BufferArgs
&
inputs
,
const
BufferArgs
&
outputs
)
override
{
const
TensorShape
&
output
=
inputs
[
0
].
shape
();
const
TensorShape
&
filter
=
inputs
[
1
].
shape
();
const
TensorShape
&
input
=
outputs
[
0
].
shape
();
checkShape
(
input
,
filter
,
output
);
}
void
calc
(
const
BufferArgs
&
inputs
,
const
BufferArgs
&
outputs
)
override
{
CHECK_EQ
(
numInputs_
,
inputs
.
size
());
CHECK_EQ
(
numOutputs_
,
outputs
.
size
());
CHECK_EQ
(
outputs
[
0
].
getArgType
(),
ASSIGN_TO
);
check
(
inputs
,
outputs
);
const
TensorShape
&
input
=
inputs
[
0
].
shape
();
const
TensorShape
&
filter
=
inputs
[
1
].
shape
();
const
TensorShape
&
output
=
outputs
[
0
].
shape
();
check
(
input
,
filter
,
output
);
size_t
batchSize
=
input
[
0
];
size_t
inputChannels
=
input
[
1
];
...
...
@@ -92,12 +100,13 @@ public:
// size_t outputWidth = output[3];
nnp_size
inputSize
=
{.
width
=
inputWidth
,
.
height
=
inputHeight
};
nnp_padding
padding
=
{.
top
=
paddingH
(),
.
right
=
paddingW
(),
.
bottom
=
paddingH
(),
.
left
=
paddingW
()};
nnp_padding
padding
=
{.
top
=
(
size_t
)
paddingH
(),
.
right
=
(
size_t
)
paddingW
(),
.
bottom
=
(
size_t
)
paddingH
(),
.
left
=
(
size_t
)
paddingW
()};
nnp_size
kernelSize
=
{.
width
=
filterWidth
,
.
height
=
filterHeight
};
nnp_size
outputSubsampling
=
{.
width
=
strideW
(),
.
height
=
strideH
()};
nnp_size
outputSubsampling
=
{.
width
=
(
size_t
)
strideW
(),
.
height
=
(
size_t
)
strideH
()};
float
*
inputData
=
inputs
[
0
].
data
<
float
>
();
float
*
filterData
=
inputs
[
1
].
data
<
float
>
();
...
...
@@ -129,7 +138,8 @@ public:
CHECK_EQ
(
status
,
nnp_status_success
);
}
else
{
// only supports stride = 1
CHECK_EQ
(
stride_
,
1
);
CHECK_EQ
(
strideH
(),
1
);
CHECK_EQ
(
strideW
(),
1
);
nnp_status
status
=
nnp_convolution_output
(
algorithm_
,
batchSize
,
inputChannels
,
...
...
@@ -189,7 +199,8 @@ public:
CHECK_EQ
(
status
,
nnp_status_success
);
}
else
{
// only supports stride = 1
CHECK_EQ
(
stride_
,
1
);
CHECK_EQ
(
strideH
(),
1
);
CHECK_EQ
(
strideW
(),
1
);
nnp_status
status
=
nnp_convolution_output
(
algorithm_
,
batchSize
,
inputChannels
,
...
...
paddle/function/nnpack/nnpack.cmake
0 → 100644
浏览文件 @
7062be0f
# Find the NNPACK library
# NNPACK_ROOT - where to find NNPACK include and library.
#
set
(
NNPACK_FOUND OFF
)
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
)
if
(
NNPACK_INC_DIR AND NNPACK_LIB AND PTHREADPOOL_LIB
)
set
(
NNPACK_FOUND ON
)
INCLUDE_DIRECTORIES
(
${
NNPACK_INC_DIR
}
)
else
()
message
(
FATAL_ERROR
"Cannot find NNPACK in (
${
NNPACK_ROOT
}
)"
)
endif
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录