Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
05b65411
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看板
提交
05b65411
编写于
6月 07, 2018
作者:
D
dolphin8
提交者:
GitHub
6月 07, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'develop' into develop
上级
127f0944
ee0ebd26
变更
21
显示空白变更内容
内联
并排
Showing
21 changed file
with
141 addition
and
191 deletion
+141
-191
CMakeLists.txt
CMakeLists.txt
+2
-3
src/common/enforce.h
src/common/enforce.h
+5
-7
src/common/type_define.h
src/common/type_define.h
+0
-8
src/common/types.h
src/common/types.h
+0
-1
src/common/variant.h
src/common/variant.h
+0
-2
src/framework/attribute.h
src/framework/attribute.h
+1
-0
src/framework/ddim.h
src/framework/ddim.h
+0
-1
src/framework/dim.h
src/framework/dim.h
+0
-1
src/framework/lod_tensor.h
src/framework/lod_tensor.h
+0
-1
src/framework/operator.h
src/framework/operator.h
+0
-1
src/framework/program/program-optimize/node.cpp
src/framework/program/program-optimize/node.cpp
+0
-142
src/framework/program/program-optimize/node.h
src/framework/program/program-optimize/node.h
+0
-9
src/framework/variable.h
src/framework/variable.h
+0
-1
src/operators/math/pooling.cpp
src/operators/math/pooling.cpp
+1
-1
src/operators/pool_op.h
src/operators/pool_op.h
+4
-3
src/operators/sigmoid_op.h
src/operators/sigmoid_op.h
+3
-2
src/operators/softmax_op.h
src/operators/softmax_op.h
+3
-2
src/operators/transpose_op.cpp
src/operators/transpose_op.cpp
+3
-2
test/common/test_lib_size.cpp
test/common/test_lib_size.cpp
+21
-0
test/common/test_lib_size.h
test/common/test_lib_size.h
+93
-0
test/common/test_openmp.cpp
test/common/test_openmp.cpp
+5
-4
未找到文件。
CMakeLists.txt
浏览文件 @
05b65411
...
...
@@ -15,9 +15,8 @@ else ()
add_definitions
(
-DX86
)
endif
()
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++14"
)
set
(
CMAKE_BUILD_TYPE RelWithDebInfo
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
set
(
CMAKE_BUILD_TYPE Release
)
set
(
CMAKE_VERBOSE_MAKEFILE ON
)
set
(
CMAKE_EXPORT_COMPILE_COMMANDS ON
)
set
(
CMAKE_ARCHIVE_OUTPUT_DIRECTORY build
)
...
...
src/common/enforce.h
浏览文件 @
05b65411
...
...
@@ -17,7 +17,6 @@ limitations under the License. */
#ifdef ENABLE_EXCEPTION
#include <stdio.h>
#include <exception>
#include <sstream>
#include <string>
#endif
...
...
@@ -31,12 +30,11 @@ struct PaddleMobileException : public std::exception {
PaddleMobileException
(
const
char
*
header
,
const
char
*
detail
,
const
char
*
file
,
const
int
line
)
{
std
::
stringstream
ss
;
ss
<<
exception_prefix
<<
"| "
<<
header
<<
"
\n
"
;
ss
<<
"| [in file] : "
<<
file
<<
"
\n
"
;
ss
<<
"| [on line] : "
<<
line
<<
"
\n
"
;
ss
<<
"| [detail] : "
<<
detail
;
message
=
ss
.
str
();
char
buffer
[
1500
];
snprintf
(
buffer
,
sizeof
(
buffer
),
"%s| %s
\n
| [in file] : %s
\n
| [on line] : %d
\n
| [detail] : %s
\n
"
,
exception_prefix
.
c_str
(),
header
,
file
,
line
,
detail
);
message
=
std
::
string
(
buffer
);
}
const
char
*
what
()
const
noexcept
{
return
message
.
c_str
();
}
};
...
...
src/common/type_define.h
浏览文件 @
05b65411
...
...
@@ -16,7 +16,6 @@ limitations under the License. */
#include <map>
#include <string>
#include <unordered_set>
#include <vector>
#include "framework/attribute.h"
#include "framework/scope.h"
...
...
@@ -40,13 +39,6 @@ using OpCreator = std::function<framework::OperatorBase<Dtype> *(
const
framework
::
AttributeMap
&
/*attrs*/
,
std
::
shared_ptr
<
framework
::
Scope
>
/*scope*/
)
>
;
using
GradOpMakerFN
=
std
::
function
<
std
::
vector
<
std
::
unique_ptr
<
framework
::
OpDesc
>>
(
const
framework
::
OpDesc
&
,
const
std
::
unordered_set
<
std
::
string
>
&
/*no_grad_set*/
,
std
::
unordered_map
<
std
::
string
,
std
::
string
>
*
/*grad_to_var*/
,
const
std
::
vector
<
framework
::
BlockDesc
*>
&
grad_block
)
>
;
using
InferVarTypeFN
=
std
::
function
<
void
(
const
framework
::
OpDesc
&
/*op_desc*/
,
framework
::
BlockDesc
*
/*block*/
)
>
;
...
...
src/common/types.h
浏览文件 @
05b65411
...
...
@@ -16,7 +16,6 @@ limitations under the License. */
#include <string>
#include <unordered_map>
#include <utility>
namespace
paddle_mobile
{
enum
class
Precision
:
int
{
FP32
=
0
};
...
...
src/common/variant.h
浏览文件 @
05b65411
...
...
@@ -12,8 +12,6 @@ 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 "common/log.h"
#pragma once
...
...
src/framework/attribute.h
浏览文件 @
05b65411
...
...
@@ -17,6 +17,7 @@ limitations under the License. */
#include <string>
#include <unordered_map>
#include <vector>
#include "common/enforce.h"
#include "common/log.h"
#include "common/variant.h"
...
...
src/framework/ddim.h
浏览文件 @
05b65411
...
...
@@ -14,7 +14,6 @@ limitations under the License. */
#pragma once
#include <assert.h>
#include <initializer_list>
#include <stdexcept>
#include <vector>
...
...
src/framework/dim.h
浏览文件 @
05b65411
...
...
@@ -14,7 +14,6 @@ limitations under the License. */
#pragma once
#include <iostream>
#include <sstream>
#include <stdexcept>
#include <type_traits>
...
...
src/framework/lod_tensor.h
浏览文件 @
05b65411
...
...
@@ -16,7 +16,6 @@ limitations under the License. */
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include "tensor.h"
#include "tensor_util.h"
...
...
src/framework/operator.h
浏览文件 @
05b65411
...
...
@@ -16,7 +16,6 @@ limitations under the License. */
#include <map>
#include <string>
#include <utility>
#include <vector>
#include "common/enforce.h"
...
...
src/framework/program/program-optimize/node.cpp
浏览文件 @
05b65411
...
...
@@ -43,47 +43,6 @@ bool Node::operator==(const Node &in) {
return
true
;
}
bool
Node
::
CanSplit
(
std
::
unordered_set
<
std
::
string
>
complex_compute_set
)
{
bool
split
=
false
;
CanSplit
(
&
split
,
false
,
0
,
&
complex_compute_set
,
this
);
return
split
;
}
void
Node
::
CanSplit
(
bool
*
split
,
bool
spliting
,
int
complex_count
,
std
::
unordered_set
<
std
::
string
>
*
complex_compute_set
,
Node
*
pre_node
)
{
if
(
spliting
)
{
if
(
complex_compute_set
->
find
(
this
->
type_
)
!=
complex_compute_set
->
end
())
{
complex_count
++
;
}
}
if
(
inputs_
.
size
()
>
1
&&
pre_node
!=
inputs_
.
back
())
{
return
;
}
if
(
inputs_
.
size
()
>
1
&&
pre_node
==
inputs_
.
back
())
{
if
(
complex_count
>
1
)
{
*
split
=
true
;
return
;
}
}
// multi output, to check
if
(
outputs_
.
size
()
>
1
)
{
spliting
=
true
;
complex_compute_set
=
0
;
}
else
{
if
(
spliting
==
true
&&
inputs_
.
size
()
>
0
)
{
spliting
=
false
;
}
else
{
}
}
for
(
auto
&
output
:
outputs_
)
{
output
->
CanSplit
(
split
,
spliting
,
complex_count
,
complex_compute_set
,
this
);
}
}
std
::
vector
<
std
::
shared_ptr
<
framework
::
OpDesc
>>
Node
::
OpDescs
(
uint
size
)
{
std
::
vector
<
std
::
shared_ptr
<
framework
::
OpDesc
>>
op_descs
;
OpDescs
(
size
-
1
,
&
op_descs
);
...
...
@@ -101,107 +60,6 @@ void Node::OpDescs(uint index,
}
}
void
Node
::
OpDescs
(
std
::
vector
<
std
::
shared_ptr
<
framework
::
OpDesc
>>
*
op_desc
,
Node
*
node
,
bool
adding_thread
,
int
thread_num
)
{
if
(
outputs_
.
size
()
>
1
)
{
adding_thread
=
false
;
}
bool
can_add_split
=
false
;
// 如果当前节点有多个输出 并且 只有当前节点对应的 op_desc_ 输出数为 1 时支持
if
(
outputs_
.
size
()
>
1
&&
op_input_output_key
[
op_desc_
->
type_
].
second
.
size
()
==
1
)
{
can_add_split
=
true
;
// 遍历当前节点的 output 节点
for
(
const
auto
&
output
:
outputs_
)
{
// 不支持 output 有多个 output 的情况
if
(
output
->
outputs_
.
size
()
>
0
)
{
can_add_split
=
false
;
break
;
}
//与节点关联的 OpDesc
std
::
shared_ptr
<
framework
::
OpDesc
>
&
op_desc
=
output
->
op_desc_
;
//获取这个 op 的 inputs key 和 outputs key
auto
inputs_and_outputs
=
op_input_output_key
[
op_desc
->
type_
];
//判断现在 是否存在这个 op
//判断这个 output 和 input key 的 size 等于 1
if
(
op_input_output_key
.
find
(
op_desc
->
type_
)
!=
op_input_output_key
.
end
()
&&
inputs_and_outputs
.
first
.
size
()
==
1
&&
inputs_and_outputs
.
second
.
size
()
==
1
)
{
auto
inputs_of_output
=
op_desc
->
Input
(
inputs_and_outputs
.
first
[
0
]);
auto
outputs_of_output
=
op_desc
->
Output
(
inputs_and_outputs
.
second
[
0
]);
// 判断一下, 如果输入和输出没有同名, 是支持的
for
(
int
i
=
0
;
i
<
inputs_of_output
.
size
();
++
i
)
{
std
::
string
input_of_output
=
inputs_of_output
[
i
];
for
(
int
j
=
0
;
j
<
outputs_of_output
.
size
();
++
j
)
{
std
::
string
output_of_output
=
outputs_of_output
[
j
];
if
(
input_of_output
==
output_of_output
)
{
DLOG
<<
"output的 output 包含 input"
<<
input_of_output
;
can_add_split
=
false
;
break
;
}
}
}
}
else
{
// 如果模型中包含没有的 op, 则不支持添加 split
DLOG
<<
"找不到 这个 op 类型: "
<<
output
->
op_desc_
->
type_
;
can_add_split
=
false
;
}
}
}
if
(
inputs_
.
size
()
>
1
&&
node
!=
inputs_
.
back
())
{
return
;
}
else
if
(
inputs_
.
size
()
>
1
&&
node
==
inputs_
.
back
())
{
adding_thread
=
false
;
op_desc
->
push_back
(
this
->
op_desc_
);
}
else
{
op_desc
->
push_back
(
this
->
op_desc_
);
}
if
(
adding_thread
)
{
Attribute
attr
;
attr
.
Set
<
int
>
(
thread_num
);
this
->
op_desc_
->
attrs_
[
"thread"
]
=
attr
;
}
if
(
can_add_split
)
{
adding_thread
=
true
;
std
::
shared_ptr
<
OpDesc
>
split_op_desc
=
std
::
make_shared
<
OpDesc
>
();
split_op_desc
->
type_
=
G_OP_TYPE_SPLIT
;
auto
outputs
=
this
->
op_desc_
->
Output
(
op_input_output_key
[
this
->
op_desc_
->
Type
()].
second
[
0
]);
split_op_desc
->
inputs_
=
{
{
op_input_output_key
[
G_OP_TYPE_SPLIT
].
first
[
0
],
outputs
}};
auto
&
split_outputs
=
split_op_desc
->
outputs_
[
op_input_output_key
[
G_OP_TYPE_SPLIT
].
second
[
0
]];
for
(
const
auto
&
output
:
outputs_
)
{
split_outputs
.
push_back
(
outputs
[
0
]);
}
DLOG
<<
"add split"
;
op_desc
->
push_back
(
split_op_desc
);
}
for
(
int
i
=
0
;
i
<
outputs_
.
size
();
++
i
)
{
auto
&
output
=
outputs_
[
i
];
if
(
can_add_split
)
{
output
->
OpDescs
(
op_desc
,
this
,
adding_thread
,
i
);
}
else
{
output
->
OpDescs
(
op_desc
,
this
,
adding_thread
,
thread_num
);
}
}
}
std
::
vector
<
std
::
shared_ptr
<
framework
::
OpDesc
>>
Node
::
OpDescs
()
{
std
::
vector
<
std
::
shared_ptr
<
framework
::
OpDesc
>>
op_descs
;
OpDescs
(
&
op_descs
,
this
,
false
,
0
);
return
op_descs
;
}
std
::
shared_ptr
<
Node
>
Node
::
To
(
int
size
)
{
std
::
shared_ptr
<
Node
>
node
=
std
::
make_shared
<
Node
>
();
this
->
To
(
size
-
1
,
node
);
...
...
src/framework/program/program-optimize/node.h
浏览文件 @
05b65411
...
...
@@ -16,8 +16,6 @@ limitations under the License. */
#include <map>
#include <string>
#include <unordered_set>
#include <utility>
#include <vector>
#include "common/log.h"
...
...
@@ -36,7 +34,6 @@ class Node {
:
op_desc_
(
op_desc
),
type_
(
op_desc
->
Type
())
{}
Node
&
operator
>
(
std
::
shared_ptr
<
Node
>
node
);
bool
operator
==
(
const
Node
&
in
);
bool
CanSplit
(
std
::
unordered_set
<
std
::
string
>
complex_compute_set
);
std
::
string
ToString
()
const
;
std
::
shared_ptr
<
Node
>
To
(
int
size
);
uint
Depth
(
uint
begin
=
0
);
...
...
@@ -45,17 +42,11 @@ class Node {
std
::
map
<
std
::
string
,
std
::
pair
<
std
::
string
,
std
::
string
>>
change_map
,
std
::
vector
<
std
::
shared_ptr
<
Node
>>
*
removed_nodes
);
std
::
vector
<
std
::
shared_ptr
<
framework
::
OpDesc
>>
OpDescs
(
uint
size
);
std
::
vector
<
std
::
shared_ptr
<
framework
::
OpDesc
>>
OpDescs
();
std
::
shared_ptr
<
framework
::
OpDesc
>
OpDescOfNode
()
{
return
op_desc_
;
}
std
::
string
Type
()
{
return
type_
;
}
void
Description
();
private:
void
CanSplit
(
bool
*
split
,
bool
spliting
,
int
complex_count
,
std
::
unordered_set
<
std
::
string
>
*
complex_compute_set
,
Node
*
pre_node
);
void
OpDescs
(
std
::
vector
<
std
::
shared_ptr
<
framework
::
OpDesc
>>
*
op_desc
,
Node
*
node
,
bool
adding_thread
,
int
thread_num
);
void
OpDescs
(
uint
size
,
std
::
vector
<
std
::
shared_ptr
<
framework
::
OpDesc
>>
*
op_desc
);
void
To
(
int
index
,
std
::
shared_ptr
<
Node
>
);
...
...
src/framework/variable.h
浏览文件 @
05b65411
...
...
@@ -14,7 +14,6 @@ limitations under the License. */
#pragma once
#include <iostream>
#include <memory>
#include <string>
#include <typeindex>
...
...
src/operators/math/pooling.cpp
浏览文件 @
05b65411
...
...
@@ -15,7 +15,7 @@ limitations under the License. */
#ifdef POOL_OP
#include "pooling.h"
#include
<common/types.h>
#include
"common/types.h"
namespace
paddle_mobile
{
namespace
operators
{
...
...
src/operators/pool_op.h
浏览文件 @
05b65411
...
...
@@ -16,11 +16,12 @@ limitations under the License. */
#pragma once
#include <framework/operator.h>
#include <operators/kernel/pool_kernel.h>
#include <operators/op_param.h>
#include <string>
#include "framework/operator.h"
#include "operators/kernel/pool_kernel.h"
#include "operators/op_param.h"
namespace
paddle_mobile
{
namespace
operators
{
using
framework
::
AttributeMap
;
...
...
src/operators/sigmoid_op.h
浏览文件 @
05b65411
...
...
@@ -16,10 +16,11 @@ limitations under the License. */
#pragma once
#include <framework/operator.h>
#include <operators/op_param.h>
#include <string>
#include "framework/operator.h"
#include "operators/kernel/sigmoid_kernel.h"
#include "operators/op_param.h"
namespace
paddle_mobile
{
namespace
operators
{
...
...
src/operators/softmax_op.h
浏览文件 @
05b65411
...
...
@@ -16,10 +16,11 @@ limitations under the License. */
#pragma once
#include <framework/operator.h>
#include <operators/op_param.h>
#include <string>
#include "framework/operator.h"
#include "operators/kernel/softmax_kernel.h"
#include "operators/op_param.h"
namespace
paddle_mobile
{
namespace
operators
{
...
...
src/operators/transpose_op.cpp
浏览文件 @
05b65411
...
...
@@ -14,9 +14,10 @@ limitations under the License. */
#ifdef TRANSPOSE_OP
#include "operators/transpose_op.h"
#include <common/enforce.h>
#include <vector>
#include "common/enforce.h"
#include "operators/transpose_op.h"
namespace
paddle_mobile
{
namespace
operators
{
...
...
test/common/test_lib_size.cpp
0 → 100644
浏览文件 @
05b65411
/* 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. */
//
// Created by liuRuiLong on 2018/6/6.
//
#include "test_lib_size.h"
static
test_lib_size
t
;
test/common/test_lib_size.h
0 → 100644
浏览文件 @
05b65411
/* 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. */
//
// Created by liuRuiLong on 2018/6/6.
//
#ifndef PADDLE_MOBILE_TEST_LIB_SIZE_H
#define PADDLE_MOBILE_TEST_LIB_SIZE_H
#include <vector>
//#include <list>
//#include <tuple>
//#include <typeinfo>
//#include <mutex>
//#include <initializer_list>
//#include <map>
//#include <string>
//#include <unordered_map>
//#include <unordered_set>
//#include <algorithm>
//#include <iostream>
//#include <sstream>
#include <memory>
//#include <stdio.h>
//#include <cstring>
void
foo
()
{
// char *str = "1234";
// char dst[10];
// strcpy(dst, str);
// std::cout << "12345" << std::endl;
std
::
vector
<
int
>
vec
=
{
1
,
2
,
3
,
4
,
5
};
// std::find(vec.begin(), vec.end(), 1);
// std::find(vec.begin(), vec.end(), 1);
// std::list<int> l;
// std::mutex mutex_;
// std::map<int, float> m;
// std::unordered_map<int, float> u_m;
// std::unordered_set<int> u_s;
// std::string ss = "12345";
// printf("%f", ss.c_str());
// std::initializer_list<int> init_list = {1, 2};
// std::tuple<int, int> t = {1, 2};
// std::tuple_element<I, std::tuple<ARGS...>>::type
// std::tuple<>
// int i;
// int j;
// if (typeid(i) == typeid(j)){
// int z = 10;
// }
std
::
shared_ptr
<
int
>
s1
=
std
::
make_shared
<
int
>
();
// std::stringstream ss;
// ss << "12345";
}
class
test_lib_size
{
public:
test_lib_size
()
{}
// std::shared_ptr<int> Test(){
// std::vector<int> vec = {1, 2, 3};
// std::shared_ptr<int> si = std::make_shared<int>();
// return si;
// }
// void test(){
// int i = 9;
// }
};
#endif // PADDLE_MOBILE_TEST_LIB_SIZE_H
test/common/test_openmp.cpp
浏览文件 @
05b65411
...
...
@@ -12,16 +12,17 @@ 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 <omp.h>
//
#include <omp.h>
#include <iostream>
int
main
(
void
)
{
#ifdef PADDLE_MOBILE_USE_OPENMP
#pragma omp parallel num_threads(2)
{
int
thread_id
=
omp_get_thread_num
();
int
nthreads
=
omp_get_num_threads
();
std
::
cout
<<
"Hello, OMP "
<<
thread_id
<<
"/"
<<
nthreads
<<
"
\n
"
;
// int thread_id = omp_get_thread_num();
// int nthreads = omp_get_num_threads();
// std::cout << "Hello, OMP " << thread_id << "/" << nthreads <<
// "\n";
}
#endif
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录