Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
s920243400
PaddleDetection
提交
b36205e2
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看板
提交
b36205e2
编写于
8月 02, 2017
作者:
L
liaogang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refine compute code in operators
上级
bfaea910
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
33 addition
and
15 deletion
+33
-15
paddle/framework/eigen.h
paddle/framework/eigen.h
+1
-0
paddle/operators/add_op.h
paddle/operators/add_op.h
+7
-4
paddle/operators/mean_op.h
paddle/operators/mean_op.h
+5
-2
paddle/operators/mul_op.h
paddle/operators/mul_op.h
+9
-4
paddle/operators/sgd_op.h
paddle/operators/sgd_op.h
+6
-2
paddle/operators/sigmoid_op.h
paddle/operators/sigmoid_op.h
+5
-3
未找到文件。
paddle/framework/eigen.h
浏览文件 @
b36205e2
...
...
@@ -28,6 +28,7 @@ struct EigenDim {
static
Type
From
(
const
DDim
&
dims
)
{
PADDLE_ENFORCE
(
arity
(
dims
)
==
D
,
"D must match arity(DDim)"
);
Type
ret
;
#pragma unroll
for
(
int
d
=
0
;
d
<
arity
(
dims
);
d
++
)
{
ret
[
d
]
=
dims
[
d
];
}
...
...
paddle/operators/add_op.h
浏览文件 @
b36205e2
...
...
@@ -28,10 +28,13 @@ public:
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
EigenVector
<
T
>::
Flatten
(
*
output
).
device
(
*
(
context
.
GetEigenDevice
<
Place
>
()))
=
framework
::
EigenVector
<
T
>::
Flatten
(
*
input0
)
+
framework
::
EigenVector
<
T
>::
Flatten
(
*
input1
);
auto
X
=
EigenVector
<
T
>::
Flatten
(
*
input0
);
auto
Y
=
EigenVector
<
T
>::
Flatten
(
*
input1
);
auto
Z
=
EigenVector
<
T
>::
Flatten
(
*
output
);
auto
place
=
*
context
.
GetEigenDevice
<
Place
>
();
Z
.
device
(
place
)
=
X
+
Y
;
}
};
...
...
paddle/operators/mean_op.h
浏览文件 @
b36205e2
...
...
@@ -27,8 +27,11 @@ public:
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
EigenScalar
<
T
>::
From
(
*
output
).
device
(
*
(
context
.
GetEigenDevice
<
Place
>
()))
=
EigenVector
<
T
>::
Flatten
(
*
input
).
mean
();
auto
X
=
EigenVector
<
T
>::
Flatten
(
*
input
);
auto
y
=
EigenScalar
<
T
>::
From
(
*
output
);
auto
place
=
*
context
.
GetEigenDevice
<
Place
>
();
y
.
device
(
place
)
=
X
.
mean
();
}
};
...
...
paddle/operators/mul_op.h
浏览文件 @
b36205e2
...
...
@@ -26,13 +26,18 @@ public:
Eigen
::
array
<
Eigen
::
IndexPair
<
Eigen
::
DenseIndex
>
,
1
>
dim_pair
=
{
{
Eigen
::
IndexPair
<
Eigen
::
DenseIndex
>
(
1
,
0
)}};
auto
input0
=
context
.
Input
<
Tensor
>
(
"X"
);
auto
input1
=
context
.
Input
<
Tensor
>
(
"Y"
);
auto
output
=
context
.
Output
<
Tensor
>
(
0
);
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
EigenMatrix
<
T
>::
From
(
*
output
).
device
(
*
(
context
.
GetEigenDevice
<
Place
>
()))
=
EigenMatrix
<
T
>::
From
(
*
context
.
Input
<
Tensor
>
(
"X"
))
.
contract
(
EigenMatrix
<
T
>::
From
(
*
context
.
Input
<
Tensor
>
(
"Y"
)),
dim_pair
);
auto
X
=
EigenMatrix
<
T
>::
From
(
*
input0
);
auto
Y
=
EigenMatrix
<
T
>::
From
(
*
input1
);
auto
Z
=
EigenMatrix
<
T
>::
From
(
*
output
);
auto
place
=
*
context
.
GetEigenDevice
<
Place
>
();
Z
.
device
(
place
)
=
X
.
contract
(
Y
,
dim_pair
);
}
};
}
// namespace operators
...
...
paddle/operators/sgd_op.h
浏览文件 @
b36205e2
...
...
@@ -29,8 +29,12 @@ public:
param_out
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
EigenVector
<
T
>::
Flatten
(
*
param_out
).
device
(
*
(
ctx
.
GetEigenDevice
<
Place
>
()))
=
EigenVector
<
T
>::
Flatten
(
*
param
)
-
lr
*
EigenVector
<
T
>::
Flatten
(
*
grad
);
auto
p
=
EigenVector
<
T
>::
Flatten
(
*
param
);
auto
g
=
EigenVector
<
T
>::
Flatten
(
*
grad
);
auto
o
=
EigenVector
<
T
>::
Flatten
(
*
param_out
);
auto
place
=
*
ctx
.
GetEigenDevice
<
Place
>
();
o
.
device
(
place
)
=
p
-
lr
*
g
;
}
};
...
...
paddle/operators/sigmoid_op.h
浏览文件 @
b36205e2
...
...
@@ -27,9 +27,11 @@ public:
auto
output
=
context
.
Output
<
Tensor
>
(
0
);
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
EigenVector
<
T
>::
Flatten
(
*
output
).
device
(
*
(
context
.
GetEigenDevice
<
Place
>
()))
=
1.0
/
(
1.0
+
(
-
1.0
*
EigenVector
<
T
>::
Flatten
(
*
input
)).
exp
());
auto
X
=
EigenVector
<
T
>::
Flatten
(
*
input
);
auto
Y
=
EigenVector
<
T
>::
Flatten
(
*
output
);
auto
place
=
*
context
.
GetEigenDevice
<
Place
>
();
Y
.
device
(
place
)
=
1.0
/
(
1.0
+
(
-
1.0
*
X
).
exp
());
}
};
}
// namespace operators
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录