Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
299be048
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
1 年多 前同步成功
通知
697
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
299be048
编写于
6月 13, 2019
作者:
T
tensor-tang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix mul kernel test
上级
24e4be6a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
104 addition
and
89 deletion
+104
-89
paddle/fluid/lite/kernels/arm/conv_compute_test.cc
paddle/fluid/lite/kernels/arm/conv_compute_test.cc
+15
-0
paddle/fluid/lite/kernels/arm/mul_compute_test.cc
paddle/fluid/lite/kernels/arm/mul_compute_test.cc
+89
-89
未找到文件。
paddle/fluid/lite/kernels/arm/conv_compute_test.cc
浏览文件 @
299be048
...
...
@@ -124,6 +124,20 @@ TEST(conv_arm, init) {
TEST
(
conv_arm
,
compute
)
{
DeviceInfo
::
Init
();
#if 1
for
(
auto
n
:
{
2
})
{
for
(
auto
ic
:
{
6
})
{
for
(
auto
oc
:
{
6
})
{
for
(
auto
ih
:
{
9
})
{
for
(
auto
iw
:
{
9
})
{
for
(
auto
flag_bias
:
{
false
,
true
})
{
for
(
auto
flag_relu
:
{
false
,
true
})
{
for
(
auto
depthwise
:
{
false
,
true
})
{
for
(
auto
dilation
:
{
1
})
{
for
(
auto
stride
:
{
1
,
2
})
{
for
(
auto
padding
:
{
0
,
1
,
2
})
{
for
(
auto
ks
:
{
1
,
3
,
5
})
{
#else
for
(
auto
n
:
{
1
,
2
})
{
for
(
auto
ic
:
{
6
,
32
/*, 128*/
})
{
for
(
auto
oc
:
{
6
,
32
/*, 128*/
})
{
...
...
@@ -136,6 +150,7 @@ TEST(conv_arm, compute) {
for
(
auto
stride
:
{
1
,
2
})
{
for
(
auto
padding
:
{
0
,
1
,
2
})
{
for
(
auto
ks
:
{
1
,
3
,
5
})
{
#endif
int
group
=
1
;
if
(
depthwise
)
{
// depthwise convolution ?
group
=
oc
=
ic
;
...
...
paddle/fluid/lite/kernels/arm/mul_compute_test.cc
浏览文件 @
299be048
...
...
@@ -14,7 +14,10 @@
#include "paddle/fluid/lite/kernels/arm/mul_compute.h"
#include <gtest/gtest.h>
#include <algorithm>
#include <iostream>
#include <memory>
#include <random>
#include <utility>
#include <vector>
#include "paddle/fluid/lite/arm/math/funcs.h"
...
...
@@ -25,6 +28,17 @@ namespace lite {
namespace
kernels
{
namespace
arm
{
template
<
typename
T
>
void
FillData
(
T
*
a
,
const
int
n
,
const
T
lower
=
static_cast
<
T
>
(
-
2.
f
),
const
T
upper
=
static_cast
<
T
>
(
2.
f
))
{
static
unsigned
int
seed
=
100
;
std
::
mt19937
rng
(
seed
++
);
std
::
uniform_real_distribution
<
double
>
uniform_dist
(
0
,
1
);
for
(
int
i
=
0
;
i
<
n
;
++
i
)
{
a
[
i
]
=
static_cast
<
T
>
(
uniform_dist
(
rng
)
*
(
upper
-
lower
)
+
lower
);
}
}
TEST
(
mul_arm
,
retrive_op
)
{
auto
mul
=
KernelRegistry
::
Global
().
Create
<
TARGET
(
kARM
),
PRECISION
(
kFloat
)
>
(
"mul"
);
...
...
@@ -33,114 +47,100 @@ TEST(mul_arm, retrive_op) {
}
TEST
(
mul_arm
,
init
)
{
Fc
Compute
mul
;
Mul
Compute
mul
;
ASSERT_EQ
(
mul
.
precision
(),
PRECISION
(
kFloat
));
ASSERT_EQ
(
mul
.
target
(),
TARGET
(
kARM
));
}
TEST
(
mul_arm
,
compare_test
)
{
lite
::
Tensor
x
,
w
,
b
,
out
,
ref
;
constexpr
int
batch_size
=
2
;
x
.
Resize
({
batch_size
,
3
});
w
.
Resize
({
3
,
4
});
b
.
Resize
({
1
,
4
});
out
.
Resize
({
batch_size
,
4
});
ref
.
Resize
({
batch_size
,
4
});
auto
x_data
=
x
.
mutable_data
<
float
>
();
auto
w_data
=
w
.
mutable_data
<
float
>
();
auto
b_data
=
b
.
mutable_data
<
float
>
();
auto
out_data
=
out
.
mutable_data
<
float
>
();
auto
ref_data
=
ref
.
mutable_data
<
float
>
();
for
(
int64_t
i
=
0
;
i
<
x
.
dims
().
product
();
i
++
)
{
x_data
[
i
]
=
static_cast
<
float
>
(
i
);
}
for
(
int64_t
i
=
0
;
i
<
w
.
dims
().
product
();
i
++
)
{
w_data
[
i
]
=
static_cast
<
float
>
(
i
);
}
for
(
int64_t
i
=
0
;
i
<
b
.
dims
().
product
();
i
++
)
{
b_data
[
i
]
=
static_cast
<
float
>
(
i
);
using
T
=
float
;
for
(
int
m
:
{
1
,
2
,
3
,
4
})
{
for
(
int
n
:
{
1
,
2
,
3
,
4
})
{
for
(
int
k
:
{
1
,
2
,
3
,
4
})
{
lite
::
Tensor
x
,
y
,
out
,
ref
;
x
.
Resize
({
m
,
k
});
y
.
Resize
({
k
,
n
});
out
.
Resize
({
m
,
n
});
ref
.
Resize
({
m
,
n
});
auto
*
x_data
=
x
.
mutable_data
<
T
>
();
auto
*
y_data
=
y
.
mutable_data
<
T
>
();
auto
*
out_data
=
out
.
mutable_data
<
T
>
();
auto
*
ref_data
=
ref
.
mutable_data
<
T
>
();
FillData
<
T
>
(
x_data
,
x
.
dims
().
production
());
FillData
<
T
>
(
y_data
,
y
.
dims
().
production
());
FillData
<
T
>
(
out_data
,
out
.
dims
().
production
());
FillData
<
T
>
(
ref_data
,
out
.
dims
().
production
());
MulCompute
mul
;
operators
::
MulParam
param
;
param
.
x
=
&
x
;
param
.
y
=
&
y
;
param
.
output
=
&
out
;
DeviceInfo
::
Init
();
std
::
unique_ptr
<
KernelContext
>
ctx
(
new
KernelContext
);
ctx
->
As
<
ARMContext
>
();
mul
.
SetParam
(
param
);
mul
.
SetContext
(
std
::
move
(
ctx
));
mul
.
PrepareForRun
();
mul
.
Run
();
lite
::
arm
::
math
::
mul_compute_eigen
(
x_data
,
m
,
k
,
y_data
,
k
,
n
,
ref_data
);
for
(
int
i
=
0
;
i
<
out
.
dims
().
production
();
i
++
)
{
EXPECT_NEAR
(
out_data
[
i
],
ref_data
[
i
],
1e-3
);
}
}
}
}
}
TEST
(
mul_arm
,
num_col_dims
)
{
using
T
=
float
;
lite
::
arm
::
math
::
fc_compute_eigen
(
x_data
,
batch_size
,
3
,
//
w_data
,
3
,
4
,
//
b_data
,
ref_data
);
lite
::
Tensor
x
,
y
,
out
,
ref
;
x
.
Resize
({
2
,
3
,
4
});
y
.
Resize
({
3
,
4
,
5
});
out
.
Resize
({
2
,
5
});
ref
.
Resize
({
2
,
5
});
// mul compute kernel
FcCompute
mul
;
operators
::
FcParam
param
;
auto
*
x_data
=
x
.
mutable_data
<
T
>
();
auto
*
y_data
=
y
.
mutable_data
<
T
>
();
auto
*
out_data
=
out
.
mutable_data
<
T
>
();
auto
*
ref_data
=
ref
.
mutable_data
<
T
>
();
param
.
in_num_col_dims
=
1
;
param
.
input
=
&
x
;
param
.
w
=
&
w
;
param
.
bias
=
&
b
;
FillData
<
T
>
(
x_data
,
x
.
dims
().
production
());
FillData
<
T
>
(
y_data
,
y
.
dims
().
production
());
FillData
<
T
>
(
out_data
,
out
.
dims
().
production
());
FillData
<
T
>
(
ref_data
,
out
.
dims
().
production
());
MulCompute
mul
;
operators
::
MulParam
param
;
param
.
x
=
&
x
;
param
.
y
=
&
y
;
param
.
output
=
&
out
;
param
.
in_mat_dims
=
x
.
dims
();
param
.
x_num_col_dims
=
1
;
param
.
y_num_col_dims
=
2
;
DeviceInfo
::
Init
();
std
::
unique_ptr
<
KernelContext
>
ctx
(
new
KernelContext
);
ctx
->
As
<
ARMContext
>
();
mul
.
SetParam
(
param
);
mul
.
SetContext
(
std
::
move
(
ctx
));
mul
.
Run
();
mul
.
PrepareFor
Run
();
VLOG
(
3
)
<<
"output vs ref"
;
for
(
int
i
=
0
;
i
<
out
.
dims
().
product
();
i
++
)
{
VLOG
(
3
)
<<
out_data
[
i
]
<<
" vs "
<<
ref_data
[
i
];
}
for
(
int
i
=
0
;
i
<
out
.
dims
().
product
();
++
i
)
{
EXPECT_NEAR
(
out_data
[
i
],
ref_data
[
i
],
1e-5
);
}
}
mul
.
Run
();
TEST
(
mul_arm
,
num_col_dims
)
{
FcCompute
mul
;
operators
::
FcParam
param
;
lite
::
Tensor
x
;
lite
::
Tensor
w
;
lite
::
Tensor
bias
;
lite
::
Tensor
output
;
x
.
Resize
({
1
,
2
,
3
});
w
.
Resize
({
3
,
4
});
bias
.
Resize
({
1
,
4
});
output
.
Resize
({
2
,
4
});
auto
*
x_data
=
x
.
mutable_data
<
float
>
();
auto
*
w_data
=
w
.
mutable_data
<
float
>
();
auto
*
bias_data
=
bias
.
mutable_data
<
float
>
();
auto
*
output_data
=
output
.
mutable_data
<
float
>
();
for
(
int64_t
i
=
0
;
i
<
x
.
dims
().
product
();
i
++
)
{
x_data
[
i
]
=
static_cast
<
float
>
(
i
);
}
for
(
int64_t
i
=
0
;
i
<
w
.
dims
().
product
();
i
++
)
{
w_data
[
i
]
=
static_cast
<
float
>
(
i
);
}
for
(
int64_t
i
=
0
;
i
<
bias
.
dims
().
product
();
i
++
)
{
bias_data
[
i
]
=
static_cast
<
float
>
(
i
);
lite
::
arm
::
math
::
mul_compute_eigen
(
x_data
,
2
,
12
,
y_data
,
12
,
5
,
ref_data
);
for
(
int
i
=
0
;
i
<
out
.
dims
().
production
();
i
++
)
{
EXPECT_NEAR
(
out_data
[
i
],
ref_data
[
i
],
1e-3
);
}
for
(
int64_t
i
=
0
;
i
<
output
.
dims
().
product
();
i
++
)
{
output_data
[
i
]
=
static_cast
<
float
>
(
i
);
}
param
.
in_num_col_dims
=
2
;
param
.
input
=
&
x
;
param
.
w
=
&
w
;
param
.
bias
=
&
bias
;
param
.
output
=
&
output
;
param
.
in_mat_dims
=
x
.
dims
();
std
::
unique_ptr
<
KernelContext
>
ctx
(
new
KernelContext
);
ctx
->
As
<
ARMContext
>
();
DeviceInfo
::
Init
();
mul
.
SetParam
(
param
);
mul
.
SetContext
(
std
::
move
(
ctx
));
mul
.
Run
();
}
}
// namespace arm
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录