Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
0d35f17b
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
332
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看板
提交
0d35f17b
编写于
5月 24, 2018
作者:
朔-望
提交者:
GitHub
5月 24, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #251 from allonli/develop
/test contains many source files check style
上级
1620fd1b
942f112a
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
97 addition
and
85 deletion
+97
-85
.pre-commit-config.yaml
.pre-commit-config.yaml
+17
-17
README.md
README.md
+4
-0
test/common/test_log.cpp
test/common/test_log.cpp
+0
-1
test/framework/executor_for_test.cpp
test/framework/executor_for_test.cpp
+6
-8
test/framework/executor_for_test.h
test/framework/executor_for_test.h
+6
-6
test/framework/test_load.cpp
test/framework/test_load.cpp
+4
-4
test/framework/test_optimize.cpp
test/framework/test_optimize.cpp
+3
-7
test/operators/test_batchnorm_op.cpp
test/operators/test_batchnorm_op.cpp
+9
-7
test/operators/test_concat_op.cpp
test/operators/test_concat_op.cpp
+8
-7
test/operators/test_cov_op.cpp
test/operators/test_cov_op.cpp
+5
-6
test/operators/test_elementwise_add_op.cpp
test/operators/test_elementwise_add_op.cpp
+7
-6
test/operators/test_lrn_op.cpp
test/operators/test_lrn_op.cpp
+7
-6
test/operators/test_mul_op.cpp
test/operators/test_mul_op.cpp
+7
-6
test/test_helper.h
test/test_helper.h
+6
-1
test/test_include.h
test/test_include.h
+8
-3
未找到文件。
.pre-commit-config.yaml
浏览文件 @
0d35f17b
...
@@ -3,9 +3,9 @@ repos:
...
@@ -3,9 +3,9 @@ repos:
sha
:
v1.0.1
sha
:
v1.0.1
hooks
:
hooks
:
-
id
:
remove-crlf
-
id
:
remove-crlf
files
:
(src).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
files
:
(src
/
).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
-
id
:
remove-tabs
-
id
:
remove-tabs
files
:
(
src
).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
files
:
(
test/|src/
).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|cu|h|hpp|hxx)$
-
repo
:
https://github.com/pre-commit/pre-commit-hooks
-
repo
:
https://github.com/pre-commit/pre-commit-hooks
sha
:
5bf6c09bfa1297d3692cadd621ef95f1284e33c0
sha
:
5bf6c09bfa1297d3692cadd621ef95f1284e33c0
...
@@ -16,9 +16,9 @@ repos:
...
@@ -16,9 +16,9 @@ repos:
-
id
:
detect-private-key
-
id
:
detect-private-key
files
:
(?!.*tar.gz)^.*$
files
:
(?!.*tar.gz)^.*$
-
id
:
end-of-file-fixer
-
id
:
end-of-file-fixer
files
:
(
src
).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|h|hpp|hxx)$
files
:
(
test/|src/
).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|h|hpp|hxx)$
-
id
:
trailing-whitespace
-
id
:
trailing-whitespace
files
:
(
src
).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|h|hpp|hxx)$
files
:
(
test/|src/
).*\.(md|py|mm|swift|java|c|cc|cxx|cpp|h|hpp|hxx)$
-
repo
:
local
-
repo
:
local
hooks
:
hooks
:
...
@@ -26,7 +26,7 @@ repos:
...
@@ -26,7 +26,7 @@ repos:
name
:
copyright
name
:
copyright
entry
:
python ./tools/pre-commit.hooks/copyright.hook
entry
:
python ./tools/pre-commit.hooks/copyright.hook
language
:
system
language
:
system
files
:
(
src
).*\.(c|cc|cxx|cpp|h|hpp|hxx|py)$
files
:
(
test/|src/
).*\.(c|cc|cxx|cpp|h|hpp|hxx|py)$
exclude
:
(?!.*third_party)^.*$ | (?!.*book)^.*$
exclude
:
(?!.*third_party)^.*$ | (?!.*book)^.*$
-
repo
:
local
-
repo
:
local
...
@@ -36,17 +36,7 @@ repos:
...
@@ -36,17 +36,7 @@ repos:
description
:
Format files with ClangFormat.
description
:
Format files with ClangFormat.
entry
:
bash ./tools/pre-commit.hooks/clang-format.hook -i
entry
:
bash ./tools/pre-commit.hooks/clang-format.hook -i
language
:
system
language
:
system
files
:
(src).*\.(c|cc|cxx|cpp|h|hpp|hxx)$
files
:
(test/|src/).*\.(c|cc|cxx|cpp|h|hpp|hxx)$
#
#- repo: local
# hooks:
# - id: clang-tidy
# name: clang-tidy
# description: Check C++ code style using clang-tidy.
# entry: bash ./tools/pre-commit.hooks/.clang-tidy.hook -i
# language: system
# files: (src).*\.(c|cc|cxx|cpp|h|hpp|hxx)$
-
repo
:
local
-
repo
:
local
hooks
:
hooks
:
...
@@ -55,6 +45,16 @@ repos:
...
@@ -55,6 +45,16 @@ repos:
description
:
Check C++ code style using cpplint.
description
:
Check C++ code style using cpplint.
entry
:
bash ./tools/pre-commit.hooks/cpplint.hook
entry
:
bash ./tools/pre-commit.hooks/cpplint.hook
language
:
system
language
:
system
files
:
(test
|src
).*\.(c|cc|cxx|cpp|h|hpp|hxx)$
files
:
(test
/|src/
).*\.(c|cc|cxx|cpp|h|hpp|hxx)$
exclude
:
(?!.*third_party)^.*$ | (?!.*book)^.*$i | *\.pb\.cpp
exclude
:
(?!.*third_party)^.*$ | (?!.*book)^.*$i | *\.pb\.cpp
#
#- repo: local
# hooks:
# - id: clang-tidy
# name: clang-tidy
# description: Check C++ code style using clang-tidy.
# entry: bash ./tools/pre-commit.hooks/.clang-tidy.hook -i
# language: system
# files: (src).*\.(c|cc|cxx|cpp|h|hpp|hxx)$
README.md
浏览文件 @
0d35f17b
...
@@ -6,8 +6,12 @@
...
@@ -6,8 +6,12 @@
This project is used to develop the next version deep learning freamwork for mobile device.
This project is used to develop the next version deep learning freamwork for mobile device.
# Development
[
Used model in development
](
https://mms-mis.cdn.bcebos.com/paddle-mobile/models.zip
)
## Old Version of Mobile-Deep-Learning
## Old Version of Mobile-Deep-Learning
The old version of MDL was I moved to here
[
Mobile-Deep-Learning
](
https://github.com/allonli/mobile-deep-learning
)
The old version of MDL was I moved to here
[
Mobile-Deep-Learning
](
https://github.com/allonli/mobile-deep-learning
)
test/common/test_log.cpp
浏览文件 @
0d35f17b
...
@@ -15,7 +15,6 @@ limitations under the License. */
...
@@ -15,7 +15,6 @@ limitations under the License. */
#include "common/log.h"
#include "common/log.h"
int
main
()
{
int
main
()
{
DLOGF
(
"DASJFDAFJ%d -- %f"
,
12345
,
344.234
);
DLOGF
(
"DASJFDAFJ%d -- %f"
,
12345
,
344.234
);
LOGF
(
paddle_mobile
::
kLOG_DEBUG
,
"DASJFDAFJ%d -- %f"
,
12345
,
344.234
);
LOGF
(
paddle_mobile
::
kLOG_DEBUG
,
"DASJFDAFJ%d -- %f"
,
12345
,
344.234
);
...
...
test/framework/executor_for_test.cpp
浏览文件 @
0d35f17b
...
@@ -12,13 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,13 +12,12 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "executor_for_test.h"
#include "
framework/
executor_for_test.h"
template
<
typename
DeviceType
,
typename
OpType
>
template
<
typename
DeviceType
,
typename
OpType
>
Executor4Test
<
DeviceType
,
OpType
>::
Executor4Test
(
const
Program
<
DeviceType
>
p
,
Executor4Test
<
DeviceType
,
OpType
>::
Executor4Test
(
const
Program
<
DeviceType
>
p
,
std
::
string
op_type
)
std
::
string
op_type
)
:
Executor
<
DeviceType
>
(
p
)
{
:
Executor
<
DeviceType
>
(
p
)
{
if
(
this
->
program_
.
originProgram
==
nullptr
)
{
if
(
this
->
program_
.
originProgram
==
nullptr
)
{
LOG
(
paddle_mobile
::
LogLevel
::
kLOG_ERROR
)
LOG
(
paddle_mobile
::
LogLevel
::
kLOG_ERROR
)
<<
"to_predict_program_ == nullptr"
;
<<
"to_predict_program_ == nullptr"
;
...
@@ -27,7 +26,7 @@ Executor4Test<DeviceType, OpType>::Executor4Test(const Program<DeviceType> p,
...
@@ -27,7 +26,7 @@ Executor4Test<DeviceType, OpType>::Executor4Test(const Program<DeviceType> p,
const
std
::
vector
<
std
::
shared_ptr
<
BlockDesc
>>
blocks
=
const
std
::
vector
<
std
::
shared_ptr
<
BlockDesc
>>
blocks
=
this
->
to_predict_program_
->
Blocks
();
this
->
to_predict_program_
->
Blocks
();
for
(
std
::
shared_ptr
<
BlockDesc
>
block_desc
:
blocks
)
{
for
(
std
::
shared_ptr
<
BlockDesc
>
block_desc
:
blocks
)
{
std
::
vector
<
std
::
shared_ptr
<
OpDesc
>>
ops
=
block_desc
->
Ops
();
std
::
vector
<
std
::
shared_ptr
<
OpDesc
>>
ops
=
block_desc
->
Ops
();
for
(
std
::
shared_ptr
<
OpDesc
>
op
:
ops
)
{
for
(
std
::
shared_ptr
<
OpDesc
>
op
:
ops
)
{
if
(
op
->
Type
()
==
op_type
)
{
if
(
op
->
Type
()
==
op_type
)
{
...
@@ -43,9 +42,8 @@ Executor4Test<DeviceType, OpType>::Executor4Test(const Program<DeviceType> p,
...
@@ -43,9 +42,8 @@ Executor4Test<DeviceType, OpType>::Executor4Test(const Program<DeviceType> p,
}
}
template
<
typename
DeviceType
,
typename
OpType
>
template
<
typename
DeviceType
,
typename
OpType
>
std
::
shared_ptr
<
Tensor
>
std
::
shared_ptr
<
Tensor
>
Executor4Test
<
DeviceType
,
OpType
>::
predict
(
Executor4Test
<
DeviceType
,
OpType
>::
predict
(
const
Tensor
&
t
,
std
::
string
input
,
const
Tensor
&
t
,
std
::
string
input
,
std
::
string
output
,
const
DDim
&
dDim
)
{
std
::
string
output
,
DDim
&
dDim
)
{
auto
scope
=
this
->
program_
.
scope
;
auto
scope
=
this
->
program_
.
scope
;
Variable
*
g_feed_value
=
scope
->
Var
(
input
);
Variable
*
g_feed_value
=
scope
->
Var
(
input
);
auto
tensor
=
g_feed_value
->
GetMutable
<
Tensor
>
();
auto
tensor
=
g_feed_value
->
GetMutable
<
Tensor
>
();
...
@@ -68,5 +66,5 @@ template class Executor4Test<
...
@@ -68,5 +66,5 @@ template class Executor4Test<
paddle_mobile
::
CPU
,
paddle_mobile
::
CPU
,
paddle_mobile
::
operators
::
PoolOp
<
paddle_mobile
::
CPU
,
float
>
>
;
paddle_mobile
::
operators
::
PoolOp
<
paddle_mobile
::
CPU
,
float
>
>
;
template
class
Executor4Test
<
template
class
Executor4Test
<
paddle_mobile
::
CPU
,
paddle_mobile
::
CPU
,
paddle_mobile
::
operators
::
SoftmaxOp
<
paddle_mobile
::
CPU
,
float
>
>
;
paddle_mobile
::
operators
::
SoftmaxOp
<
paddle_mobile
::
CPU
,
float
>
>
;
test/framework/executor_for_test.h
浏览文件 @
0d35f17b
...
@@ -21,20 +21,20 @@ limitations under the License. */
...
@@ -21,20 +21,20 @@ limitations under the License. */
#include "operators/pool_op.h"
#include "operators/pool_op.h"
#include "operators/softmax_op.h"
#include "operators/softmax_op.h"
using
paddle_mobile
::
framework
::
Tensor
;
using
paddle_mobile
::
framework
::
BlockDesc
;
using
paddle_mobile
::
framework
::
LoDTensor
;
using
std
::
string
;
using
paddle_mobile
::
framework
::
DDim
;
using
paddle_mobile
::
framework
::
DDim
;
using
paddle_mobile
::
framework
::
Executor
;
using
paddle_mobile
::
framework
::
Executor
;
using
paddle_mobile
::
framework
::
Program
;
using
paddle_mobile
::
framework
::
LoDTensor
;
using
paddle_mobile
::
framework
::
BlockDesc
;
using
paddle_mobile
::
framework
::
OpDesc
;
using
paddle_mobile
::
framework
::
OpDesc
;
using
paddle_mobile
::
framework
::
Program
;
using
paddle_mobile
::
framework
::
Tensor
;
using
paddle_mobile
::
framework
::
Variable
;
using
paddle_mobile
::
framework
::
Variable
;
using
std
::
string
;
template
<
typename
DeviceType
,
typename
OpType
>
template
<
typename
DeviceType
,
typename
OpType
>
class
Executor4Test
:
public
Executor
<
DeviceType
>
{
class
Executor4Test
:
public
Executor
<
DeviceType
>
{
public:
public:
Executor4Test
(
Program
<
DeviceType
>
p
,
string
op_type
);
Executor4Test
(
Program
<
DeviceType
>
p
,
string
op_type
);
std
::
shared_ptr
<
Tensor
>
predict
(
const
Tensor
&
t
,
string
input
,
string
output
,
std
::
shared_ptr
<
Tensor
>
predict
(
const
Tensor
&
t
,
string
input
,
string
output
,
DDim
&
dDim
);
const
DDim
&
dDim
);
};
};
test/framework/test_load.cpp
浏览文件 @
0d35f17b
...
@@ -12,13 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,13 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "io.h"
#include "
/
io.h"
int
main
()
{
int
main
()
{
paddle_mobile
::
Loader
<
paddle_mobile
::
CPU
>
loader
;
paddle_mobile
::
Loader
<
paddle_mobile
::
CPU
>
loader
;
//../../../test/models/googlenet
//
../../../test/models/googlenet
//../../../test/models/mobilenet
//
../../../test/models/mobilenet
auto
program
=
loader
.
Load
(
std
::
string
(
"../models/googlenet"
));
auto
program
=
loader
.
Load
(
std
::
string
(
"../models/googlenet"
));
return
0
;
return
0
;
}
}
\ No newline at end of file
test/framework/test_optimize.cpp
浏览文件 @
0d35f17b
...
@@ -12,23 +12,19 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,23 +12,19 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "/io.h"
#include "framework/program/program-optimize/node.h"
#include "framework/program/program-optimize/node.h"
#include "framework/program/program-optimize/program_optimize.h"
#include "framework/program/program-optimize/program_optimize.h"
#include "io.h"
using
namespace
paddle_mobile
;
using
namespace
paddle_mobile
::
framework
;
int
main
()
{
int
main
()
{
Loader
<
paddle_mobile
::
CPU
>
loader
;
Loader
<
paddle_mobile
::
CPU
>
loader
;
// "../../../test/models/googlenet"
// "../../../test/models/googlenet"
auto
program
=
loader
.
Load
(
"../models/googlenet"
);
auto
program
=
loader
.
Load
(
"../models/googlenet"
);
ProgramOptimize
optimize
;
ProgramOptimize
optimize
;
// program.originProgram->Description("origin");
// program.originProgram->Description("origin");
auto
optimize_program
=
optimize
.
FushionOptimize
(
program
.
originProgram
);
auto
optimize_program
=
optimize
.
FushionOptimize
(
program
.
originProgram
);
if
(
optimize_program
!=
nullptr
)
{
if
(
optimize_program
!=
nullptr
)
{
// optimize_program->Description("optimize");
// optimize_program->Description("optimize");
}
else
{
}
else
{
LOG
(
kLOG_ERROR
)
<<
"optimize_program is null"
;
LOG
(
kLOG_ERROR
)
<<
"optimize_program is null"
;
}
}
...
...
test/operators/test_batchnorm_op.cpp
浏览文件 @
0d35f17b
...
@@ -19,8 +19,9 @@ limitations under the License. */
...
@@ -19,8 +19,9 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
paddle_mobile
{
namespace
framework
{
namespace
framework
{
template
<
typename
Dtype
>
class
TestBatchNormOp
{
template
<
typename
Dtype
>
public:
class
TestBatchNormOp
{
public:
explicit
TestBatchNormOp
(
const
Program
<
Dtype
>
p
)
:
program_
(
p
)
{
explicit
TestBatchNormOp
(
const
Program
<
Dtype
>
p
)
:
program_
(
p
)
{
if
(
use_optimize_
)
{
if
(
use_optimize_
)
{
to_predict_program_
=
program_
.
optimizeProgram
;
to_predict_program_
=
program_
.
optimizeProgram
;
...
@@ -59,8 +60,9 @@ public:
...
@@ -59,8 +60,9 @@ public:
}
}
}
}
std
::
shared_ptr
<
Tensor
>
predict_bn
(
Tensor
&
t1
,
Tensor
&
t2
,
Tensor
&
t3
,
std
::
shared_ptr
<
Tensor
>
predict_bn
(
const
Tensor
&
t1
,
const
Tensor
&
t2
,
Tensor
&
t4
,
Tensor
&
t5
)
{
const
Tensor
&
t3
,
const
Tensor
&
t4
,
const
Tensor
&
t5
)
{
// feed
// feed
auto
scope
=
program_
.
scope
;
auto
scope
=
program_
.
scope
;
Variable
*
x1_feed_value
=
scope
->
Var
(
"conv2d_0.tmp_0"
);
Variable
*
x1_feed_value
=
scope
->
Var
(
"conv2d_0.tmp_0"
);
...
@@ -96,7 +98,7 @@ public:
...
@@ -96,7 +98,7 @@ public:
return
out_tensor
;
return
out_tensor
;
}
}
private:
private:
const
framework
::
Program
<
Dtype
>
program_
;
const
framework
::
Program
<
Dtype
>
program_
;
std
::
shared_ptr
<
ProgramDesc
>
to_predict_program_
;
std
::
shared_ptr
<
ProgramDesc
>
to_predict_program_
;
std
::
map
<
framework
::
BlockDesc
,
std
::
map
<
framework
::
BlockDesc
,
...
@@ -117,8 +119,8 @@ private:
...
@@ -117,8 +119,8 @@ private:
};
};
template
class
TestBatchNormOp
<
CPU
>;
template
class
TestBatchNormOp
<
CPU
>;
}
// namespace framework
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace paddle_mobile
int
main
()
{
int
main
()
{
DLOG
<<
"----------**********----------"
;
DLOG
<<
"----------**********----------"
;
...
...
test/operators/test_concat_op.cpp
浏览文件 @
0d35f17b
...
@@ -19,8 +19,9 @@ limitations under the License. */
...
@@ -19,8 +19,9 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
paddle_mobile
{
namespace
framework
{
namespace
framework
{
template
<
typename
Dtype
>
class
TestConcatOp
{
template
<
typename
Dtype
>
public:
class
TestConcatOp
{
public:
explicit
TestConcatOp
(
const
Program
<
Dtype
>
p
)
:
program_
(
p
)
{
explicit
TestConcatOp
(
const
Program
<
Dtype
>
p
)
:
program_
(
p
)
{
if
(
use_optimize_
)
{
if
(
use_optimize_
)
{
to_predict_program_
=
program_
.
optimizeProgram
;
to_predict_program_
=
program_
.
optimizeProgram
;
...
@@ -55,8 +56,8 @@ public:
...
@@ -55,8 +56,8 @@ public:
}
}
}
}
std
::
shared_ptr
<
Tensor
>
predict_concat
(
Tensor
&
t1
,
Tensor
&
t2
,
Tensor
&
t3
,
std
::
shared_ptr
<
Tensor
>
predict_concat
(
const
Tensor
&
t1
,
const
Tensor
&
t2
,
Tensor
&
t4
)
{
const
Tensor
&
t3
,
const
Tensor
&
t4
)
{
// feed
// feed
auto
scope
=
program_
.
scope
;
auto
scope
=
program_
.
scope
;
Variable
*
x1_feed_value
=
scope
->
Var
(
"conv2d_3.tmp_1"
);
Variable
*
x1_feed_value
=
scope
->
Var
(
"conv2d_3.tmp_1"
);
...
@@ -88,7 +89,7 @@ public:
...
@@ -88,7 +89,7 @@ public:
return
out_tensor
;
return
out_tensor
;
}
}
private:
private:
const
framework
::
Program
<
Dtype
>
program_
;
const
framework
::
Program
<
Dtype
>
program_
;
std
::
shared_ptr
<
ProgramDesc
>
to_predict_program_
;
std
::
shared_ptr
<
ProgramDesc
>
to_predict_program_
;
std
::
map
<
framework
::
BlockDesc
,
std
::
map
<
framework
::
BlockDesc
,
...
@@ -109,8 +110,8 @@ private:
...
@@ -109,8 +110,8 @@ private:
};
};
template
class
TestConcatOp
<
CPU
>;
template
class
TestConcatOp
<
CPU
>;
}
// namespace framework
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace paddle_mobile
int
main
()
{
int
main
()
{
DLOG
<<
"----------**********----------"
;
DLOG
<<
"----------**********----------"
;
...
...
test/operators/test_cov_op.cpp
浏览文件 @
0d35f17b
...
@@ -12,13 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,13 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include
"../framework/executor_for_test.h"
#include
<io>
#include "
../test_helper
.h"
#include "
framework/executor_for_test
.h"
#include "
./io
.h"
#include "
framework/test_helper
.h"
int
main
()
{
int
main
()
{
paddle_mobile
::
Loader
<
paddle_mobile
::
CPU
>
loader
;
paddle_mobile
::
Loader
<
paddle_mobile
::
CPU
>
loader
;
//../models/image_classification_resnet.inference.model
//
../models/image_classification_resnet.inference.model
auto
program
=
loader
.
Load
(
std
::
string
(
"../models/googlenet"
));
auto
program
=
loader
.
Load
(
std
::
string
(
"../models/googlenet"
));
if
(
program
.
originProgram
==
nullptr
)
{
if
(
program
.
originProgram
==
nullptr
)
{
DLOG
<<
"program file read fail"
;
DLOG
<<
"program file read fail"
;
...
@@ -32,8 +32,7 @@ int main() {
...
@@ -32,8 +32,7 @@ int main() {
SetupTensor
<
float
>
(
&
input
,
{
1
,
3
,
32
,
32
},
static_cast
<
float
>
(
0
),
SetupTensor
<
float
>
(
&
input
,
{
1
,
3
,
32
,
32
},
static_cast
<
float
>
(
0
),
static_cast
<
float
>
(
1
));
static_cast
<
float
>
(
1
));
auto
out_ddim
=
paddle_mobile
::
framework
::
make_ddim
({
1
,
64
,
56
,
56
});
auto
out_ddim
=
paddle_mobile
::
framework
::
make_ddim
({
1
,
64
,
56
,
56
});
auto
output
=
auto
output
=
executor
.
predict
(
input
,
"data"
,
"conv2d_0.tmp_0"
,
out_ddim
);
executor
.
predict
(
input
,
"data"
,
"conv2d_0.tmp_0"
,
out_ddim
);
auto
output_ptr
=
output
->
data
<
float
>
();
auto
output_ptr
=
output
->
data
<
float
>
();
for
(
int
j
=
0
;
j
<
output
->
numel
();
++
j
)
{
for
(
int
j
=
0
;
j
<
output
->
numel
();
++
j
)
{
...
...
test/operators/test_elementwise_add_op.cpp
浏览文件 @
0d35f17b
...
@@ -19,8 +19,9 @@ limitations under the License. */
...
@@ -19,8 +19,9 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
paddle_mobile
{
namespace
framework
{
namespace
framework
{
template
<
typename
Dtype
>
class
TestElementwiseAddOp
{
template
<
typename
Dtype
>
public:
class
TestElementwiseAddOp
{
public:
explicit
TestElementwiseAddOp
(
const
Program
<
Dtype
>
p
)
:
program_
(
p
)
{
explicit
TestElementwiseAddOp
(
const
Program
<
Dtype
>
p
)
:
program_
(
p
)
{
if
(
use_optimize_
)
{
if
(
use_optimize_
)
{
to_predict_program_
=
program_
.
optimizeProgram
;
to_predict_program_
=
program_
.
optimizeProgram
;
...
@@ -59,7 +60,7 @@ public:
...
@@ -59,7 +60,7 @@ public:
}
}
}
}
std
::
shared_ptr
<
Tensor
>
predict_add
(
Tensor
&
t1
,
Tensor
&
t2
)
{
std
::
shared_ptr
<
Tensor
>
predict_add
(
const
Tensor
&
t1
,
const
Tensor
&
t2
)
{
// feed
// feed
auto
scope
=
program_
.
scope
;
auto
scope
=
program_
.
scope
;
Variable
*
x_feed_value
=
scope
->
Var
(
"batch_norm_2.tmp_2"
);
Variable
*
x_feed_value
=
scope
->
Var
(
"batch_norm_2.tmp_2"
);
...
@@ -83,7 +84,7 @@ public:
...
@@ -83,7 +84,7 @@ public:
return
out_tensor
;
return
out_tensor
;
}
}
private:
private:
const
framework
::
Program
<
Dtype
>
program_
;
const
framework
::
Program
<
Dtype
>
program_
;
std
::
shared_ptr
<
ProgramDesc
>
to_predict_program_
;
std
::
shared_ptr
<
ProgramDesc
>
to_predict_program_
;
std
::
map
<
framework
::
BlockDesc
,
std
::
map
<
framework
::
BlockDesc
,
...
@@ -103,8 +104,8 @@ private:
...
@@ -103,8 +104,8 @@ private:
};
};
template
class
TestElementwiseAddOp
<
CPU
>;
template
class
TestElementwiseAddOp
<
CPU
>;
}
// namespace framework
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace paddle_mobile
int
main
()
{
int
main
()
{
DLOG
<<
"----------**********----------"
;
DLOG
<<
"----------**********----------"
;
DLOG
<<
"begin to run ElementAddOp Test"
;
DLOG
<<
"begin to run ElementAddOp Test"
;
...
...
test/operators/test_lrn_op.cpp
浏览文件 @
0d35f17b
...
@@ -19,8 +19,9 @@ limitations under the License. */
...
@@ -19,8 +19,9 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
paddle_mobile
{
namespace
framework
{
namespace
framework
{
template
<
typename
Dtype
>
class
TestLrnOp
{
template
<
typename
Dtype
>
public:
class
TestLrnOp
{
public:
explicit
TestLrnOp
(
const
Program
<
Dtype
>
p
)
:
program_
(
p
)
{
explicit
TestLrnOp
(
const
Program
<
Dtype
>
p
)
:
program_
(
p
)
{
if
(
use_optimize_
)
{
if
(
use_optimize_
)
{
to_predict_program_
=
program_
.
optimizeProgram
;
to_predict_program_
=
program_
.
optimizeProgram
;
...
@@ -57,7 +58,7 @@ public:
...
@@ -57,7 +58,7 @@ public:
}
}
}
}
std
::
shared_ptr
<
Tensor
>
predict_lrn
(
Tensor
&
t1
)
{
std
::
shared_ptr
<
Tensor
>
predict_lrn
(
const
Tensor
&
t1
)
{
// feed
// feed
auto
scope
=
program_
.
scope
;
auto
scope
=
program_
.
scope
;
Variable
*
x1_feed_value
=
scope
->
Var
(
"pool2d_0.tmp_0"
);
Variable
*
x1_feed_value
=
scope
->
Var
(
"pool2d_0.tmp_0"
);
...
@@ -77,7 +78,7 @@ public:
...
@@ -77,7 +78,7 @@ public:
return
out_tensor
;
return
out_tensor
;
}
}
private:
private:
const
framework
::
Program
<
Dtype
>
program_
;
const
framework
::
Program
<
Dtype
>
program_
;
std
::
shared_ptr
<
ProgramDesc
>
to_predict_program_
;
std
::
shared_ptr
<
ProgramDesc
>
to_predict_program_
;
std
::
map
<
framework
::
BlockDesc
,
std
::
map
<
framework
::
BlockDesc
,
...
@@ -97,8 +98,8 @@ private:
...
@@ -97,8 +98,8 @@ private:
};
};
template
class
TestLrnOp
<
CPU
>;
template
class
TestLrnOp
<
CPU
>;
}
// namespace framework
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace paddle_mobile
int
main
()
{
int
main
()
{
DLOG
<<
"----------**********----------"
;
DLOG
<<
"----------**********----------"
;
...
...
test/operators/test_mul_op.cpp
浏览文件 @
0d35f17b
...
@@ -19,8 +19,9 @@ limitations under the License. */
...
@@ -19,8 +19,9 @@ limitations under the License. */
namespace
paddle_mobile
{
namespace
paddle_mobile
{
namespace
framework
{
namespace
framework
{
template
<
typename
Dtype
>
class
TestMulOp
{
template
<
typename
Dtype
>
public:
class
TestMulOp
{
public:
explicit
TestMulOp
(
const
Program
<
Dtype
>
p
)
:
program_
(
p
)
{
explicit
TestMulOp
(
const
Program
<
Dtype
>
p
)
:
program_
(
p
)
{
if
(
use_optimize_
)
{
if
(
use_optimize_
)
{
to_predict_program_
=
program_
.
optimizeProgram
;
to_predict_program_
=
program_
.
optimizeProgram
;
...
@@ -59,7 +60,7 @@ public:
...
@@ -59,7 +60,7 @@ public:
}
}
}
}
std
::
shared_ptr
<
Tensor
>
predict_mul
(
Tensor
&
t1
,
Tensor
&
t2
)
{
std
::
shared_ptr
<
Tensor
>
predict_mul
(
const
Tensor
&
t1
,
const
Tensor
&
t2
)
{
// feed
// feed
auto
scope
=
program_
.
scope
;
auto
scope
=
program_
.
scope
;
Variable
*
x_feed_value
=
scope
->
Var
(
"pool2d_0.tmp_0"
);
Variable
*
x_feed_value
=
scope
->
Var
(
"pool2d_0.tmp_0"
);
...
@@ -83,7 +84,7 @@ public:
...
@@ -83,7 +84,7 @@ public:
return
out_tensor
;
return
out_tensor
;
}
}
private:
private:
const
framework
::
Program
<
Dtype
>
program_
;
const
framework
::
Program
<
Dtype
>
program_
;
std
::
shared_ptr
<
ProgramDesc
>
to_predict_program_
;
std
::
shared_ptr
<
ProgramDesc
>
to_predict_program_
;
std
::
map
<
framework
::
BlockDesc
,
std
::
map
<
framework
::
BlockDesc
,
...
@@ -103,8 +104,8 @@ private:
...
@@ -103,8 +104,8 @@ private:
};
};
template
class
TestMulOp
<
CPU
>;
template
class
TestMulOp
<
CPU
>;
}
// namespace framework
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace paddle_mobile
int
main
()
{
int
main
()
{
DLOG
<<
"----------**********----------"
;
DLOG
<<
"----------**********----------"
;
...
...
test/test_helper.h
浏览文件 @
0d35f17b
...
@@ -12,11 +12,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,11 +12,14 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#ifndef TEST_TEST_INCLUDE_H_
#define TEST_TEST_INCLUDE_H_
#pragma once
#pragma once
#include <random>
#include "common/log.h"
#include "common/log.h"
#include "framework/ddim.h"
#include "framework/ddim.h"
#include "framework/tensor.h"
#include "framework/tensor.h"
#include <random>
template
<
typename
T
>
template
<
typename
T
>
void
SetupTensor
(
paddle_mobile
::
framework
::
Tensor
*
input
,
void
SetupTensor
(
paddle_mobile
::
framework
::
Tensor
*
input
,
...
@@ -30,3 +33,5 @@ void SetupTensor(paddle_mobile::framework::Tensor *input,
...
@@ -30,3 +33,5 @@ void SetupTensor(paddle_mobile::framework::Tensor *input,
input_ptr
[
i
]
=
static_cast
<
T
>
(
uniform_dist
(
rng
)
*
(
upper
-
lower
)
+
lower
);
input_ptr
[
i
]
=
static_cast
<
T
>
(
uniform_dist
(
rng
)
*
(
upper
-
lower
)
+
lower
);
}
}
}
}
#endif
test/test_include.h
浏览文件 @
0d35f17b
...
@@ -12,18 +12,23 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -12,18 +12,23 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#ifndef TEST_TEST_INCLUDE_H_
#define TEST_TEST_INCLUDE_H_
#include <map>
#include <map>
#include <string>
#include <string>
#include <vector>
#include <vector>
#include "framework/program/block_desc.h"
#include "./test_helper.h"
#include "/io.h"
#include "framework/framework.pb.h"
#include "framework/framework.pb.h"
#include "framework/lod_tensor.h"
#include "framework/lod_tensor.h"
#include "framework/operator.h"
#include "framework/operator.h"
#include "framework/program/block_desc.h"
#include "framework/program/program.h"
#include "framework/program/program.h"
#include "framework/program/program_desc.h"
#include "framework/program/program_desc.h"
#include "framework/scope.h"
#include "framework/scope.h"
#include "framework/tensor.h"
#include "framework/tensor.h"
#include "framework/variable.h"
#include "framework/variable.h"
#include "io.h"
#
include "test_helper.h"
#
endif // TEST_TEST_INCLUDE_H_
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录