Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
7cc864ea
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看板
提交
7cc864ea
编写于
5月 20, 2018
作者:
朔-望
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update for google code style
上级
75ba2f3d
变更
97
展开全部
隐藏空白更改
内联
并排
Showing
97 changed file
with
2435 addition
and
2450 deletion
+2435
-2450
src/common/log.h
src/common/log.h
+27
-21
src/common/type_define.h
src/common/type_define.h
+5
-4
src/common/types.h
src/common/types.h
+3
-2
src/common/variant.h
src/common/variant.h
+23
-11
src/framework/attribute.cpp
src/framework/attribute.cpp
+1
-1
src/framework/attribute.h
src/framework/attribute.h
+65
-60
src/framework/block_desc.cpp
src/framework/block_desc.cpp
+2
-2
src/framework/block_desc.h
src/framework/block_desc.h
+7
-6
src/framework/data_layout.h
src/framework/data_layout.h
+11
-11
src/framework/data_transform.cpp
src/framework/data_transform.cpp
+2
-2
src/framework/data_transform.h
src/framework/data_transform.h
+2
-2
src/framework/data_type.h
src/framework/data_type.h
+1
-1
src/framework/ddim.cc
src/framework/ddim.cc
+66
-51
src/framework/ddim.h
src/framework/ddim.h
+10
-6
src/framework/dim.h
src/framework/dim.h
+53
-29
src/framework/executor.cpp
src/framework/executor.cpp
+2
-2
src/framework/executor.h
src/framework/executor.h
+6
-5
src/framework/framework.pb.cpp
src/framework/framework.pb.cpp
+1292
-1332
src/framework/framework.pb.h
src/framework/framework.pb.h
+298
-315
src/framework/lod_tensor.cc
src/framework/lod_tensor.cc
+16
-26
src/framework/lod_tensor.h
src/framework/lod_tensor.h
+8
-9
src/framework/op_desc.cpp
src/framework/op_desc.cpp
+2
-2
src/framework/op_desc.h
src/framework/op_desc.h
+4
-4
src/framework/op_info.h
src/framework/op_info.h
+12
-8
src/framework/op_kernel_type.h
src/framework/op_kernel_type.h
+2
-2
src/framework/op_proto_maker.h
src/framework/op_proto_maker.h
+2
-2
src/framework/operator.cpp
src/framework/operator.cpp
+6
-3
src/framework/operator.h
src/framework/operator.h
+11
-9
src/framework/paddle_mobile_object.h
src/framework/paddle_mobile_object.h
+4
-4
src/framework/program-optimize/node.cpp
src/framework/program-optimize/node.cpp
+2
-2
src/framework/program-optimize/node.h
src/framework/program-optimize/node.h
+4
-4
src/framework/program-optimize/program_optimize.cpp
src/framework/program-optimize/program_optimize.cpp
+4
-4
src/framework/program-optimize/program_optimize.h
src/framework/program-optimize/program_optimize.h
+6
-6
src/framework/program.cpp
src/framework/program.cpp
+1
-1
src/framework/program.h
src/framework/program.h
+4
-4
src/framework/program_desc.cpp
src/framework/program_desc.cpp
+2
-2
src/framework/program_desc.h
src/framework/program_desc.h
+4
-4
src/framework/scope.cc
src/framework/scope.cc
+2
-2
src/framework/scope.h
src/framework/scope.h
+7
-7
src/framework/selected_rows.h
src/framework/selected_rows.h
+4
-4
src/framework/tensor.h
src/framework/tensor.h
+20
-12
src/framework/tensor_util.cc
src/framework/tensor_util.cc
+15
-11
src/framework/tensor_util.h
src/framework/tensor_util.h
+3
-3
src/framework/var_desc.cpp
src/framework/var_desc.cpp
+2
-2
src/framework/var_desc.h
src/framework/var_desc.h
+21
-21
src/framework/var_type.h
src/framework/var_type.h
+2
-2
src/framework/variable.h
src/framework/variable.h
+13
-9
src/io.cpp
src/io.cpp
+101
-167
src/io.h
src/io.h
+3
-3
src/memory/t_malloc.cc
src/memory/t_malloc.cc
+2
-2
src/memory/t_malloc.h
src/memory/t_malloc.h
+8
-6
src/operators/batchnorm_op.cpp
src/operators/batchnorm_op.cpp
+2
-2
src/operators/batchnorm_op.h
src/operators/batchnorm_op.h
+4
-4
src/operators/concat_op.cpp
src/operators/concat_op.cpp
+2
-2
src/operators/concat_op.h
src/operators/concat_op.h
+4
-4
src/operators/conv_op.cpp
src/operators/conv_op.cpp
+2
-2
src/operators/conv_op.h
src/operators/conv_op.h
+4
-4
src/operators/elementwise_add_op.cpp
src/operators/elementwise_add_op.cpp
+2
-2
src/operators/elementwise_add_op.h
src/operators/elementwise_add_op.h
+4
-4
src/operators/kernel/arm/batchnorm_kernel.cpp
src/operators/kernel/arm/batchnorm_kernel.cpp
+2
-2
src/operators/kernel/arm/concat_kernel.cpp
src/operators/kernel/arm/concat_kernel.cpp
+5
-4
src/operators/kernel/arm/conv_kernel.cpp
src/operators/kernel/arm/conv_kernel.cpp
+4
-3
src/operators/kernel/arm/elementwise_add_kernel.cpp
src/operators/kernel/arm/elementwise_add_kernel.cpp
+4
-3
src/operators/kernel/arm/lrn_kernel.cpp
src/operators/kernel/arm/lrn_kernel.cpp
+4
-3
src/operators/kernel/arm/mul_kernel.cpp
src/operators/kernel/arm/mul_kernel.cpp
+4
-3
src/operators/kernel/arm/pool_kernel.cpp
src/operators/kernel/arm/pool_kernel.cpp
+5
-4
src/operators/kernel/batchnorm_kernel.h
src/operators/kernel/batchnorm_kernel.h
+3
-3
src/operators/kernel/concat_kernel.h
src/operators/kernel/concat_kernel.h
+3
-3
src/operators/kernel/conv_kernel.h
src/operators/kernel/conv_kernel.h
+3
-3
src/operators/kernel/elementwise_add_kernel.h
src/operators/kernel/elementwise_add_kernel.h
+3
-3
src/operators/kernel/fpga/conv_kernel.cpp
src/operators/kernel/fpga/conv_kernel.cpp
+1
-1
src/operators/kernel/lrn_kernel.h
src/operators/kernel/lrn_kernel.h
+5
-4
src/operators/kernel/mul_kernel.h
src/operators/kernel/mul_kernel.h
+3
-3
src/operators/kernel/pool_kernel.h
src/operators/kernel/pool_kernel.h
+3
-3
src/operators/lrn_op.cpp
src/operators/lrn_op.cpp
+4
-3
src/operators/lrn_op.h
src/operators/lrn_op.h
+4
-4
src/operators/math/elementwise_op_function.h
src/operators/math/elementwise_op_function.h
+18
-14
src/operators/math/im2col.cc
src/operators/math/im2col.cc
+15
-11
src/operators/math/im2col.h
src/operators/math/im2col.h
+5
-5
src/operators/math/math_function.cc
src/operators/math/math_function.cc
+3
-3
src/operators/math/math_function.h
src/operators/math/math_function.h
+4
-4
src/operators/math/pool3x3.h
src/operators/math/pool3x3.h
+1
-1
src/operators/math/pool_2x2.h
src/operators/math/pool_2x2.h
+1
-1
src/operators/math/pooling.cpp
src/operators/math/pooling.cpp
+4
-5
src/operators/math/pooling.h
src/operators/math/pooling.h
+9
-7
src/operators/math/transform.h
src/operators/math/transform.h
+3
-3
src/operators/math/vol2col.cc
src/operators/math/vol2col.cc
+9
-7
src/operators/math/vol2col.h
src/operators/math/vol2col.h
+9
-7
src/operators/mul_op.cpp
src/operators/mul_op.cpp
+4
-3
src/operators/mul_op.h
src/operators/mul_op.h
+4
-4
src/operators/op_param.cpp
src/operators/op_param.cpp
+2
-2
src/operators/op_param.h
src/operators/op_param.h
+18
-18
src/operators/pool_op.cpp
src/operators/pool_op.cpp
+2
-2
src/operators/pool_op.h
src/operators/pool_op.h
+4
-4
src/platform/data_type.h
src/platform/data_type.h
+56
-56
src/platform/macros.h
src/platform/macros.h
+5
-5
test/operators/test_cov_op.cpp
test/operators/test_cov_op.cpp
+2
-2
未找到文件。
src/common/log.h
浏览文件 @
7cc864ea
...
...
@@ -51,12 +51,13 @@ struct Print;
struct
Print
{
friend
struct
ToLog
;
template
<
typename
T
>
Print
&
operator
<<
(
T
const
&
value
)
{
template
<
typename
T
>
Print
&
operator
<<
(
T
const
&
value
)
{
buffer_
<<
value
;
return
*
this
;
}
private:
private:
void
print
(
LogLevel
level
)
{
buffer_
<<
std
::
endl
;
if
(
level
==
kLOG_ERROR
)
{
...
...
@@ -76,14 +77,15 @@ struct ToLog {
printer_
<<
logs
[
level
]
<<
" "
<<
info
<<
":"
<<
std
::
string
(
blanks
,
' '
);
}
template
<
typename
T
>
ToLog
&
operator
<<
(
T
const
&
value
)
{
template
<
typename
T
>
ToLog
&
operator
<<
(
T
const
&
value
)
{
printer_
<<
value
;
return
*
this
;
}
~
ToLog
()
{
printer_
.
print
(
level_
);
}
private:
private:
LogLevel
level_
;
Print
printer_
;
};
...
...
@@ -109,16 +111,16 @@ private:
<< (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1) : __FILE__) \
<< "] [line: " << __LINE__ << "] ") \
.str())
}
// namespace paddle_mobile
}
// namespace paddle_mobile
#define LOGF(level, format, ...)
\
if (level > paddle_mobile::log_level) {
\
} else
\
#define LOGF(level, format, ...) \
if (level > paddle_mobile::log_level) { \
} else \
printf(format, ##__VA_ARGS__)
#define DLOGF(format, ...)
\
if (paddle_mobile::kLOG_DEBUG > paddle_mobile::log_level) {
\
} else
\
#define DLOGF(format, ...) \
if (paddle_mobile::kLOG_DEBUG > paddle_mobile::log_level) { \
} else \
printf(format, ##__VA_ARGS__)
#else
...
...
@@ -140,30 +142,34 @@ enum LogLevel {
struct
ToLog
;
struct
Print
{
friend
struct
ToLog
;
template
<
typename
T
>
Print
&
operator
<<
(
T
const
&
value
)
{}
template
<
typename
T
>
Print
&
operator
<<
(
T
const
&
value
)
{}
private:
private:
};
struct
ToLog
{
ToLog
(
LogLevel
level
)
{}
template
<
typename
T
>
ToLog
&
operator
<<
(
T
const
&
value
)
{
return
*
this
;
}
template
<
typename
T
>
ToLog
&
operator
<<
(
T
const
&
value
)
{
return
*
this
;
}
};
#define LOG(level)
\
if (true) {
\
} else
\
#define LOG(level) \
if (true) { \
} else \
paddle_mobile::ToLog(level)
#define DLOG
\
if (true) {
\
} else
\
#define DLOG \
if (true) { \
} else \
paddle_mobile::ToLog(paddle_mobile::kLOG_DEBUG)
#define LOGF(level, format, ...)
#define DLOGF(format, ...)
}
// namespace paddle_mobile
}
// namespace paddle_mobile
#endif
src/common/type_define.h
浏览文件 @
7cc864ea
...
...
@@ -17,18 +17,19 @@ SOFTWARE.
==============================================================================*/
#pragma once;
#include "framework/attribute.h"
#include <map>
#include <string>
#include "framework/attribute.h"
namespace
paddle_mobile
{
namespace
framework
{
template
<
typename
Dtype
>
class
OperatorBase
;
template
<
typename
Dtype
>
class
OperatorBase
;
class
OpDesc
;
class
BlockDesc
;
class
InferShapeContext
;
}
// namespace framework
}
// namespace framework
using
VariableNameMap
=
std
::
map
<
std
::
string
,
std
::
vector
<
std
::
string
>>
;
...
...
@@ -49,4 +50,4 @@ using InferVarTypeFN = std::function<void(const framework::OpDesc & /*op_desc*/,
framework
::
BlockDesc
*
/*block*/
)
>
;
using
InferShapeFN
=
std
::
function
<
void
(
framework
::
InferShapeContext
*
)
>
;
};
// namespace paddle_mobile
};
// namespace paddle_mobile
src/common/types.h
浏览文件 @
7cc864ea
...
...
@@ -24,7 +24,8 @@ enum class Precision : int { FP32 = 0 };
//! device type
enum
DeviceTypeEnum
{
kINVALID
=
-
1
,
kCPU
=
0
,
kFPGA
=
1
,
kGPU_MALI
=
2
};
template
<
DeviceTypeEnum
T
>
struct
DeviceType
{};
template
<
DeviceTypeEnum
T
>
struct
DeviceType
{};
typedef
DeviceType
<
kCPU
>
CPU
;
typedef
DeviceType
<
kFPGA
>
FPGA
;
...
...
@@ -60,4 +61,4 @@ enum PMStatus {
PMUnImplError
=
0x07
,
/*!< Unimplement error. */
PMWrongDevice
=
0x08
/*!< un-correct device. */
};
}
// namespace paddle_mobile
}
// namespace paddle_mobile
src/common/variant.h
浏览文件 @
7cc864ea
...
...
@@ -21,9 +21,13 @@ SOFTWARE.
#pragma once
namespace
paddle_mobile
{
template
<
int
ID
,
typename
Type
>
struct
IDToType
{
typedef
Type
type_t
;
};
template
<
int
ID
,
typename
Type
>
struct
IDToType
{
typedef
Type
type_t
;
};
template
<
typename
F
,
typename
...
Ts
>
struct
VariantHelper
{
template
<
typename
F
,
typename
...
Ts
>
struct
VariantHelper
{
static
const
size_t
size
=
sizeof
(
F
)
>
VariantHelper
<
Ts
...
>::
size
?
sizeof
(
F
)
:
VariantHelper
<
Ts
...
>::
size
;
...
...
@@ -37,7 +41,8 @@ template <typename F, typename... Ts> struct VariantHelper {
}
};
template
<
typename
F
>
struct
VariantHelper
<
F
>
{
template
<
typename
F
>
struct
VariantHelper
<
F
>
{
static
const
size_t
size
=
sizeof
(
F
);
inline
static
void
Destroy
(
size_t
id
,
void
*
data
)
{
if
(
id
==
typeid
(
F
).
hash_code
())
{
...
...
@@ -48,8 +53,9 @@ template <typename F> struct VariantHelper<F> {
}
};
template
<
size_t
size
>
class
RawData
{
public:
template
<
size_t
size
>
class
RawData
{
public:
char
data
[
size
];
RawData
()
{}
RawData
(
const
RawData
&
raw_data
)
{
strcpy
(
data
,
raw_data
.
data
);
}
...
...
@@ -58,7 +64,8 @@ public:
// }
};
template
<
typename
...
Ts
>
struct
Variant
{
template
<
typename
...
Ts
>
struct
Variant
{
Variant
(
const
Variant
&
variant
)
{
// std::cout << " 赋值构造函数 " << std::endl;
type_id
=
variant
.
type_id
;
...
...
@@ -70,13 +77,15 @@ template <typename... Ts> struct Variant {
// helper::Destroy(type_id, &data);
}
template
<
typename
T
,
typename
...
Args
>
void
Set
(
Args
&&
...
args
)
{
template
<
typename
T
,
typename
...
Args
>
void
Set
(
Args
&&
...
args
)
{
helper
::
Destroy
(
type_id
,
&
data
);
new
(
&
data
)
T
(
std
::
forward
<
Args
>
(
args
)...);
type_id
=
typeid
(
T
).
hash_code
();
}
template
<
typename
T
>
T
&
Get
()
const
{
template
<
typename
T
>
T
&
Get
()
const
{
if
(
type_id
==
typeid
(
T
).
hash_code
())
{
return
*
const_cast
<
T
*>
(
reinterpret_cast
<
const
T
*>
(
&
data
));
}
else
{
...
...
@@ -87,13 +96,16 @@ template <typename... Ts> struct Variant {
size_t
TypeId
()
const
{
return
type_id
;
}
private:
private:
static
inline
size_t
invalid_type
()
{
return
typeid
(
void
).
hash_code
();
}
typedef
VariantHelper
<
Ts
...
>
helper
;
size_t
type_id
;
RawData
<
helper
::
size
>
data
;
};
template
<
typename
T
>
struct
Vistor
{
typedef
T
type_t
;
};
template
<
typename
T
>
struct
Vistor
{
typedef
T
type_t
;
};
}
// namespace paddle_mobile
}
// namespace paddle_mobile
src/framework/attribute.cpp
浏览文件 @
7cc864ea
...
...
@@ -18,4 +18,4 @@ SOFTWARE.
namespace
paddle_mobile
{
namespace
framework
{}
}
// namespace paddle_mobile
}
// namespace paddle_mobile
src/framework/attribute.h
浏览文件 @
7cc864ea
...
...
@@ -27,80 +27,84 @@ namespace framework {
class
BlockDesc
;
class
Attribute
{
public:
public:
static
Attribute
GetAttrValue
(
const
proto
::
OpDesc
::
Attr
&
attr_desc
)
{
// std::cout << "begin get attr value" << std::endl;
Attribute
attr
;
switch
(
attr_desc
.
type
())
{
case
proto
::
AttrType
::
BOOLEAN
:
{
attr
.
Set
<
bool
>
(
attr_desc
.
b
());
break
;
}
case
proto
::
AttrType
::
INT
:
{
attr
.
Set
<
int
>
(
attr_desc
.
i
());
break
;
}
case
proto
::
AttrType
::
FLOAT
:
{
attr
.
Set
<
float
>
(
attr_desc
.
f
());
break
;
}
case
proto
::
AttrType
::
STRING
:
{
attr
.
Set
<
std
::
string
>
(
attr_desc
.
s
());
break
;
}
case
proto
::
AttrType
::
BOOLEANS
:
{
std
::
vector
<
bool
>
val
(
attr_desc
.
bools_size
());
for
(
int
i
=
0
;
i
<
attr_desc
.
bools_size
();
++
i
)
{
val
[
i
]
=
attr_desc
.
bools
(
i
);
case
proto
::
AttrType
::
BOOLEAN
:
{
attr
.
Set
<
bool
>
(
attr_desc
.
b
());
break
;
}
attr
.
Set
<
std
::
vector
<
bool
>>
(
val
);
break
;
}
case
proto
::
AttrType
::
INTS
:
{
std
::
vector
<
int
>
val
(
attr_desc
.
ints_size
());
for
(
int
i
=
0
;
i
<
attr_desc
.
ints_size
();
++
i
)
{
val
[
i
]
=
attr_desc
.
ints
(
i
);
case
proto
::
AttrType
::
INT
:
{
attr
.
Set
<
int
>
(
attr_desc
.
i
());
break
;
}
attr
.
Set
<
std
::
vector
<
int
>>
(
val
);
break
;
}
case
proto
::
AttrType
::
FLOATS
:
{
std
::
vector
<
float
>
val
(
attr_desc
.
floats_size
());
for
(
int
i
=
0
;
i
<
attr_desc
.
floats_size
();
++
i
)
{
val
[
i
]
=
attr_desc
.
floats
(
i
);
case
proto
::
AttrType
::
FLOAT
:
{
attr
.
Set
<
float
>
(
attr_desc
.
f
());
break
;
}
attr
.
Set
<
std
::
vector
<
float
>>
(
val
);
break
;
}
case
proto
::
AttrType
::
STRINGS
:
{
std
::
vector
<
std
::
string
>
val
(
attr_desc
.
strings_size
());
for
(
int
i
=
0
;
i
<
attr_desc
.
strings_size
();
++
i
)
{
val
[
i
]
=
attr_desc
.
strings
(
i
);
case
proto
::
AttrType
::
STRING
:
{
attr
.
Set
<
std
::
string
>
(
attr_desc
.
s
());
break
;
}
attr
.
Set
<
std
::
vector
<
std
::
string
>>
(
val
);
break
;
}
case
proto
::
AttrType
::
LONG
:
{
attr
.
Set
<
int64_t
>
(
attr_desc
.
l
());
break
;
}
default:
// std::cout << " not support " << std::endl;
break
;
case
proto
::
AttrType
::
BOOLEANS
:
{
std
::
vector
<
bool
>
val
(
attr_desc
.
bools_size
());
for
(
int
i
=
0
;
i
<
attr_desc
.
bools_size
();
++
i
)
{
val
[
i
]
=
attr_desc
.
bools
(
i
);
}
attr
.
Set
<
std
::
vector
<
bool
>>
(
val
);
break
;
}
case
proto
::
AttrType
::
INTS
:
{
std
::
vector
<
int
>
val
(
attr_desc
.
ints_size
());
for
(
int
i
=
0
;
i
<
attr_desc
.
ints_size
();
++
i
)
{
val
[
i
]
=
attr_desc
.
ints
(
i
);
}
attr
.
Set
<
std
::
vector
<
int
>>
(
val
);
break
;
}
case
proto
::
AttrType
::
FLOATS
:
{
std
::
vector
<
float
>
val
(
attr_desc
.
floats_size
());
for
(
int
i
=
0
;
i
<
attr_desc
.
floats_size
();
++
i
)
{
val
[
i
]
=
attr_desc
.
floats
(
i
);
}
attr
.
Set
<
std
::
vector
<
float
>>
(
val
);
break
;
}
case
proto
::
AttrType
::
STRINGS
:
{
std
::
vector
<
std
::
string
>
val
(
attr_desc
.
strings_size
());
for
(
int
i
=
0
;
i
<
attr_desc
.
strings_size
();
++
i
)
{
val
[
i
]
=
attr_desc
.
strings
(
i
);
}
attr
.
Set
<
std
::
vector
<
std
::
string
>>
(
val
);
break
;
}
case
proto
::
AttrType
::
LONG
:
{
attr
.
Set
<
int64_t
>
(
attr_desc
.
l
());
break
;
}
default:
// std::cout << " not support " << std::endl;
break
;
}
// std::cout << "end get attr value" << std::endl;
return
attr
;
}
Attribute
()
{}
template
<
typename
T
,
typename
...
Args
>
Attribute
&
Set
(
Args
&&
...
args
)
{
template
<
typename
T
,
typename
...
Args
>
Attribute
&
Set
(
Args
&&
...
args
)
{
variant_
.
Set
<
T
>
(
args
...);
return
*
this
;
}
template
<
typename
T
>
T
&
Get
()
const
{
return
variant_
.
Get
<
T
>
();
}
template
<
typename
T
>
T
&
Get
()
const
{
return
variant_
.
Get
<
T
>
();
}
private:
private:
Variant
<
int
,
float
,
std
::
string
,
std
::
vector
<
int
>
,
std
::
vector
<
float
>
,
std
::
vector
<
std
::
string
>
,
bool
,
std
::
vector
<
bool
>
,
BlockDesc
*
,
int64_t
>
...
...
@@ -110,10 +114,11 @@ private:
using
AttributeMap
=
std
::
unordered_map
<
std
::
string
,
Attribute
>
;
class
AttrReader
{
public:
public:
explicit
AttrReader
(
const
AttributeMap
&
attrs
)
:
attrs_
(
attrs
)
{}
template
<
typename
T
>
inline
T
Get
(
const
std
::
string
&
name
)
const
{
template
<
typename
T
>
inline
T
Get
(
const
std
::
string
&
name
)
const
{
// PADDLE_ENFORCE(attrs_.count(name) != 0, "%s should
// be in
// AttributeMap",
...
...
@@ -121,9 +126,9 @@ public:
return
((
Attribute
)
attrs_
.
at
(
name
)).
Get
<
T
>
();
}
private:
private:
const
AttributeMap
&
attrs_
;
};
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace framework
}
// namespace paddle_mobile
src/framework/block_desc.cpp
浏览文件 @
7cc864ea
...
...
@@ -46,5 +46,5 @@ BlockDesc::BlockDesc(const proto::BlockDesc &desc) : desc_(desc) {
}
}
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace framework
}
// namespace paddle_mobile
src/framework/block_desc.h
浏览文件 @
7cc864ea
...
...
@@ -27,7 +27,7 @@ namespace paddle_mobile {
namespace
framework
{
class
BlockDesc
:
PaddleMobileObject
{
public:
public:
BlockDesc
(
const
proto
::
BlockDesc
&
desc
);
const
int
&
ID
()
const
{
return
desc_
.
idx
();
}
...
...
@@ -45,18 +45,19 @@ public:
std
::
vector
<
std
::
shared_ptr
<
VarDesc
>>
Vars
()
const
;
std
::
vector
<
std
::
shared_ptr
<
OpDesc
>>
Ops
()
const
;
private:
private:
proto
::
BlockDesc
desc_
;
std
::
vector
<
std
::
shared_ptr
<
OpDesc
>>
ops_
;
std
::
unordered_map
<
std
::
string
,
std
::
shared_ptr
<
VarDesc
>>
vars_
;
};
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace framework
}
// namespace paddle_mobile
namespace
std
{
template
<
>
struct
hash
<
paddle_mobile
::
framework
::
BlockDesc
>
{
template
<
>
struct
hash
<
paddle_mobile
::
framework
::
BlockDesc
>
{
typedef
paddle_mobile
::
framework
::
BlockDesc
argument_type
;
typedef
std
::
size_t
result_type
;
result_type
operator
()(
argument_type
const
&
s
)
const
noexcept
{
...
...
@@ -66,4 +67,4 @@ template <> struct hash<paddle_mobile::framework::BlockDesc> {
}
};
}
// namespace std
}
// namespace std
src/framework/data_layout.h
浏览文件 @
7cc864ea
...
...
@@ -46,15 +46,15 @@ inline DataLayout StringToDataLayout(const std::string &str) {
inline
std
::
string
DataLayoutToString
(
const
DataLayout
&
data_layout
)
{
switch
(
data_layout
)
{
case
DataLayout
::
kNHWC
:
return
"NHWC"
;
case
DataLayout
::
kNCHW
:
return
"NCHW"
;
case
DataLayout
::
kAnyLayout
:
return
"ANY_LAYOUT"
;
default:
break
;
// std::cout << "unknown DataLayou %d", data_layout;
case
DataLayout
::
kNHWC
:
return
"NHWC"
;
case
DataLayout
::
kNCHW
:
return
"NCHW"
;
case
DataLayout
::
kAnyLayout
:
return
"ANY_LAYOUT"
;
default:
break
;
// std::cout << "unknown DataLayou %d", data_layout;
}
}
...
...
@@ -63,5 +63,5 @@ inline std::ostream &operator<<(std::ostream &out, const DataLayout &l) {
return
out
;
}
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace framework
}
// namespace paddle_mobile
src/framework/data_transform.cpp
浏览文件 @
7cc864ea
...
...
@@ -88,5 +88,5 @@ void CopyVariableWithTensor(const Variable &in_var, const Tensor &tensor,
// }
}
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace framework
}
// namespace paddle_mobile
src/framework/data_transform.h
浏览文件 @
7cc864ea
...
...
@@ -37,5 +37,5 @@ void DataTransform(const OpKernelType &expected_kernel_type,
void
CopyVariableWithTensor
(
const
Variable
&
in_var
,
const
Tensor
&
tensor
,
Variable
&
out_var
);
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace framework
}
// namespace paddle_mobile
src/framework/data_type.h
浏览文件 @
7cc864ea
...
...
@@ -40,4 +40,4 @@ namespace framework {
// }
// }
}
}
// namespace paddle_mobile
}
// namespace paddle_mobile
src/framework/ddim.cc
浏览文件 @
7cc864ea
...
...
@@ -19,49 +19,53 @@ namespace framework {
/// @cond HIDDEN
template
<
int
i
>
Dim
<
i
>
make_dim
(
const
int64_t
*
d
)
{
template
<
int
i
>
Dim
<
i
>
make_dim
(
const
int64_t
*
d
)
{
return
Dim
<
i
>
(
*
d
,
make_dim
<
i
-
1
>
(
d
+
1
));
}
template
<
>
Dim
<
0
>
make_dim
<
0
>
(
const
int64_t
*
d
)
{
return
Dim
<
0
>
(
*
d
);
}
template
<
>
Dim
<
0
>
make_dim
<
0
>
(
const
int64_t
*
d
)
{
return
Dim
<
0
>
(
*
d
);
}
void
make_ddim
(
DDim
&
ddim
,
const
int64_t
*
dims
,
int
n
)
{
switch
(
n
)
{
case
0
:
ddim
=
make_dim
<
0
>
(
dims
);
break
;
case
1
:
ddim
=
make_dim
<
1
>
(
dims
);
break
;
case
2
:
ddim
=
make_dim
<
2
>
(
dims
);
break
;
case
3
:
ddim
=
make_dim
<
3
>
(
dims
);
break
;
case
4
:
ddim
=
make_dim
<
4
>
(
dims
);
break
;
case
5
:
ddim
=
make_dim
<
5
>
(
dims
);
break
;
case
6
:
ddim
=
make_dim
<
6
>
(
dims
);
break
;
case
7
:
ddim
=
make_dim
<
7
>
(
dims
);
break
;
case
8
:
ddim
=
make_dim
<
8
>
(
dims
);
break
;
case
9
:
ddim
=
make_dim
<
9
>
(
dims
);
break
;
default:
// std::cout << "Dynamic dimensions must have between [1,
// 9]
// dimensions.";
break
;
case
0
:
ddim
=
make_dim
<
0
>
(
dims
);
break
;
case
1
:
ddim
=
make_dim
<
1
>
(
dims
);
break
;
case
2
:
ddim
=
make_dim
<
2
>
(
dims
);
break
;
case
3
:
ddim
=
make_dim
<
3
>
(
dims
);
break
;
case
4
:
ddim
=
make_dim
<
4
>
(
dims
);
break
;
case
5
:
ddim
=
make_dim
<
5
>
(
dims
);
break
;
case
6
:
ddim
=
make_dim
<
6
>
(
dims
);
break
;
case
7
:
ddim
=
make_dim
<
7
>
(
dims
);
break
;
case
8
:
ddim
=
make_dim
<
8
>
(
dims
);
break
;
case
9
:
ddim
=
make_dim
<
9
>
(
dims
);
break
;
default:
// std::cout << "Dynamic dimensions must have between [1,
// 9]
// dimensions.";
break
;
}
}
...
...
@@ -90,24 +94,28 @@ DDim make_ddim(const std::vector<int> &dims) {
// XXX For some reason, putting this in an anonymous namespace causes
// errors
struct
DynamicMutableIndexer
:
Vistor
<
int64_t
&>
{
public:
public:
explicit
DynamicMutableIndexer
(
int
idx
)
:
idx_
(
idx
)
{}
template
<
int
D
>
int64_t
&
operator
()(
Dim
<
D
>
&
dim
)
const
{
return
dim
[
idx_
];
}
template
<
int
D
>
int64_t
&
operator
()(
Dim
<
D
>
&
dim
)
const
{
return
dim
[
idx_
];
}
private:
private:
int
idx_
;
};
struct
DynamicConstIndexer
:
public
Vistor
<
int64_t
>
{
public:
public:
explicit
DynamicConstIndexer
(
int
idx
)
:
idx_
(
idx
)
{}
template
<
int
D
>
int64_t
operator
()(
const
Dim
<
D
>
&
dim
)
const
{
template
<
int
D
>
int64_t
operator
()(
const
Dim
<
D
>
&
dim
)
const
{
return
dim
[
idx_
];
}
private:
private:
int
idx_
;
};
...
...
@@ -182,7 +190,8 @@ struct VectorizeVisitor : Vistor<void> {
explicit
VectorizeVisitor
(
std
::
vector
<
int64_t
>
&
v
)
:
vector
(
v
)
{}
template
<
typename
T
>
void
operator
()(
const
T
&
t
)
{
template
<
typename
T
>
void
operator
()(
const
T
&
t
)
{
vector
.
push_back
(
t
.
head
);
this
->
operator
()(
t
.
tail
);
}
...
...
@@ -207,7 +216,8 @@ std::vector<int> vectorize2int(const DDim &ddim) {
}
struct
ProductVisitor
:
Vistor
<
int64_t
>
{
template
<
int
D
>
int64_t
operator
()(
const
Dim
<
D
>
&
dim
)
{
template
<
int
D
>
int64_t
operator
()(
const
Dim
<
D
>
&
dim
)
{
return
product
(
dim
);
}
};
...
...
@@ -233,7 +243,8 @@ struct SliceVectorizeVisitor : Vistor<void> {
// ddim slice.");
}
template
<
int
S
>
void
operator
()(
const
Dim
<
S
>
&
dim
)
{
template
<
int
S
>
void
operator
()(
const
Dim
<
S
>
&
dim
)
{
if
(
begin
==
0
)
{
vector
.
push_back
(
dim
.
head
);
}
else
{
...
...
@@ -264,7 +275,10 @@ DDim slice_ddim(const DDim &ddim, int begin, int end) {
/// \cond HIDDEN
struct
ArityVisitor
:
Vistor
<
int
>
{
template
<
int
D
>
int
operator
()(
Dim
<
D
>
)
const
{
return
D
;
}
template
<
int
D
>
int
operator
()(
Dim
<
D
>
)
const
{
return
D
;
}
};
/// \endcond
...
...
@@ -282,11 +296,12 @@ int arity(const DDim &d) {
struct
OSVistor
:
Vistor
<
std
::
ostream
&>
{
OSVistor
(
std
::
ostream
&
os
)
:
os_
(
os
)
{}
template
<
int
D
>
std
::
ostream
&
operator
()(
Dim
<
D
>
dim
)
const
{
template
<
int
D
>
std
::
ostream
&
operator
()(
Dim
<
D
>
dim
)
const
{
return
os_
<<
dim
;
}
private:
private:
std
::
ostream
&
os_
;
};
...
...
@@ -326,5 +341,5 @@ DDim stride_numel(const framework::DDim &ddim) {
return
framework
::
make_ddim
(
strides
);
}
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace framework
}
// namespace paddle_mobile
src/framework/ddim.h
浏览文件 @
7cc864ea
...
...
@@ -14,12 +14,12 @@ limitations under the License. */
#pragma once
#include "common/variant.h"
#include "dim.h"
#include <assert.h>
#include <initializer_list>
#include <stdexcept>
#include <vector>
#include "common/variant.h"
#include "dim.h"
namespace
paddle_mobile
{
namespace
framework
{
...
...
@@ -66,11 +66,15 @@ struct DDim {
DDim
()
{
var
.
Set
<
Dim
<
1
>>
(
Dim
<
1
>
());
}
template
<
int
D
>
explicit
DDim
(
const
Dim
<
D
>
&
in
)
{
var
.
Set
<
Dim
<
D
>>
(
in
);
}
template
<
int
D
>
explicit
DDim
(
const
Dim
<
D
>
&
in
)
{
var
.
Set
<
Dim
<
D
>>
(
in
);
}
/*implicit*/
DDim
(
std
::
initializer_list
<
int64_t
>
init_list
);
template
<
int
D
>
DDim
&
operator
=
(
const
Dim
<
D
>
&
in
)
{
template
<
int
D
>
DDim
&
operator
=
(
const
Dim
<
D
>
&
in
)
{
var
.
Set
<
Dim
<
D
>>
(
in
);
return
*
this
;
}
...
...
@@ -159,5 +163,5 @@ DDim flatten_to_1d(const DDim &src);
DDim
stride
(
const
DDim
&
ddim
);
DDim
stride_numel
(
const
DDim
&
ddim
);
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace framework
}
// namespace paddle_mobile
src/framework/dim.h
浏览文件 @
7cc864ea
...
...
@@ -24,7 +24,8 @@ namespace paddle_mobile {
namespace
framework
{
// Statically sized, statically indexed dimension
template
<
int
i
>
struct
Dim
{
template
<
int
i
>
struct
Dim
{
static
constexpr
int
dimensions
=
i
;
template
<
typename
...
Args
>
...
...
@@ -70,7 +71,8 @@ template <int i> struct Dim {
};
// Base case specialization
template
<
>
struct
Dim
<
0
>
{
template
<
>
struct
Dim
<
0
>
{
static
constexpr
int
dimensions
=
0
;
HOSTDEVICE
...
...
@@ -105,28 +107,37 @@ template <> struct Dim<0> {
namespace
{
// Helper for accessing Dim classes
template
<
int
i
>
struct
DimGetter
{
template
<
int
i
>
struct
DimGetter
{
// Return a copy if Dim is const
template
<
typename
D
>
HOSTDEVICE
static
int64_t
impl
(
const
D
&
d
)
{
template
<
typename
D
>
HOSTDEVICE
static
int64_t
impl
(
const
D
&
d
)
{
return
DimGetter
<
i
-
1
>::
impl
(
d
.
tail
);
}
// Return a reference if Dim is mutable
template
<
typename
D
>
HOSTDEVICE
static
int64_t
&
impl
(
D
&
d
)
{
template
<
typename
D
>
HOSTDEVICE
static
int64_t
&
impl
(
D
&
d
)
{
return
DimGetter
<
i
-
1
>::
impl
(
d
.
tail
);
}
};
// Eureka! We found the element!
template
<
>
struct
DimGetter
<
0
>
{
template
<
>
struct
DimGetter
<
0
>
{
// Return a copy if Dim is const
template
<
typename
D
>
HOSTDEVICE
static
int64_t
impl
(
const
D
&
d
)
{
template
<
typename
D
>
HOSTDEVICE
static
int64_t
impl
(
const
D
&
d
)
{
return
d
.
head
;
}
// Return a reference if Dim is mutable
template
<
typename
D
>
HOSTDEVICE
static
int64_t
&
impl
(
D
&
d
)
{
return
d
.
head
;
}
template
<
typename
D
>
HOSTDEVICE
static
int64_t
&
impl
(
D
&
d
)
{
return
d
.
head
;
}
};
template
<
int
D
>
HOSTDEVICE
int64_t
&
indexer
(
Dim
<
D
>
&
dim
,
int
idx
)
{
template
<
int
D
>
HOSTDEVICE
int64_t
&
indexer
(
Dim
<
D
>
&
dim
,
int
idx
)
{
#ifndef __CUDA_ARCH__
if
(
idx
<
0
)
{
throw
std
::
invalid_argument
(
"Tried to access a negative dimension"
);
...
...
@@ -140,7 +151,8 @@ template <int D> HOSTDEVICE int64_t &indexer(Dim<D> &dim, int idx) {
return
indexer
(
dim
.
tail
,
idx
-
1
);
}
template
<
>
HOSTDEVICE
int64_t
&
indexer
<
0
>
(
Dim
<
0
>
&
dim
,
int
idx
)
{
template
<
>
HOSTDEVICE
int64_t
&
indexer
<
0
>
(
Dim
<
0
>
&
dim
,
int
idx
)
{
#ifndef __CUDA_ARCH__
throw
std
::
invalid_argument
(
"Invalid index"
);
#else
...
...
@@ -156,7 +168,8 @@ template <> HOSTDEVICE int64_t &indexer<0>(Dim<0> &dim, int idx) {
#endif
}
template
<
int
D
>
HOSTDEVICE
int64_t
indexer
(
const
Dim
<
D
>
&
dim
,
int
idx
)
{
template
<
int
D
>
HOSTDEVICE
int64_t
indexer
(
const
Dim
<
D
>
&
dim
,
int
idx
)
{
#ifndef __CUDA_ARCH__
if
(
idx
<
0
)
{
throw
std
::
invalid_argument
(
"Tried to access a negative dimension"
);
...
...
@@ -170,7 +183,8 @@ template <int D> HOSTDEVICE int64_t indexer(const Dim<D> &dim, int idx) {
return
indexer
(
dim
.
tail
,
idx
-
1
);
}
template
<
>
HOSTDEVICE
int64_t
indexer
<
0
>
(
const
Dim
<
0
>
&
dim
,
int
idx
)
{
template
<
>
HOSTDEVICE
int64_t
indexer
<
0
>
(
const
Dim
<
0
>
&
dim
,
int
idx
)
{
#ifndef __CUDA_ARCH__
throw
std
::
invalid_argument
(
"Invalid index"
);
#else
...
...
@@ -186,25 +200,29 @@ template <> HOSTDEVICE int64_t indexer<0>(const Dim<0> &dim, int idx) {
#endif
}
}
// namespace
}
// namespace
// Static access to constant Dim
template
<
int
i
,
int
l
>
HOSTDEVICE
int64_t
get
(
const
Dim
<
l
>
&
d
)
{
template
<
int
i
,
int
l
>
HOSTDEVICE
int64_t
get
(
const
Dim
<
l
>
&
d
)
{
return
DimGetter
<
i
>::
impl
(
d
);
}
// Static access to mutable Dim
template
<
int
i
,
int
l
>
HOSTDEVICE
int64_t
&
get
(
Dim
<
l
>
&
d
)
{
template
<
int
i
,
int
l
>
HOSTDEVICE
int64_t
&
get
(
Dim
<
l
>
&
d
)
{
return
DimGetter
<
i
>::
impl
(
d
);
}
// Dynamic access to constant Dim
template
<
int
l
>
HOSTDEVICE
int64_t
Dim
<
l
>::
operator
[](
int
i
)
const
{
template
<
int
l
>
HOSTDEVICE
int64_t
Dim
<
l
>::
operator
[](
int
i
)
const
{
// std::cout << "l: " << l << std::endl;
return
indexer
(
*
this
,
i
);
}
// Dynamic access to mutable Dim
template
<
int
l
>
HOSTDEVICE
int64_t
&
Dim
<
l
>::
operator
[](
int
i
)
{
template
<
int
l
>
HOSTDEVICE
int64_t
&
Dim
<
l
>::
operator
[](
int
i
)
{
return
indexer
(
*
this
,
i
);
}
...
...
@@ -247,13 +265,15 @@ HOSTDEVICE inline int64_t linearize(const Dim<0> &a, const Dim<0> &b) {
}
// Product of a Dim
template
<
int
i
>
HOSTDEVICE
int64_t
product
(
const
Dim
<
i
>
&
a
,
int
prod
=
1
)
{
template
<
int
i
>
HOSTDEVICE
int64_t
product
(
const
Dim
<
i
>
&
a
,
int
prod
=
1
)
{
return
prod
*
a
.
head
*
product
(
a
.
tail
);
}
// Base case product of a Dim
// Notice it is inline because it is no longer a template
template
<
>
HOSTDEVICE
inline
int64_t
product
(
const
Dim
<
0
>
&
a
,
int
prod
)
{
template
<
>
HOSTDEVICE
inline
int64_t
product
(
const
Dim
<
0
>
&
a
,
int
prod
)
{
return
prod
;
}
...
...
@@ -282,7 +302,8 @@ HOSTDEVICE Dim<i> ex_prefix_mul(const Dim<i> &src, int mul = 1) {
///\cond HIDDEN
// Base case of ex_prefix_mul
// Notice it is inline because it is no longer a template
template
<
>
HOSTDEVICE
inline
Dim
<
0
>
ex_prefix_mul
(
const
Dim
<
0
>
&
src
,
int
mul
)
{
template
<
>
HOSTDEVICE
inline
Dim
<
0
>
ex_prefix_mul
(
const
Dim
<
0
>
&
src
,
int
mul
)
{
return
Dim
<
0
>
();
}
///\endcond
...
...
@@ -290,7 +311,8 @@ template <> HOSTDEVICE inline Dim<0> ex_prefix_mul(const Dim<0> &src, int mul) {
/**
* Add two dimensions together
*/
template
<
int
i
>
HOSTDEVICE
Dim
<
i
>
dim_plus
(
const
Dim
<
i
>
&
a
,
const
Dim
<
i
>
&
b
)
{
template
<
int
i
>
HOSTDEVICE
Dim
<
i
>
dim_plus
(
const
Dim
<
i
>
&
a
,
const
Dim
<
i
>
&
b
)
{
return
Dim
<
i
>
(
a
.
head
+
b
.
head
,
dim_plus
(
a
.
tail
,
b
.
tail
));
}
...
...
@@ -308,7 +330,8 @@ HOSTDEVICE Dim<i> operator+(const Dim<i> &lhs, const Dim<i> &rhs) {
/**
* Multiply two dimensions together
*/
template
<
int
i
>
HOSTDEVICE
Dim
<
i
>
dim_mult
(
const
Dim
<
i
>
&
a
,
const
Dim
<
i
>
&
b
)
{
template
<
int
i
>
HOSTDEVICE
Dim
<
i
>
dim_mult
(
const
Dim
<
i
>
&
a
,
const
Dim
<
i
>
&
b
)
{
return
Dim
<
i
>
(
a
.
head
*
b
.
head
,
dim_mult
(
a
.
tail
,
b
.
tail
));
}
...
...
@@ -365,8 +388,8 @@ HOSTDEVICE Dim<sizeof...(Args)> make_dim(Args... idxes) {
// Allows us to output a Dim
// XXX For some reason, overloading fails to resolve this correctly
template
<
int
i
>
typename
std
::
enable_if
<
(
i
>
1
),
std
::
ostream
&>::
type
operator
<<
(
std
::
ostream
&
os
,
const
Dim
<
i
>
&
d
)
{
typename
std
::
enable_if
<
(
i
>
1
),
std
::
ostream
&>::
type
operator
<<
(
std
::
ostream
&
os
,
const
Dim
<
i
>
&
d
)
{
os
<<
d
.
head
<<
", "
<<
d
.
tail
;
return
os
;
}
...
...
@@ -374,8 +397,8 @@ operator<<(std::ostream &os, const Dim<i> &d) {
// Base case that allows us to output a Dim
// XXX I wish this could be an overload instead of a template
template
<
int
i
>
typename
std
::
enable_if
<
(
i
==
1
),
std
::
ostream
&>::
type
operator
<<
(
std
::
ostream
&
os
,
const
Dim
<
i
>
&
d
)
{
typename
std
::
enable_if
<
(
i
==
1
),
std
::
ostream
&>::
type
operator
<<
(
std
::
ostream
&
os
,
const
Dim
<
i
>
&
d
)
{
os
<<
d
.
head
;
return
os
;
}
...
...
@@ -384,7 +407,8 @@ inline std::ostream &operator<<(std::ostream &os, const Dim<0> &d) {
return
os
;
}
template
<
int
i
>
HOST
std
::
string
Dim
<
i
>::
to_string
()
const
{
template
<
int
i
>
HOST
std
::
string
Dim
<
i
>::
to_string
()
const
{
std
::
stringstream
stream
;
stream
<<
*
this
;
...
...
@@ -406,5 +430,5 @@ HOSTDEVICE Dim<D> linear_to_dimension(int linear_index, Dim<D> extents) {
return
result
;
}
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace framework
}
// namespace paddle_mobile
src/framework/executor.cpp
浏览文件 @
7cc864ea
...
...
@@ -90,5 +90,5 @@ void Executor<Dtype>::predict(const Tensor &t, int block_id) {
template
class
Executor
<
CPU
>;
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace framework
}
// namespace paddle_mobile
src/framework/executor.h
浏览文件 @
7cc864ea
...
...
@@ -34,15 +34,16 @@ SOFTWARE.
namespace
paddle_mobile
{
namespace
framework
{
template
<
typename
Dtype
>
class
Executor
{
public:
template
<
typename
Dtype
>
class
Executor
{
public:
Executor
();
Executor
(
const
Program
<
Dtype
>
p
);
std
::
shared_ptr
<
Tensor
>
predict
(
Tensor
&
t
);
public:
public:
const
framework
::
Program
<
Dtype
>
program_
;
std
::
shared_ptr
<
ProgramDesc
>
to_predict_program_
;
...
...
@@ -54,5 +55,5 @@ public:
bool
use_optimize_
=
false
;
};
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace framework
}
// namespace paddle_mobile
src/framework/framework.pb.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/framework.pb.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/lod_tensor.cc
浏览文件 @
7cc864ea
...
...
@@ -13,10 +13,10 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include "lod_tensor.h"
#include <algorithm>
#include <iterator>
#include <stdint.h>
#include <string.h>
#include <algorithm>
#include <iterator>
namespace
paddle_mobile
{
namespace
framework
{
...
...
@@ -105,8 +105,7 @@ LoD SliceInLevel(const LoD &in, size_t level, size_t elem_begin,
LoD
ToAbsOffset
(
const
LoD
&
in
)
{
// the lowest level stores relative offsets
if
(
in
.
empty
()
||
in
.
size
()
==
1
)
return
in
;
if
(
in
.
empty
()
||
in
.
size
()
==
1
)
return
in
;
LoD
result
=
in
;
for
(
auto
level
=
static_cast
<
int
>
(
in
.
size
()
-
2
);
level
>=
0
;
level
--
)
{
for
(
size_t
i
=
0
;
i
<
in
[
level
].
size
();
++
i
)
{
...
...
@@ -138,23 +137,19 @@ bool operator==(const LoD &a, const LoD &b) {
}
bool
CheckLoD
(
const
LoD
&
in
,
int
tensor_height
)
{
if
(
in
.
empty
())
return
true
;
if
(
in
.
empty
())
return
true
;
for
(
const
auto
&
level
:
in
)
{
// check: there should be more than 2 offsets existing in each
// level.
if
(
level
.
size
()
<
2
)
return
false
;
if
(
level
.
size
()
<
2
)
return
false
;
// check: the first offset(the begin offset) of each level
// should be 0.
if
(
level
.
front
()
!=
0
)
return
false
;
if
(
level
.
front
()
!=
0
)
return
false
;
// check: all the offsets in a level should be ascending(no same
// items
// allows).
if
(
!
std
::
is_sorted
(
level
.
begin
(),
level
.
begin
(),
[](
size_t
a
,
size_t
b
)
{
if
(
a
<
b
)
return
true
;
if
(
a
<
b
)
return
true
;
return
false
;
}))
{
std
::
cout
<<
"ascending error"
;
...
...
@@ -174,22 +169,19 @@ bool CheckLoD(const LoD &in, int tensor_height) {
// goes
// first.
for
(
size_t
level
=
0
;
level
<
in
.
size
()
-
1
;
level
++
)
{
if
(
in
[
level
].
back
()
!=
in
[
level
+
1
].
size
()
-
1
)
return
false
;
if
(
in
[
level
].
back
()
!=
in
[
level
+
1
].
size
()
-
1
)
return
false
;
}
return
true
;
}
bool
CheckAbsLoD
(
const
LoD
&
in
,
int
tensor_height
)
{
if
(
in
.
empty
())
return
true
;
if
(
in
.
empty
())
return
true
;
for
(
const
auto
&
level
:
in
)
{
// check: all the offsets in a level should be ascending(no same
// items
// allows).
if
(
!
std
::
is_sorted
(
level
.
begin
(),
level
.
begin
(),
[](
size_t
a
,
size_t
b
)
{
if
(
a
<
b
)
return
true
;
if
(
a
<
b
)
return
true
;
return
false
;
}))
{
return
false
;
...
...
@@ -197,14 +189,12 @@ bool CheckAbsLoD(const LoD &in, int tensor_height) {
// check: there should be more than 2 offsets existing in each
// level.
if
(
level
.
size
()
<
2
)
return
false
;
if
(
level
.
size
()
<
2
)
return
false
;
// check: the first offset of each level should be 0, and the
// last should be
// the same(the height of underlying tensor).
if
(
level
.
front
()
!=
0
)
return
false
;
if
(
level
.
front
()
!=
0
)
return
false
;
if
(
tensor_height
<
0
)
{
tensor_height
=
level
.
back
();
}
else
if
((
size_t
)
tensor_height
!=
level
.
back
())
{
...
...
@@ -242,7 +232,7 @@ void AppendLoD(LoD *lod, const LoD &lod_length) {
// lod.");
if
(
lod
->
empty
())
{
for
(
size_t
i
=
0
;
i
<
lod_length
.
size
();
++
i
)
{
lod
->
emplace_back
(
1
,
0
);
// size = 1, value = 0;
lod
->
emplace_back
(
1
,
0
);
// size = 1, value = 0;
}
*
lod
=
LoD
(
lod_length
.
size
(),
std
::
vector
<
size_t
>
({
0
}));
}
...
...
@@ -255,7 +245,7 @@ void AppendLoD(LoD *lod, const LoD &lod_length) {
}
void
SerializeToStream
(
std
::
ostream
&
os
,
const
LoDTensor
&
tensor
)
{
{
// the 1st field, uint32_t version for LoDTensor
{
// the 1st field, uint32_t version for LoDTensor
constexpr
uint32_t
version
=
0
;
os
.
write
(
reinterpret_cast
<
const
char
*>
(
&
version
),
sizeof
(
version
));
}
...
...
@@ -307,5 +297,5 @@ void DeserializeFromStream(std::istream &is, LoDTensor *tensor) {
TensorFromStream
(
is
,
static_cast
<
Tensor
*>
(
tensor
));
}
}
// namespace framework
}
// namespace paddle_mobile
}
// namespace framework
}
// namespace paddle_mobile
src/framework/lod_tensor.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/op_desc.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/op_desc.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/op_info.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/op_kernel_type.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/op_proto_maker.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/operator.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/operator.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/paddle_mobile_object.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/program-optimize/node.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/program-optimize/node.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/program-optimize/program_optimize.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/program-optimize/program_optimize.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/program.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/program.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/program_desc.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/program_desc.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/scope.cc
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/scope.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/selected_rows.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/tensor.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/tensor_util.cc
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/tensor_util.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/var_desc.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/var_desc.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/var_type.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/framework/variable.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/io.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/io.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/memory/t_malloc.cc
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/memory/t_malloc.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/batchnorm_op.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/batchnorm_op.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/concat_op.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/concat_op.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/conv_op.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/conv_op.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/elementwise_add_op.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/elementwise_add_op.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/arm/batchnorm_kernel.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/arm/concat_kernel.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/arm/conv_kernel.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/arm/elementwise_add_kernel.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/arm/lrn_kernel.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/arm/mul_kernel.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/arm/pool_kernel.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/batchnorm_kernel.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/concat_kernel.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/conv_kernel.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/elementwise_add_kernel.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/fpga/conv_kernel.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/lrn_kernel.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/mul_kernel.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/kernel/pool_kernel.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/lrn_op.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/lrn_op.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/math/elementwise_op_function.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/math/im2col.cc
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/math/im2col.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/math/math_function.cc
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/math/math_function.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/math/pool3x3.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/math/pool_2x2.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/math/pooling.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/math/pooling.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/math/transform.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/math/vol2col.cc
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/math/vol2col.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/mul_op.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/mul_op.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/op_param.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/op_param.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/pool_op.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/operators/pool_op.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/platform/data_type.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
src/platform/macros.h
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
test/operators/test_cov_op.cpp
浏览文件 @
7cc864ea
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录