Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
0157fb6e
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看板
提交
0157fb6e
编写于
5月 18, 2018
作者:
L
liuruilong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add program optimize node
上级
22a62842
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
218 addition
and
4 deletion
+218
-4
src/framework/paddle_mobile_object.h
src/framework/paddle_mobile_object.h
+1
-1
src/framework/program-optimize/node.cpp
src/framework/program-optimize/node.cpp
+64
-0
src/framework/program-optimize/node.h
src/framework/program-optimize/node.h
+46
-0
src/framework/program-optimize/program_optimize.cpp
src/framework/program-optimize/program_optimize.cpp
+25
-0
src/framework/program-optimize/program_optimize.h
src/framework/program-optimize/program_optimize.h
+35
-0
test/CMakeLists.txt
test/CMakeLists.txt
+6
-1
test/framework/test_load.cpp
test/framework/test_load.cpp
+1
-1
test/framework/test_optimize.cpp
test/framework/test_optimize.cpp
+39
-0
test/main.cpp
test/main.cpp
+1
-1
未找到文件。
src/framework/paddle_mobile_object.h
浏览文件 @
0157fb6e
...
@@ -25,7 +25,7 @@ namespace paddle_mobile {
...
@@ -25,7 +25,7 @@ namespace paddle_mobile {
class
PaddleMobileObject
{
class
PaddleMobileObject
{
public:
public:
virtual
inline
const
std
::
string
&
ToString
()
{
virtual
std
::
string
ToString
()
{
char
address
[
128
]
=
{
0
};
char
address
[
128
]
=
{
0
};
sprintf
(
address
,
"%p"
,
this
);
sprintf
(
address
,
"%p"
,
this
);
return
std
::
string
(
address
);
return
std
::
string
(
address
);
...
...
src/framework/program-optimize/node.cpp
0 → 100644
浏览文件 @
0157fb6e
/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
==============================================================================*/
#include <sstream>
#include "node.h"
namespace
paddle_mobile
{
namespace
framework
{
Node
&
Node
::
operator
>
(
const
Node
&
out
)
{
std
::
shared_ptr
<
Node
>
node
=
std
::
make_shared
<
Node
>
(
Node
(
out
));
outputs_
.
push_back
(
node
);
return
*
node
;
}
bool
Node
::
operator
==
(
const
Node
&
in
)
{
if
(
in
.
type_
==
this
->
type_
)
{
if
(
this
->
outputs_
.
size
()
==
in
.
outputs_
.
size
())
{
for
(
int
i
=
0
;
i
<
outputs_
.
size
();
++
i
)
{
if
(
!
(
*
outputs_
[
i
]
==
*
in
.
outputs_
[
i
]))
{
return
false
;
}
}
}
else
{
return
false
;
}
}
else
{
return
false
;
}
return
true
;
}
std
::
string
Node
::
ToString
(
std
::
string
blank
)
const
{
std
::
stringstream
ss
;
ss
<<
type_
<<
":
\n
"
;
for
(
int
i
=
0
;
i
<
outputs_
.
size
();
++
i
)
{
ss
<<
blank
<<
outputs_
[
i
]
->
ToString
(
blank
+
" "
)
<<
""
;
}
return
ss
.
str
();
}
std
::
string
Node
::
ToString
()
const
{
return
this
->
ToString
(
" "
);
}
Print
&
operator
<<
(
Print
&
printer
,
const
Node
&
node
)
{
printer
<<
node
.
ToString
();
return
printer
;
}
}
}
src/framework/program-optimize/node.h
0 → 100644
浏览文件 @
0157fb6e
/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
==============================================================================*/
#pragma once
#include <string>
#include <vector>
#include "common/log.h"
#include "framework/paddle_mobile_object.h"
namespace
paddle_mobile
{
namespace
framework
{
class
Node
:
PaddleMobileObject
{
public:
Node
(
const
std
::
string
&
type
)
:
type_
(
type
)
{}
Node
&
operator
>
(
const
Node
&
out
);
bool
operator
==
(
const
Node
&
in
);
std
::
string
ToString
()
const
;
private:
std
::
string
ToString
(
std
::
string
blank
)
const
;
std
::
vector
<
std
::
shared_ptr
<
Node
>>
outputs_
;
std
::
string
type_
;
};
Print
&
operator
<<
(
Print
&
printer
,
const
Node
&
node
);
}
}
src/framework/program-optimize/program_optimize.cpp
0 → 100644
浏览文件 @
0157fb6e
/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
==============================================================================*/
#include "program_optimize.h"
namespace
paddle_mobile
{
namespace
framework
{
std
::
shared_ptr
<
ProgramDesc
>
ProgramOptimize
::
Optimize
()
{}
}
}
src/framework/program-optimize/program_optimize.h
0 → 100644
浏览文件 @
0157fb6e
/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
==============================================================================*/
#pragma once
#include "framework/program_desc.h"
namespace
paddle_mobile
{
namespace
framework
{
class
ProgramOptimize
{
public:
ProgramOptimize
(
std
::
shared_ptr
<
ProgramDesc
>
ori_desc
)
:
ori_desc_
(
ori_desc
)
{}
std
::
shared_ptr
<
ProgramDesc
>
Optimize
();
private:
std
::
shared_ptr
<
ProgramDesc
>
ori_desc_
;
};
}
}
// namespace paddle_mobile
test/CMakeLists.txt
浏览文件 @
0157fb6e
...
@@ -13,4 +13,9 @@ target_link_libraries(test-log paddle-mobile)
...
@@ -13,4 +13,9 @@ target_link_libraries(test-log paddle-mobile)
# gen test log
# gen test log
ADD_EXECUTABLE
(
test-load framework/test_load.cpp
)
ADD_EXECUTABLE
(
test-load framework/test_load.cpp
)
target_link_libraries
(
test-load paddle-mobile
)
target_link_libraries
(
test-load paddle-mobile
)
\ No newline at end of file
# gen test log
ADD_EXECUTABLE
(
test-optimize framework/test_optimize.cpp
)
target_link_libraries
(
test-optimize paddle-mobile
)
\ No newline at end of file
test/framework/test_load.cpp
浏览文件 @
0157fb6e
...
@@ -23,6 +23,6 @@ int main() {
...
@@ -23,6 +23,6 @@ int main() {
//../../../test/models/googlenet
//../../../test/models/googlenet
//../../../test/models/mobilenet
//../../../test/models/mobilenet
auto
program
=
loader
.
Load
(
std
::
string
(
"../../../test/models/
mobi
lenet"
));
auto
program
=
loader
.
Load
(
std
::
string
(
"../../../test/models/
goog
lenet"
));
return
0
;
return
0
;
}
}
\ No newline at end of file
test/framework/test_optimize.cpp
0 → 100644
浏览文件 @
0157fb6e
/* Copyright (c) 2016 Baidu, Inc. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
==============================================================================*/
#include <iostream>
#include "framework/program-optimize/node.h"
using
namespace
paddle_mobile
::
framework
;
int
main
(){
Node
node
(
"conv"
);
node
>
Node
(
"add"
)
>
Node
(
"relu"
);
Node
node1
(
"conv"
);
node1
>
Node
(
"add"
)
>
Node
(
"relu"
);
if
(
node
==
node1
){
DLOG
<<
"equal"
;
}
DLOG
<<
"
\n
"
<<
node1
;
// DLOG << node;
}
test/main.cpp
浏览文件 @
0157fb6e
...
@@ -53,7 +53,7 @@ int main() {
...
@@ -53,7 +53,7 @@ int main() {
paddle_mobile
::
Loader
<
paddle_mobile
::
CPU
>
loader
;
paddle_mobile
::
Loader
<
paddle_mobile
::
CPU
>
loader
;
auto
program
=
loader
.
Load
(
std
::
string
(
auto
program
=
loader
.
Load
(
std
::
string
(
"../../test/models/image_classification_resnet.inference.model"
));
"../../
../
test/models/image_classification_resnet.inference.model"
));
paddle_mobile
::
framework
::
Executor
<
paddle_mobile
::
CPU
>
executor
(
program
);
paddle_mobile
::
framework
::
Executor
<
paddle_mobile
::
CPU
>
executor
(
program
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录