Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
f657e21f
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
接近 2 年 前同步成功
通知
707
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看板
提交
f657e21f
编写于
9月 14, 2017
作者:
L
Luo Tao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update new_op_cn.md, fix type error
上级
70cadf93
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
19 deletion
+13
-19
doc/howto/dev/new_op_cn.md
doc/howto/dev/new_op_cn.md
+12
-18
paddle/operators/CMakeLists.txt
paddle/operators/CMakeLists.txt
+1
-1
未找到文件。
doc/howto/dev/new_op_cn.md
浏览文件 @
f657e21f
...
@@ -241,24 +241,12 @@ MulOp(const std::string &type, const framework::VariableNameMap &inputs,
...
@@ -241,24 +241,12 @@ MulOp(const std::string &type, const framework::VariableNameMap &inputs,
-
绑定Python
-
绑定Python
在 [`paddle/pybind/pybind.cc
编译器 [paddle/operators/CMakeLists.txt](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/operators/CMakeLists.txt) 会自动为Op绑定Python,生成[`paddle/pybind/pybind.h](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/pybind/pybind.h),绑定规则如下:
`](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/pybind/pybind.cc) 使用`
USE_OP
`告知编译器需要链接的Op,具体解释参考[代码注释](https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/framework/op_registry.h#L81)。
- net_op 不绑定Python
```
- 如果OP不带Kernel,则使用`USE_NO_KENREL_OP`
USE_OP(mul);
- 如果只实现了CPU版本,则使用`USE_CPU_ONLY_OP`
```
- `USE_NO_KENREL_OP`优先级高于`USE_CPU_ONLY_OP`
如果只实现了CPU版本,则使用`
USE_CPU_ONLY_OP
`:
```
USE_CPU_ONLY_OP(gather);
```
如果OP不带Kernel,则使用`
USE_NO_KENREL_OP
`:
```
USE_NO_KENREL_OP(recurrent);
```
-
生成库
-
生成库
...
@@ -367,3 +355,9 @@ make test ARGS="-R test_mul_op -V"
...
@@ -367,3 +355,9 @@ make test ARGS="-R test_mul_op -V"
```
bash
```
bash
ctest
-R
test_mul_op
ctest
-R
test_mul_op
```
```
## 注意事项
-
为每个Op创建单独的
`*_op.h`
(如有)、
`*_op.cc`
和
`*_op.cu`
(如有)。不允许一个文件中包含多个Op,这将会导致编译出错。
-
注册Op时的类型名,需要和该Op的名字一样。即不允许在
`A_op.cc`
里面,注册
`REGISTER_OP(B, ...)`
等,这将会导致单元测试出错。
-
如果Op没有实现GPU Kernel,请不要创建空的
`*_op.cu`
,这将会导致单元测试出错。
paddle/operators/CMakeLists.txt
浏览文件 @
f657e21f
...
@@ -52,7 +52,7 @@ function(op_library TARGET)
...
@@ -52,7 +52,7 @@ function(op_library TARGET)
# net_op doesn't need pybind
# net_op doesn't need pybind
if
(
"
${
TARGET
}
"
STREQUAL
"net_op"
)
if
(
"
${
TARGET
}
"
STREQUAL
"net_op"
)
set
(
pybind_f
ile
1
)
set
(
pybind_f
lag
1
)
endif
()
endif
()
# pybind USE_NO_KERNEL_OP
# pybind USE_NO_KERNEL_OP
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录