Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
f1913d46
P
PaddleDetection
项目概览
s920243400
/
PaddleDetection
与 Fork 源项目一致
Fork自
PaddlePaddle / PaddleDetection
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f1913d46
编写于
9月 27, 2017
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Change registry, test register double kernel
上级
2c05465d
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
37 addition
and
9 deletion
+37
-9
paddle/framework/op_registry.h
paddle/framework/op_registry.h
+29
-5
paddle/operators/elementwise_mul_op.cc
paddle/operators/elementwise_mul_op.cc
+4
-2
paddle/operators/elementwise_mul_op.cu
paddle/operators/elementwise_mul_op.cu
+4
-2
未找到文件。
paddle/framework/op_registry.h
浏览文件 @
f1913d46
...
...
@@ -100,14 +100,38 @@ class OpRegistrar : public Registrar {
}
};
template
<
typename
PlaceType
,
typename
KernelType
>
template
<
typename
PlaceType
,
bool
at_end
,
size_t
I
,
typename
...
KernelType
>
struct
OpKernelRegistrarFunctor
;
template
<
typename
PlaceType
,
size_t
I
,
typename
...
KernelType
>
struct
OpKernelRegistrarFunctor
<
PlaceType
,
false
,
I
,
KernelType
...
>
{
using
KT
=
typename
std
::
tuple_element
<
I
,
std
::
tuple
<
KernelType
...
>>::
type
;
void
operator
()(
const
char
*
op_type
)
const
{
using
T
=
typename
KT
::
ELEMENT_TYPE
;
OperatorWithKernel
::
OpKernelKey
key
(
ToDataType
(
std
::
type_index
(
typeid
(
T
))),
PlaceType
());
OperatorWithKernel
::
AllOpKernels
()[
op_type
][
key
].
reset
(
new
KT
);
constexpr
auto
size
=
std
::
tuple_size
<
std
::
tuple
<
KernelType
...
>>::
value
;
OpKernelRegistrarFunctor
<
PlaceType
,
I
+
1
==
size
,
I
+
1
,
KernelType
...
>
func
;
func
(
op_type
);
}
};
template
<
typename
PlaceType
,
size_t
I
,
typename
...
KernelType
>
struct
OpKernelRegistrarFunctor
<
PlaceType
,
true
,
I
,
KernelType
...
>
{
void
operator
()(
const
char
*
op_type
)
const
{}
};
// User can register many kernel in one place. The data type could be different.
template
<
typename
PlaceType
,
typename
...
KernelType
>
class
OpKernelRegistrar
:
public
Registrar
{
public:
explicit
OpKernelRegistrar
(
const
char
*
op_type
)
{
using
T
=
typename
KernelType
::
ELEMENT_TYPE
;
OperatorWithKernel
::
OpKernelKey
key
(
ToDataType
(
std
::
type_index
(
typeid
(
T
))),
PlaceType
());
OperatorWithKernel
::
AllOpKernels
()[
op_type
][
key
].
reset
(
new
KernelType
);
OpKernelRegistrarFunctor
<
PlaceType
,
false
,
0
,
KernelType
...
>
func
;
func
(
op_type
);
}
};
...
...
paddle/operators/elementwise_mul_op.cc
浏览文件 @
f1913d46
...
...
@@ -36,7 +36,9 @@ REGISTER_OP(elementwise_mul, ops::ElementwiseOp, ops::ElementwiseMulOpMaker,
elementwise_mul_grad
,
ops
::
ElementwiseOpGrad
);
REGISTER_OP_CPU_KERNEL
(
elementwise_mul
,
ops
::
ElementwiseMulKernel
<
paddle
::
platform
::
CPUPlace
,
float
>
);
ops
::
ElementwiseMulKernel
<
paddle
::
platform
::
CPUPlace
,
float
>
,
ops
::
ElementwiseMulKernel
<
paddle
::
platform
::
CPUPlace
,
double
>
);
REGISTER_OP_CPU_KERNEL
(
elementwise_mul_grad
,
ops
::
ElementwiseMulGradKernel
<
paddle
::
platform
::
CPUPlace
,
float
>
);
ops
::
ElementwiseMulGradKernel
<
paddle
::
platform
::
CPUPlace
,
float
>
,
ops
::
ElementwiseMulGradKernel
<
paddle
::
platform
::
CPUPlace
,
double
>
);
paddle/operators/elementwise_mul_op.cu
浏览文件 @
f1913d46
...
...
@@ -19,7 +19,9 @@ namespace ops = paddle::operators;
REGISTER_OP_GPU_KERNEL
(
elementwise_mul
,
ops
::
ElementwiseMulKernel
<
paddle
::
platform
::
GPUPlace
,
float
>
);
ops
::
ElementwiseMulKernel
<
paddle
::
platform
::
GPUPlace
,
float
>
,
ops
::
ElementwiseMulKernel
<
paddle
::
platform
::
GPUPlace
,
double
>
);
REGISTER_OP_GPU_KERNEL
(
elementwise_mul_grad
,
ops
::
ElementwiseMulGradKernel
<
paddle
::
platform
::
GPUPlace
,
float
>
);
ops
::
ElementwiseMulGradKernel
<
paddle
::
platform
::
GPUPlace
,
float
>
,
ops
::
ElementwiseMulGradKernel
<
paddle
::
platform
::
GPUPlace
,
double
>
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录