Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
3ce974b9
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3ce974b9
编写于
5月 31, 2017
作者:
H
hedaoyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add group argument in ConvFunctionBase
上级
048b14a9
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
49 addition
and
34 deletion
+49
-34
paddle/function/ConvOp.h
paddle/function/ConvOp.h
+6
-0
paddle/function/ConvOpTest.cpp
paddle/function/ConvOpTest.cpp
+1
-0
paddle/function/GemmConvOp.cpp
paddle/function/GemmConvOp.cpp
+42
-34
未找到文件。
paddle/function/ConvOp.h
浏览文件 @
3ce974b9
...
...
@@ -38,6 +38,7 @@ public:
// function arguments
strides_
=
config
.
get
<
std
::
vector
<
size_t
>>
(
"strides"
);
paddings_
=
config
.
get
<
std
::
vector
<
size_t
>>
(
"paddings"
);
groups_
=
config
.
get
<
size_t
>
(
"groups"
);
// number of inputs and outputs
numInputs_
=
2
;
...
...
@@ -62,6 +63,11 @@ public:
protected:
std
::
vector
<
size_t
>
strides_
;
std
::
vector
<
size_t
>
paddings_
;
/// Group size, refer to grouped convolution in
/// Alex Krizhevsky's paper: when group=2, the first half of the
/// filters are only connected to the first half of the input channels,
/// and the second half only connected to the second half.
size_t
groups_
;
inline
int
strideH
()
const
{
return
strides_
[
0
];
}
inline
int
strideW
()
const
{
return
strides_
[
1
];
}
...
...
paddle/function/ConvOpTest.cpp
浏览文件 @
3ce974b9
...
...
@@ -55,6 +55,7 @@ public:
FuncConfig
()
.
set
(
"paddings"
,
paddings
)
.
set
(
"strides"
,
strides
)
.
set
(
"groups"
,
(
size_t
)
1
)
.
set
(
"algo"
,
algo
));
TensorShape
shape0
{
...
...
paddle/function/GemmConvOp.cpp
浏览文件 @
3ce974b9
...
...
@@ -101,19 +101,26 @@ public:
size_t
outputHeight
=
outputs
[
0
].
shape
()[
2
];
size_t
outputWidth
=
outputs
[
0
].
shape
()[
3
];
CHECK_EQ
(
inputChannels
/
groups_
,
inputs
[
1
].
shape
()[
1
]);
real
*
inputData
=
inputs
[
0
].
data
<
real
>
();
real
*
filterData
=
inputs
[
1
].
data
<
real
>
();
real
*
outputData
=
outputs
[
0
].
data
<
real
>
();
size_t
size
=
inputChannels
*
filterHeight
*
filterWidth
*
outputHeight
*
outputWidth
;
size_t
size
=
inputChannels
/
groups_
*
filterHeight
*
filterWidth
*
outputHeight
*
outputWidth
;
resizeBuffer
(
size
);
real
*
colData
=
reinterpret_cast
<
real
*>
(
memory_
->
getBuf
());
Im2ColFunctor
<
real
>
im2col
;
size_t
inputOffset
=
(
inputChannels
/
groups_
)
*
inputHeight
*
inputWidth
;
size_t
outputOffset
=
(
outputChannels
/
groups_
)
*
outputHeight
*
outputWidth
;
size_t
filterOffset
=
inputs
[
1
].
shape
().
getElements
()
/
groups_
;
for
(
size_t
i
=
0
;
i
<
batchSize
;
i
++
)
{
im2col
(
inputData
,
inputChannels
,
for
(
int
g
=
0
;
g
<
groups_
;
g
++
)
{
im2col
(
inputData
+
g
*
inputOffset
,
inputChannels
/
groups_
,
inputHeight
,
inputWidth
,
filterHeight
,
...
...
@@ -135,17 +142,18 @@ public:
N
,
K
,
1.0
f
,
filterData
,
filterData
+
g
*
filterOffset
,
K
,
colData
,
N
,
0.0
f
,
outputData
,
outputData
+
g
*
outputOffset
,
N
);
inputData
+=
inputChannels
*
inputHeight
*
inputWidth
;
outputData
+=
outputChannels
*
outputHeight
*
outputWidth
;
}
}
}
void
resizeBuffer
(
size_t
newSize
)
{
if
(
!
memory_
||
newSize
*
sizeof
(
real
)
>
memory_
->
getAllocSize
())
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录