Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OPTHREE
Paddle
提交
28db1491
P
Paddle
项目概览
OPTHREE
/
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,发现更多精彩内容 >>
提交
28db1491
编写于
8月 02, 2017
作者:
G
gangliao
提交者:
GitHub
8月 02, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3179 from gangliao/eigen_refine
Refine compute code in operators
上级
c46aed57
43528c4c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
32 addition
and
13 deletion
+32
-13
paddle/operators/add_op.h
paddle/operators/add_op.h
+7
-3
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
-2
未找到文件。
paddle/operators/add_op.h
浏览文件 @
28db1491
...
@@ -28,9 +28,13 @@ public:
...
@@ -28,9 +28,13 @@ public:
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
EigenVector
<
T
>::
Flatten
(
*
output
).
device
(
context
.
GetEigenDevice
<
Place
>
())
=
auto
X
=
EigenVector
<
T
>::
Flatten
(
*
input0
);
framework
::
EigenVector
<
T
>::
Flatten
(
*
input0
)
+
auto
Y
=
EigenVector
<
T
>::
Flatten
(
*
input1
);
framework
::
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
浏览文件 @
28db1491
...
@@ -27,8 +27,11 @@ public:
...
@@ -27,8 +27,11 @@ public:
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
EigenScalar
<
T
>::
From
(
*
output
).
device
(
context
.
GetEigenDevice
<
Place
>
())
=
auto
X
=
EigenVector
<
T
>::
Flatten
(
*
input
);
EigenVector
<
T
>::
Flatten
(
*
input
).
mean
();
auto
y
=
EigenScalar
<
T
>::
From
(
*
output
);
auto
place
=
context
.
GetEigenDevice
<
Place
>
();
y
.
device
(
place
)
=
X
.
mean
();
}
}
};
};
...
...
paddle/operators/mul_op.h
浏览文件 @
28db1491
...
@@ -26,13 +26,18 @@ public:
...
@@ -26,13 +26,18 @@ public:
Eigen
::
array
<
Eigen
::
IndexPair
<
Eigen
::
DenseIndex
>
,
1
>
dim_pair
=
{
Eigen
::
array
<
Eigen
::
IndexPair
<
Eigen
::
DenseIndex
>
,
1
>
dim_pair
=
{
{
Eigen
::
IndexPair
<
Eigen
::
DenseIndex
>
(
1
,
0
)}};
{
Eigen
::
IndexPair
<
Eigen
::
DenseIndex
>
(
1
,
0
)}};
auto
input0
=
context
.
Input
<
Tensor
>
(
"X"
);
auto
input1
=
context
.
Input
<
Tensor
>
(
"Y"
);
auto
output
=
context
.
Output
<
Tensor
>
(
0
);
auto
output
=
context
.
Output
<
Tensor
>
(
0
);
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
EigenMatrix
<
T
>::
From
(
*
output
).
device
(
context
.
GetEigenDevice
<
Place
>
())
=
auto
X
=
EigenMatrix
<
T
>::
From
(
*
input0
);
EigenMatrix
<
T
>::
From
(
*
context
.
Input
<
Tensor
>
(
"X"
))
auto
Y
=
EigenMatrix
<
T
>::
From
(
*
input1
);
.
contract
(
EigenMatrix
<
T
>::
From
(
*
context
.
Input
<
Tensor
>
(
"Y"
)),
auto
Z
=
EigenMatrix
<
T
>::
From
(
*
output
);
dim_pair
);
auto
place
=
context
.
GetEigenDevice
<
Place
>
();
Z
.
device
(
place
)
=
X
.
contract
(
Y
,
dim_pair
);
}
}
};
};
}
// namespace operators
}
// namespace operators
...
...
paddle/operators/sgd_op.h
浏览文件 @
28db1491
...
@@ -29,8 +29,12 @@ public:
...
@@ -29,8 +29,12 @@ public:
param_out
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
param_out
->
mutable_data
<
T
>
(
ctx
.
GetPlace
());
EigenVector
<
T
>::
Flatten
(
*
param_out
).
device
(
ctx
.
GetEigenDevice
<
Place
>
())
=
auto
p
=
EigenVector
<
T
>::
Flatten
(
*
param
);
EigenVector
<
T
>::
Flatten
(
*
param
)
-
lr
*
EigenVector
<
T
>::
Flatten
(
*
grad
);
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
浏览文件 @
28db1491
...
@@ -27,8 +27,11 @@ public:
...
@@ -27,8 +27,11 @@ public:
auto
output
=
context
.
Output
<
Tensor
>
(
0
);
auto
output
=
context
.
Output
<
Tensor
>
(
0
);
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
output
->
mutable_data
<
T
>
(
context
.
GetPlace
());
EigenVector
<
T
>::
Flatten
(
*
output
).
device
(
context
.
GetEigenDevice
<
Place
>
())
=
auto
X
=
EigenVector
<
T
>::
Flatten
(
*
input
);
1.0
/
(
1.0
+
(
-
1.0
*
EigenVector
<
T
>::
Flatten
(
*
input
)).
exp
());
auto
Y
=
EigenVector
<
T
>::
Flatten
(
*
output
);
auto
place
=
context
.
GetEigenDevice
<
Place
>
();
Y
.
device
(
place
)
=
1.0
/
(
1.0
+
(
-
1.0
*
X
).
exp
());
}
}
};
};
}
// namespace operators
}
// namespace operators
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录