Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
90326198
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看板
提交
90326198
编写于
6月 05, 2017
作者:
H
hedaoyuan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Bug fix & add test of GemmConvGradFilter.
上级
6a93f0f3
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
15 deletion
+42
-15
paddle/function/ConvOpTest.cpp
paddle/function/ConvOpTest.cpp
+40
-13
paddle/function/GemmConvOp.cpp
paddle/function/GemmConvOp.cpp
+2
-2
未找到文件。
paddle/function/ConvOpTest.cpp
浏览文件 @
90326198
...
@@ -19,11 +19,18 @@ limitations under the License. */
...
@@ -19,11 +19,18 @@ limitations under the License. */
namespace
paddle
{
namespace
paddle
{
enum
TestType
{
FORWARD_TEST
=
0
,
BACKWARD_INPUT_TEST
=
1
,
BACKWARD_FILTER_TEST
=
2
,
};
template
<
DeviceType
DType1
,
DeviceType
DType2
>
template
<
DeviceType
DType1
,
DeviceType
DType2
>
class
ConvolutionTest
{
class
ConvolutionTest
{
public:
public:
ConvolutionTest
(
const
std
::
string
&
conv1
,
ConvolutionTest
(
const
std
::
string
&
conv1
,
const
std
::
string
&
conv2
,
const
std
::
string
&
conv2
,
TestType
type
,
std
::
string
algo
=
"auto"
)
{
std
::
string
algo
=
"auto"
)
{
for
(
size_t
batchSize
:
{
1
,
32
})
{
for
(
size_t
batchSize
:
{
1
,
32
})
{
for
(
size_t
inputSize
:
{
7
,
14
,
54
})
{
for
(
size_t
inputSize
:
{
7
,
14
,
54
})
{
...
@@ -58,16 +65,31 @@ public:
...
@@ -58,16 +65,31 @@ public:
.
set
(
"groups"
,
(
size_t
)
1
)
.
set
(
"groups"
,
(
size_t
)
1
)
.
set
(
"algo"
,
algo
));
.
set
(
"algo"
,
algo
));
TensorShape
shape0
{
TensorShape
input
{
batchSize
,
inputChannels
,
inputSize
,
inputSize
};
batchSize
,
inputChannels
,
inputSize
,
inputSize
};
TensorShape
shape1
{
TensorShape
filter
{
outputChannels
,
inputChannels
,
filterSize
,
filterSize
};
outputChannels
,
inputChannels
,
filterSize
,
filterSize
};
TensorShape
shape2
{
TensorShape
output
{
batchSize
,
outputChannels
,
outputSize
,
outputSize
};
batchSize
,
outputChannels
,
outputSize
,
outputSize
};
test
.
addInputs
(
BufferArg
(
VALUE_TYPE_FLOAT
,
shape0
));
test
.
addInputs
(
BufferArg
(
VALUE_TYPE_FLOAT
,
shape1
));
if
(
type
==
FORWARD_TEST
)
{
test
.
addOutputs
(
BufferArg
(
VALUE_TYPE_FLOAT
,
shape2
));
test
.
addInputs
(
BufferArg
(
VALUE_TYPE_FLOAT
,
input
));
test
.
run
();
test
.
addInputs
(
BufferArg
(
VALUE_TYPE_FLOAT
,
filter
));
test
.
addOutputs
(
BufferArg
(
VALUE_TYPE_FLOAT
,
output
));
test
.
run
();
}
else
if
(
type
==
BACKWARD_INPUT_TEST
)
{
#if 0
test.addInputs(BufferArg(VALUE_TYPE_FLOAT, output));
test.addInputs(BufferArg(VALUE_TYPE_FLOAT, filter));
test.addOutputs(BufferArg(VALUE_TYPE_FLOAT, input));
test.run();
#endif
}
else
if
(
type
==
BACKWARD_FILTER_TEST
)
{
test
.
addInputs
(
BufferArg
(
VALUE_TYPE_FLOAT
,
output
));
test
.
addInputs
(
BufferArg
(
VALUE_TYPE_FLOAT
,
input
));
test
.
addOutputs
(
BufferArg
(
VALUE_TYPE_FLOAT
,
filter
));
test
.
run
();
}
}
}
}
}
}
}
...
@@ -78,15 +100,20 @@ public:
...
@@ -78,15 +100,20 @@ public:
}
}
};
};
TEST
(
Convolution
,
GEMM
)
{
TEST
(
Forward
,
GEMM
)
{
ConvolutionTest
<
DEVICE_TYPE_CPU
,
DEVICE_TYPE_CPU
>
test
(
"NaiveConv-CPU"
,
ConvolutionTest
<
DEVICE_TYPE_CPU
,
DEVICE_TYPE_CPU
>
test
(
"GemmConv-CPU"
);
"NaiveConv-CPU"
,
"GemmConv-CPU"
,
FORWARD_TEST
);
}
}
#ifndef PADDLE_ONLY_CPU
#ifndef PADDLE_ONLY_CPU
TEST
(
Convolution
,
GEMM2
)
{
TEST
(
Forward
,
GEMM2
)
{
ConvolutionTest
<
DEVICE_TYPE_CPU
,
DEVICE_TYPE_GPU
>
test
(
"GemmConv-CPU"
,
ConvolutionTest
<
DEVICE_TYPE_CPU
,
DEVICE_TYPE_GPU
>
test
(
"GemmConv-GPU"
);
"GemmConv-CPU"
,
"GemmConv-GPU"
,
FORWARD_TEST
);
}
TEST
(
BackwardFilter
,
GEMM
)
{
ConvolutionTest
<
DEVICE_TYPE_CPU
,
DEVICE_TYPE_GPU
>
test
(
"GemmConvGradFilter-CPU"
,
"GemmConvGradFilter-GPU"
,
BACKWARD_FILTER_TEST
);
}
}
#endif
#endif
...
...
paddle/function/GemmConvOp.cpp
浏览文件 @
90326198
...
@@ -255,9 +255,9 @@ public:
...
@@ -255,9 +255,9 @@ public:
filterGrad
+
g
*
filterOffset
,
filterGrad
+
g
*
filterOffset
,
N
);
N
);
}
}
inputData
+=
inputChannels
*
inputHeight
*
inputWidth
;
outputGrad
+=
outputChannels
*
outputHeight
*
outputWidth
;
}
}
inputData
+=
inputChannels
*
inputHeight
*
inputWidth
;
outputGrad
+=
outputChannels
*
outputHeight
*
outputWidth
;
}
}
};
};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录