Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
9137e98e
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
9137e98e
编写于
8月 02, 2018
作者:
Z
zhaojiaying01
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify unit testing of gemm and googlenet
上级
c70d0f9b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
79 addition
and
6 deletion
+79
-6
test/CMakeLists.txt
test/CMakeLists.txt
+6
-2
test/common/test_gemm_accuracy.cpp
test/common/test_gemm_accuracy.cpp
+0
-0
test/common/test_gemm_perf.cpp
test/common/test_gemm_perf.cpp
+64
-0
test/net/test_googlenet.cpp
test/net/test_googlenet.cpp
+9
-4
未找到文件。
test/CMakeLists.txt
浏览文件 @
9137e98e
...
...
@@ -114,8 +114,12 @@ else ()
target_link_libraries
(
test-softmax paddle-mobile
)
# gen test
ADD_EXECUTABLE
(
test-gemm common/test_gemm.cpp
)
target_link_libraries
(
test-gemm paddle-mobile
)
ADD_EXECUTABLE
(
test-gemm-accuracy common/test_gemm_accuracy.cpp
)
target_link_libraries
(
test-gemm-accuracy paddle-mobile
)
# gen test
ADD_EXECUTABLE
(
test-gemm-perf common/test_gemm_perf.cpp
)
target_link_libraries
(
test-gemm-perf paddle-mobile
)
# gen test
ADD_EXECUTABLE
(
test-enforce common/test_enforce.cpp
)
...
...
test/common/test_gemm.cpp
→
test/common/test_gemm
_accuracy
.cpp
浏览文件 @
9137e98e
文件已移动
test/common/test_gemm_perf.cpp
0 → 100644
浏览文件 @
9137e98e
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include <iostream>
#include "../test_helper.h"
#include "operators/math/gemm.h"
#include "operators/math/math_function.h"
#define a(i, j) a[(i)*lda + (j)]
#define b(i, j) b[(i)*ldb + (j)]
#define c1(i, j) c1[(i)*ldc + (j)]
#define m 1024
#define n 1024
#define k 1024
int
main
()
{
Tensor
aa
,
bb
,
cc
,
scale
,
bias
;
auto
aaptr
=
aa
.
mutable_data
<
float
>
({
m
,
k
});
auto
bbptr
=
bb
.
mutable_data
<
float
>
({
k
,
n
});
auto
ccptr
=
cc
.
mutable_data
<
float
>
({
m
,
n
});
auto
scaleptr
=
scale
.
mutable_data
<
float
>
({
m
});
auto
biasptr
=
bias
.
mutable_data
<
float
>
({
m
});
for
(
int
i
=
0
;
i
<
m
*
k
;
++
i
)
{
aaptr
[
i
]
=
2
;
}
for
(
int
i
=
0
;
i
<
k
*
n
;
++
i
)
{
bbptr
[
i
]
=
2
;
}
for
(
int
i
=
0
;
i
<
m
*
n
;
++
i
)
{
ccptr
[
i
]
=
2
;
}
for
(
int
i
=
0
;
i
<
m
;
++
i
)
{
scaleptr
[
i
]
=
1
;
biasptr
[
i
]
=
0
;
}
auto
time1
=
time
();
for
(
int
j
=
0
;
j
<
10
;
++
j
)
{
paddle_mobile
::
operators
::
math
::
matmul
<
float
>
(
aa
,
false
,
bb
,
false
,
static_cast
<
float
>
(
1
),
&
cc
,
static_cast
<
float
>
(
0
),
false
);
// paddle_mobile::operators::math::matmulWithBn<float>(
// aa, false, bb, false, static_cast<float>(1), &cc,
// static_cast<float>(0), true, &scale, &bias, 0);
}
auto
time2
=
time
();
std
::
cout
<<
"gemm cost :"
<<
time_diff
(
time1
,
time2
)
/
10
<<
"ms
\n
"
;
return
0
;
}
test/net/test_googlenet.cpp
浏览文件 @
9137e98e
...
...
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include <
f
stream>
#include <
io
stream>
#include "../test_helper.h"
#include "../test_include.h"
...
...
@@ -23,15 +23,20 @@ int main() {
auto
time1
=
time
();
if
(
paddle_mobile
.
Load
(
g_googlenet
,
optimize
))
{
auto
time2
=
time
();
DLOG
<<
"load cost: "
<<
time_diff
(
time1
,
time1
)
<<
"ms"
;
std
::
cout
<<
"load cost :"
<<
time_diff
(
time1
,
time2
)
<<
"ms"
<<
std
::
endl
;
std
::
vector
<
float
>
input
;
std
::
vector
<
int64_t
>
dims
{
1
,
3
,
224
,
224
};
GetInput
<
float
>
(
g_test_image_1x3x224x224
,
&
input
,
dims
);
auto
time3
=
time
();
// 预热一次
auto
vec_result
=
paddle_mobile
.
Predict
(
input
,
dims
);
auto
time3
=
time
();
for
(
int
i
=
0
;
i
<
10
;
++
i
)
{
auto
vec_result
=
paddle_mobile
.
Predict
(
input
,
dims
);
}
auto
time4
=
time
();
DLOG
<<
"predict cost :"
<<
time_diff
(
time3
,
time4
)
<<
"ms"
;
std
::
cout
<<
"predict cost :"
<<
time_diff
(
time3
,
time4
)
/
10
<<
"ms"
<<
std
::
endl
;
}
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录