Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
fbb0d3b5
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看板
未验证
提交
fbb0d3b5
编写于
12月 11, 2019
作者:
Y
Yuan Shuai
提交者:
GitHub
12月 11, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[LITE][OPENCL] add 3 data layouts for opencl image2d (#2561)
* add 3 layout for opencl image. test=develop
上级
4ae43560
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
83 addition
and
9 deletion
+83
-9
lite/CMakeLists.txt
lite/CMakeLists.txt
+4
-2
lite/api/paddle_place.cc
lite/api/paddle_place.cc
+15
-5
lite/api/paddle_place.h
lite/api/paddle_place.h
+5
-2
lite/api/python/pybind/pybind.cc
lite/api/python/pybind/pybind.cc
+3
-0
lite/core/op_registry.cc
lite/core/op_registry.cc
+23
-0
lite/core/op_registry.h
lite/core/op_registry.h
+33
-0
未找到文件。
lite/CMakeLists.txt
浏览文件 @
fbb0d3b5
...
...
@@ -179,8 +179,10 @@ if (LITE_WITH_LIGHT_WEIGHT_FRAMEWORK AND LITE_WITH_ARM)
add_dependencies
(
tiny_publish_cxx_lib paddle_light_api_shared
)
add_dependencies
(
tiny_publish_cxx_lib bundle_light_api
)
add_dependencies
(
publish_inference tiny_publish_cxx_lib
)
add_custom_command
(
TARGET tiny_publish_cxx_lib POST_BUILD
COMMAND
${
CMAKE_STRIP
}
"-s"
${
INFER_LITE_PUBLISH_ROOT
}
/cxx/lib/libpaddle_light_api_shared.so
)
if
(
NOT
"
${
CMAKE_BUILD_TYPE
}
"
STREQUAL
"Debug"
)
add_custom_command
(
TARGET tiny_publish_cxx_lib POST_BUILD
COMMAND
${
CMAKE_STRIP
}
"-s"
${
INFER_LITE_PUBLISH_ROOT
}
/cxx/lib/libpaddle_light_api_shared.so
)
endif
()
endif
()
endif
()
endif
()
...
...
lite/api/paddle_place.cc
浏览文件 @
fbb0d3b5
...
...
@@ -77,7 +77,8 @@ const std::string& PrecisionToStr(PrecisionType precision) {
}
const
std
::
string
&
DataLayoutToStr
(
DataLayoutType
layout
)
{
static
const
std
::
string
datalayout2string
[]
=
{
"unk"
,
"NCHW"
,
"any"
,
"NHWC"
};
static
const
std
::
string
datalayout2string
[]
=
{
"unk"
,
"NCHW"
,
"any"
,
"NHWC"
,
"ImageDefault"
,
"ImageFolder"
,
"ImageNW"
};
auto
x
=
static_cast
<
int
>
(
layout
);
CHECK_LT
(
x
,
static_cast
<
int
>
(
DATALAYOUT
(
NUM
)));
return
datalayout2string
[
x
];
...
...
@@ -115,8 +116,13 @@ const std::string& PrecisionRepr(PrecisionType precision) {
}
const
std
::
string
&
DataLayoutRepr
(
DataLayoutType
layout
)
{
static
const
std
::
string
datalayout2string
[]
=
{
"kUnk"
,
"kNCHW"
,
"kAny"
,
"kNHWC"
};
static
const
std
::
string
datalayout2string
[]
=
{
"kUnk"
,
"kNCHW"
,
"kAny"
,
"kNHWC"
,
"kImageDefault"
,
"kImageFolder"
,
"kImageNW"
};
auto
x
=
static_cast
<
int
>
(
layout
);
CHECK_LT
(
x
,
static_cast
<
int
>
(
DATALAYOUT
(
NUM
)));
return
datalayout2string
[
x
];
...
...
@@ -146,8 +152,12 @@ std::set<PrecisionType> ExpandValidPrecisions(PrecisionType precision) {
}
std
::
set
<
DataLayoutType
>
ExpandValidLayouts
(
DataLayoutType
layout
)
{
static
const
std
::
set
<
DataLayoutType
>
valid_set
(
{
DATALAYOUT
(
kNCHW
),
DATALAYOUT
(
kAny
),
DATALAYOUT
(
kNHWC
)});
static
const
std
::
set
<
DataLayoutType
>
valid_set
({
DATALAYOUT
(
kNCHW
),
DATALAYOUT
(
kAny
),
DATALAYOUT
(
kNHWC
),
DATALAYOUT
(
kImageDefault
),
DATALAYOUT
(
kImageFolder
),
DATALAYOUT
(
kImageNW
)});
if
(
layout
==
DATALAYOUT
(
kAny
))
{
return
valid_set
;
}
...
...
lite/api/paddle_place.h
浏览文件 @
fbb0d3b5
...
...
@@ -71,8 +71,11 @@ enum class DataLayoutType : int {
kUnk
=
0
,
kNCHW
=
1
,
kNHWC
=
3
,
kAny
=
2
,
// any data layout
NUM
=
4
,
// number of fields.
kImageDefault
=
4
,
// for opencl image2d
kImageFolder
=
5
,
// for opencl image2d
kImageNW
=
6
,
// for opencl image2d
kAny
=
2
,
// any data layout
NUM
=
7
,
// number of fields.
};
typedef
enum
{
...
...
lite/api/python/pybind/pybind.cc
浏览文件 @
fbb0d3b5
...
...
@@ -165,6 +165,9 @@ void BindLitePlace(py::module *m) {
py
::
enum_
<
DataLayoutType
>
(
*
m
,
"DataLayoutType"
)
.
value
(
"NCHW"
,
DataLayoutType
::
kNCHW
)
.
value
(
"NHWC"
,
DataLayoutType
::
kNHWC
)
.
value
(
"ImageDefault"
,
DataLayoutType
::
kImageDefault
)
.
value
(
"ImageFolder"
,
DataLayoutType
::
kImageFolder
)
.
value
(
"ImageNW"
,
DataLayoutType
::
kImageNW
)
.
value
(
"Any"
,
DataLayoutType
::
kAny
);
// Place
...
...
lite/core/op_registry.cc
浏览文件 @
fbb0d3b5
...
...
@@ -40,6 +40,18 @@ std::list<std::unique_ptr<KernelBase>> KernelRegistry::Create(
return Create<TARGET(target__), \
PRECISION(precision__), \
DATALAYOUT(kNHWC)>(op_type); \
case DATALAYOUT(kImageDefault): \
return Create<TARGET(target__), \
PRECISION(precision__), \
DATALAYOUT(kImageDefault)>(op_type); \
case DATALAYOUT(kImageFolder): \
return Create<TARGET(target__), \
PRECISION(precision__), \
DATALAYOUT(kImageFolder)>(op_type); \
case DATALAYOUT(kImageNW): \
return Create<TARGET(target__), \
PRECISION(precision__), \
DATALAYOUT(kImageNW)>(op_type); \
default: \
LOG(FATAL) << "unsupported kernel layout " << DataLayoutToStr(layout); \
}
...
...
@@ -147,6 +159,17 @@ KernelRegistry::KernelRegistry()
INIT_FOR
(
kOpenCL
,
kFloat
,
kAny
);
INIT_FOR
(
kOpenCL
,
kInt8
,
kNCHW
);
INIT_FOR
(
kOpenCL
,
kAny
,
kAny
);
INIT_FOR
(
kOpenCL
,
kFP16
,
kNCHW
);
INIT_FOR
(
kOpenCL
,
kFP16
,
kNHWC
);
INIT_FOR
(
kOpenCL
,
kFP16
,
kImageDefault
);
INIT_FOR
(
kOpenCL
,
kFP16
,
kImageFolder
);
INIT_FOR
(
kOpenCL
,
kFP16
,
kImageNW
);
INIT_FOR
(
kOpenCL
,
kFloat
,
kImageDefault
);
INIT_FOR
(
kOpenCL
,
kFloat
,
kImageFolder
);
INIT_FOR
(
kOpenCL
,
kFloat
,
kImageNW
);
INIT_FOR
(
kOpenCL
,
kAny
,
kImageDefault
);
INIT_FOR
(
kOpenCL
,
kAny
,
kImageFolder
);
INIT_FOR
(
kOpenCL
,
kAny
,
kImageNW
);
INIT_FOR
(
kNPU
,
kFloat
,
kNCHW
);
INIT_FOR
(
kNPU
,
kInt8
,
kNCHW
);
...
...
lite/core/op_registry.h
浏览文件 @
fbb0d3b5
...
...
@@ -176,6 +176,39 @@ class KernelRegistry final {
KernelRegistryForTarget
<
TARGET
(
kOpenCL
),
PRECISION
(
kAny
),
DATALAYOUT
(
kAny
)
>
*
,
//
KernelRegistryForTarget
<
TARGET
(
kOpenCL
),
PRECISION
(
kFP16
),
DATALAYOUT
(
kNCHW
)
>
*
,
//
KernelRegistryForTarget
<
TARGET
(
kOpenCL
),
PRECISION
(
kFP16
),
DATALAYOUT
(
kNHWC
)
>
*
,
//
KernelRegistryForTarget
<
TARGET
(
kOpenCL
),
PRECISION
(
kFP16
),
DATALAYOUT
(
kImageDefault
)
>
*
,
//
KernelRegistryForTarget
<
TARGET
(
kOpenCL
),
PRECISION
(
kFP16
),
DATALAYOUT
(
kImageFolder
)
>
*
,
//
KernelRegistryForTarget
<
TARGET
(
kOpenCL
),
PRECISION
(
kFP16
),
DATALAYOUT
(
kImageNW
)
>
*
,
//
KernelRegistryForTarget
<
TARGET
(
kOpenCL
),
PRECISION
(
kFloat
),
DATALAYOUT
(
kImageDefault
)
>
*
,
//
KernelRegistryForTarget
<
TARGET
(
kOpenCL
),
PRECISION
(
kFloat
),
DATALAYOUT
(
kImageFolder
)
>
*
,
//
KernelRegistryForTarget
<
TARGET
(
kOpenCL
),
PRECISION
(
kFloat
),
DATALAYOUT
(
kImageNW
)
>
*
,
//
KernelRegistryForTarget
<
TARGET
(
kOpenCL
),
PRECISION
(
kAny
),
DATALAYOUT
(
kImageDefault
)
>
*
,
//
KernelRegistryForTarget
<
TARGET
(
kOpenCL
),
PRECISION
(
kAny
),
DATALAYOUT
(
kImageFolder
)
>
*
,
//
KernelRegistryForTarget
<
TARGET
(
kOpenCL
),
PRECISION
(
kAny
),
DATALAYOUT
(
kImageNW
)
>
*
,
//
KernelRegistryForTarget
<
TARGET
(
kNPU
),
PRECISION
(
kAny
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录