Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
f41d73b3
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f41d73b3
编写于
4月 14, 2019
作者:
S
Superjomn
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init mir
上级
a1b1feb4
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
148 addition
and
6 deletion
+148
-6
paddle/fluid/lite/core/CMakeLists.txt
paddle/fluid/lite/core/CMakeLists.txt
+2
-0
paddle/fluid/lite/core/context.cc
paddle/fluid/lite/core/context.cc
+1
-1
paddle/fluid/lite/core/mir/CMakeLists.txt
paddle/fluid/lite/core/mir/CMakeLists.txt
+3
-0
paddle/fluid/lite/core/mir/node.cc
paddle/fluid/lite/core/mir/node.cc
+1
-0
paddle/fluid/lite/core/mir/node.h
paddle/fluid/lite/core/mir/node.h
+15
-0
paddle/fluid/lite/core/mir/pass.cc
paddle/fluid/lite/core/mir/pass.cc
+1
-0
paddle/fluid/lite/core/mir/pass.h
paddle/fluid/lite/core/mir/pass.h
+0
-0
paddle/fluid/lite/core/mir/ssa_graph.cc
paddle/fluid/lite/core/mir/ssa_graph.cc
+1
-0
paddle/fluid/lite/core/mir/ssa_graph.h
paddle/fluid/lite/core/mir/ssa_graph.h
+0
-0
paddle/fluid/lite/core/target_wrapper.h
paddle/fluid/lite/core/target_wrapper.h
+8
-2
paddle/fluid/lite/core/tensor.cc
paddle/fluid/lite/core/tensor.cc
+1
-1
paddle/fluid/lite/core/type_system.h
paddle/fluid/lite/core/type_system.h
+113
-0
paddle/fluid/lite/operators/fc_op_test.cc
paddle/fluid/lite/operators/fc_op_test.cc
+2
-2
未找到文件。
paddle/fluid/lite/core/CMakeLists.txt
浏览文件 @
f41d73b3
...
...
@@ -16,3 +16,5 @@ cc_test(test_op_lite SRCS op_lite_test.cc DEPS op_lite)
cc_test
(
test_tensor_lite SRCS tensor_test.cc
)
cc_test
(
test_executor_lite SRCS executor_test.cc DEPS executor_lite ops_lite host_kernels
)
cc_test
(
test_type_system SRCS type_system_test.cc DEPS type_system
)
add_subdirectory
(
mir
)
paddle/fluid/lite/core/context.cc
浏览文件 @
f41d73b3
...
...
@@ -16,4 +16,4 @@
// Created by chunwei on 19-2-22.
//
#include "context.h"
#include "
paddle/fluid/lite/core/
context.h"
paddle/fluid/lite/core/mir/CMakeLists.txt
0 → 100644
浏览文件 @
f41d73b3
cc_library
(
mir_pass SRCS pass.cc
)
cc_library
(
mir_node SRCS node.cc
)
cc_library
(
mir_ssa_graph SRCS ssa_graph.cc
)
\ No newline at end of file
paddle/fluid/lite/core/mir/node.cc
0 → 100644
浏览文件 @
f41d73b3
#include "paddle/fluid/lite/core/mir/node.h"
paddle/fluid/lite/core/mir/node.h
0 → 100644
浏览文件 @
f41d73b3
namespace
paddle
{
namespace
lite
{
namespace
mir
{
class
Node
{
public:
// Tell is instruction.
bool
IsInstruct
()
const
;
// Tell is an argument.
bool
IsArgument
()
const
;
};
}
// namespace mir
}
// namespace lite
}
// namespace paddle
\ No newline at end of file
paddle/fluid/lite/core/mir/pass.cc
0 → 100644
浏览文件 @
f41d73b3
#include "paddle/fluid/lite/core/mir/pass.h"
paddle/fluid/lite/core/mir/pass.h
0 → 100644
浏览文件 @
f41d73b3
paddle/fluid/lite/core/mir/ssa_graph.cc
0 → 100644
浏览文件 @
f41d73b3
#include "paddle/fluid/lite/core/mir/ssa_graph.h"
paddle/fluid/lite/core/mir/ssa_graph.h
0 → 100644
浏览文件 @
f41d73b3
paddle/fluid/lite/core/target_wrapper.h
浏览文件 @
f41d73b3
...
...
@@ -38,11 +38,17 @@ struct Place {
TargetType
target
{
TARGET
(
kHost
)};
PrecisionType
precision
{
PRECISION
(
kFloat
)};
DataLayoutType
layout
{
DATALAYOUT
(
kNCHW
)};
short
device
{
0
};
// device ID
Place
()
=
default
;
Place
(
TargetType
target
,
PrecisionType
precision
,
DataLayoutType
layout
=
DATALAYOUT
(
kNCHW
))
:
target
(
target
),
precision
(
precision
),
layout
(
layout
)
{}
DataLayoutType
layout
=
DATALAYOUT
(
kNCHW
),
short
device
=
0
)
:
target
(
target
),
precision
(
precision
),
layout
(
layout
),
device
(
device
)
{}
bool
operator
==
(
const
Place
&
other
)
const
{
return
target
==
other
.
target
&&
precision
==
other
.
precision
&&
layout
==
other
.
layout
&&
device
==
other
.
device
;
}
};
constexpr
const
int
kNumPrecisions
=
...
...
paddle/fluid/lite/core/tensor.cc
浏览文件 @
f41d73b3
...
...
@@ -24,7 +24,7 @@ std::ostream &operator<<(std::ostream &os, const DDim &dims) {
}
os
<<
"["
;
for
(
in
t
i
=
0
;
i
<
dims
.
size
()
-
1
;
i
++
)
{
for
(
size_
t
i
=
0
;
i
<
dims
.
size
()
-
1
;
i
++
)
{
os
<<
dims
[
i
]
<<
" "
;
}
os
<<
dims
.
back
()
<<
"]"
;
...
...
paddle/fluid/lite/core/type_system.h
浏览文件 @
f41d73b3
...
...
@@ -31,6 +31,119 @@
namespace
paddle
{
namespace
lite
{
// Type is the definition of all the types that supported by the Variable that
// represents as the input and output of an operator or kernel.
// The DNN system is simple, and the architecture can not process that many data
// types as a compiler, or that will turn out to a chaos.
//
// We should make sure that supported data types should be registered here, and
// keep the quantity small. And avoid using some special data types as op's IO,
// such as some runtime cache, that need to be avoided.
//
// TODO(Superjomn) Add operator/kernel-wise static checking to avoid unsupported
// type mixed in the system.
class
DataTypeBase
{
public:
// The Void type can cast to any other type.
// The Unsupported is the data type that developed include in the system, for
// example, some `std::set` is used as input of some operator. It wan't be
// analyzed or optimized by the system, that way results in many bugs in
// previous system, so it should be avoided.
enum
class
ID
:
int
{
Void
=
0
,
// unknown type that can be cast to any data type.
Unsupported
,
// Unsupported data type that will not be analyzed.
Tensor_Fp32_NCHW
,
Tensor_Int8_NCHW
,
Tensor_Int64_NCHW
,
NumTypes
,
// Must remains as last defined ID.
};
ID
id
()
const
{
return
id_
;
}
// type check.
bool
IsTensor
()
const
{
return
is_tensor_
;
}
bool
IsVoid
()
const
{
return
id_
==
ID
::
Void
;
}
bool
IsUnsupported
()
const
{
return
id_
==
ID
::
Unsupported
;
}
bool
IsTensorFp32NCHW
()
const
{
return
id_
==
ID
::
Tensor_Fp32_NCHW
;
}
bool
IsTensorInt8NCHW
()
const
{
return
id_
==
ID
::
Tensor_Int8_NCHW
;
}
bool
IsTensorInt64NCHW
()
const
{
return
id_
==
ID
::
Tensor_Int64_NCHW
;
}
int
num_types
()
const
{
return
static_cast
<
int
>
(
ID
::
NumTypes
);
}
protected:
// Can only extended by subclass.
DataTypeBase
(
ID
id
,
bool
is_tensor
)
:
id_
(
id
),
is_tensor_
(
is_tensor
)
{}
ID
id_
{
ID
::
Unsupported
};
bool
is_tensor_
{
false
};
};
/*
* Datatype with device info considered.
* NOTE A Type with different device is treated as different DeviceDataType.
*/
class
DeviceDataType
:
public
DataTypeBase
{
public:
TargetType
target
()
const
{
return
place_
.
target
;
}
PrecisionType
precision
()
const
{
return
place_
.
precision
;
}
DataLayoutType
layout
()
const
{
return
place_
.
layout
;
}
const
Place
&
place
()
const
{
return
place_
;
}
const
std
::
string
&
name
()
const
{
return
name_
;
}
bool
operator
==
(
const
DeviceDataType
&
other
)
{
return
id_
==
other
.
id
()
&&
place_
==
other
.
place
();
}
// Can cast to another type. This is heavily used in MIR, by determine whether
// is is possible to add a instruction to transform a type to another.
virtual
bool
TypeCastable
(
const
DeviceDataType
&
type
)
const
{
return
id_
==
type
.
id
();
}
virtual
~
DeviceDataType
()
=
default
;
protected:
DeviceDataType
(
ID
id
,
const
std
::
string
&
name
,
bool
is_tensor
,
TargetType
target
=
TargetType
::
kHost
,
PrecisionType
precision
=
PrecisionType
::
kFloat
,
DataLayoutType
layout
=
DataLayoutType
::
kNCHW
)
:
DataTypeBase
(
id
,
is_tensor
),
place_
{
target
,
precision
,
layout
},
name_
(
name
)
{}
protected:
Place
place_
;
const
std
::
string
name_
;
};
// -------------------------------- predefined types ---------------------------
class
Void
:
public
DeviceDataType
{
public:
Void
()
:
DeviceDataType
(
ID
::
Void
,
"Void"
,
false
/*is_tensor*/
)
{}
};
class
TensorFp32NCHW
:
public
DeviceDataType
{
public:
TensorFp32NCHW
(
TargetType
target
)
:
DeviceDataType
(
ID
::
Tensor_Fp32_NCHW
,
"TensorFp32NCHW"
,
true
/*is_tensor*/
,
target
,
PrecisionType
::
kFloat
,
DataLayoutType
::
kNCHW
)
{}
};
class
TensorInt8NCHW
:
public
DeviceDataType
{
public:
TensorInt8NCHW
(
TargetType
target
)
:
DeviceDataType
(
ID
::
Tensor_Int8_NCHW
,
"TensorInt8NCHW"
,
true
/*is_tensor*/
,
target
,
PrecisionType
::
kInt8
,
DataLayoutType
::
kNCHW
)
{}
};
class
TensorInt64NCHW
:
public
DeviceDataType
{
public:
TensorInt64NCHW
(
TargetType
target
)
:
DeviceDataType
(
ID
::
Tensor_Int64_NCHW
,
"TensorInt64NCHW"
,
true
/*is_tensor*/
,
target
,
PrecisionType
::
kInt8
,
DataLayoutType
::
kNCHW
)
{}
};
// ------------------------- end predefined types ---------------------------
// NOTE TypeSystem has some overhead, and better to be used in analysis phase.
class
TypeSystem
{
private:
...
...
paddle/fluid/lite/operators/fc_op_test.cc
浏览文件 @
f41d73b3
...
...
@@ -58,8 +58,8 @@ TEST(fc_op_lite, test) {
FcOpLite
fc
(
"fc"
);
fc
.
SetValidPlaces
({
OpLite
::
Place
{
TARGET
(
kHost
),
PRECISION
(
kFloat
)}});
fc
.
PickKernel
({
OpLite
::
Place
{
TARGET
(
kHost
),
PRECISION
(
kFloat
)}});
fc
.
SetValidPlaces
({
Place
{
TARGET
(
kHost
),
PRECISION
(
kFloat
)}});
fc
.
PickKernel
({
Place
{
TARGET
(
kHost
),
PRECISION
(
kFloat
)}});
fc
.
Attach
(
desc
,
&
scope
);
fc
.
Run
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录