Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
12a1a095
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看板
提交
12a1a095
编写于
3月 28, 2020
作者:
J
jackzhang235
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add set_input_layout
上级
97c2d205
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
69 addition
and
35 deletion
+69
-35
lite/api/cxx_api_impl.cc
lite/api/cxx_api_impl.cc
+6
-10
lite/api/paddle_api.cc
lite/api/paddle_api.cc
+32
-0
lite/api/paddle_api.h
lite/api/paddle_api.h
+19
-22
lite/core/device_info.cc
lite/core/device_info.cc
+5
-1
lite/core/device_info.h
lite/core/device_info.h
+4
-1
lite/core/mir/mlu_postprocess_pass.cc
lite/core/mir/mlu_postprocess_pass.cc
+3
-1
未找到文件。
lite/api/cxx_api_impl.cc
浏览文件 @
12a1a095
...
...
@@ -36,16 +36,12 @@ void CxxPaddleApiImpl::Init(const lite_api::CxxConfig &config) {
#endif
#ifdef LITE_WITH_MLU
Env
<
TARGET
(
kMLU
)
>::
Init
();
mlu_core_version_
=
config
.
mlu_core_version
();
mlu_core_number_
=
config
.
mlu_core_number
();
use_first_conv_
=
config
.
use_first_conv
();
mean_vec_
=
config
.
mean
();
std_vec_
=
config
.
std
();
lite
::
DeviceInfo
::
Global
().
SetMLURunMode
(
mlu_core_version_
,
mlu_core_number_
,
use_first_conv_
,
mean_vec_
,
std_vec_
);
lite
::
DeviceInfo
::
Global
().
SetMLURunMode
(
config
.
mlu_core_version
(),
config
.
mlu_core_number
(),
config
.
mlu_use_first_conv
(),
config
.
mlu_first_conv_mean
(),
config
.
mlu_first_conv_std
(),
config
.
mlu_input_layout
());
#endif // LITE_WITH_MLU
auto
places
=
config
.
valid_places
();
std
::
vector
<
std
::
string
>
passes
{};
...
...
lite/api/paddle_api.cc
浏览文件 @
12a1a095
...
...
@@ -203,6 +203,38 @@ void ConfigBase::set_threads(int threads) {
#endif
}
void
CxxConfig
::
mlu_set_mlu_core_version
(
lite_api
::
MLUCoreVersion
core_version
)
{
mlu_core_version_
=
core_version
;
}
void
CxxConfig
::
mlu_set_mlu_core_number
(
int
core_number
)
{
mlu_core_number_
=
core_number
;
}
void
CxxConfig
::
mlu_set_input_layout
()(
DataLayoutType
layout
)
{
mlu_input_layout_
=
layout
;
}
void
CxxConfig
::
mlu_set_use_first_conv
(
bool
use_first_conv
)
{
mlu_use_first_conv_
=
use_first_conv
;
}
void
CxxConfig
::
mlu_set_first_conv_mean
(
const
std
::
vector
<
float
>
&
mean
)
{
mlu_first_conv_mean_
=
mean
;
}
void
CxxConfig
::
mlu_set_first_conv_std
(
const
std
::
vector
<
float
>
&
std
)
{
mlu_first_conv_std_
=
std
;
}
lite_api
::
MLUCoreVersion
CxxConfig
::
mlu_core_version
()
const
{
return
mlu_core_version_
;
}
int
CxxConfig
::
mlu_core_number
()
const
{
return
mlu_core_number_
;
}
DataLayoutType
CxxConfig
::
mlu_input_layout
()
const
{
return
mlu_input_layout_
;
}
bool
CxxConfig
::
mlu_use_first_conv
()
const
{
return
mlu_use_first_conv_
;
}
std
::
vector
<
float
>
CxxConfig
::
mlu_first_conv_mean
()
const
{
return
mlu_first_conv_mean_
;
}
std
::
vector
<
float
>
CxxConfig
::
mlu_first_conv_std
()
const
{
return
mlu_first_conv_std_
;
}
// set model data in combined format, `set_model_from_file` refers to loading
// model from file, set_model_from_buffer refers to loading model from memory
// buffer
...
...
lite/api/paddle_api.h
浏览文件 @
12a1a095
...
...
@@ -106,11 +106,6 @@ class LITE_API PaddlePredictor {
protected:
int
threads_
{
1
};
lite_api
::
PowerMode
mode_
{
lite_api
::
LITE_POWER_NO_BIND
};
lite_api
::
MLUCoreVersion
mlu_core_version_
{
lite_api
::
MLU_270
};
int
mlu_core_number_
{
1
};
bool
use_first_conv_
{
false
};
std
::
vector
<
float
>
mean_vec_
;
std
::
vector
<
float
>
std_vec_
;
};
/// Base class for all the configs.
...
...
@@ -141,11 +136,13 @@ class LITE_API CxxConfig : public ConfigBase {
#ifdef LITE_WITH_X86
int
x86_math_library_math_threads_
=
1
;
#endif
bool
use_firstconv_
{
false
};
std
::
vector
<
float
>
mean_
=
{
0.0
f
};
std
::
vector
<
float
>
std_
=
{
1.0
f
};
lite_api
::
MLUCoreVersion
mlu_core_version_
{
lite_api
::
MLUCoreVersion
::
MLU_270
};
int
mlu_core_number_
{
1
};
DataLayoutType
mlu_input_layout_
{
DATALAYOUT
(
kNCHW
)};
bool
mlu_use_first_conv_
{
false
};
std
::
vector
<
float
>
mlu_first_conv_mean_
;
std
::
vector
<
float
>
mlu_first_conv_std_
;
public:
void
set_valid_places
(
const
std
::
vector
<
Place
>&
x
)
{
valid_places_
=
x
;
}
...
...
@@ -173,20 +170,20 @@ class LITE_API CxxConfig : public ConfigBase {
return
x86_math_library_math_threads_
;
}
#endif
void
set_use_firstconv
(
const
bool
firstconv
)
{
use_firstconv_
=
firstconv
;
}
void
set_mean
(
const
std
::
vector
<
float
>
mean
)
{
mean_
=
mean
;
}
void
set_std
(
const
std
::
vector
<
float
>
std
)
{
std_
=
std
;
}
void
set_mlu_core_version
(
lite_api
::
MLUCoreVersion
core_version
)
{
mlu_core_version_
=
core_version
;
}
void
set_mlu_core_number
(
int
core_number
)
{
mlu_core_number_
=
core_number
;
}
bool
use_first_conv
()
const
{
return
use_firstconv_
;
}
std
::
vector
<
float
>
mean
()
const
{
return
mean_
;
}
std
::
vector
<
float
>
std
()
const
{
return
std_
;
}
lite_api
::
MLUCoreVersion
mlu_core_version
()
const
{
return
mlu_core_version_
;
}
int
mlu_core_number
()
const
{
return
mlu_core_number_
;
}
void
mlu_set_mlu_core_version
(
lite_api
::
MLUCoreVersion
core_version
);
void
mlu_set_mlu_core_number
(
int
core_number
);
void
mlu_set_input_layout
()(
DataLayoutType
layout
);
void
mlu_set_use_first_conv
(
bool
use_first_conv
)
;
void
mlu_set_first_conv_mean
(
const
std
::
vector
<
float
>&
mean
);
void
mlu_set_first_conv_std
(
const
std
::
vector
<
float
>&
std
);
lite_api
::
MLUCoreVersion
mlu_core_version
()
const
;
int
mlu_core_number
()
const
;
DataLayoutType
mlu_input_layout
()
const
;
bool
mlu_use_first_conv
()
const
;
std
::
vector
<
float
>
mlu_first_conv_mean
()
const
;
std
::
vector
<
float
>
mlu_first_conv_std
()
const
;
};
/// MobileConfig is the config for the light weight predictor, it will skip
...
...
lite/core/device_info.cc
浏览文件 @
12a1a095
...
...
@@ -1093,7 +1093,8 @@ void DeviceInfo::SetMLURunMode(lite_api::MLUCoreVersion core_version,
int
core_number
,
bool
use_first_conv
,
const
std
::
vector
<
float
>&
mean_vec
,
const
std
::
vector
<
float
>&
std_vec
)
{
const
std
::
vector
<
float
>&
std_vec
,
DataLayoutType
input_layout
)
{
switch
(
core_version
)
{
case
(
lite_api
::
MLUCoreVersion
::
MLU_220
):
mlu_core_version_
=
CNML_MLU220
;
...
...
@@ -1109,6 +1110,7 @@ void DeviceInfo::SetMLURunMode(lite_api::MLUCoreVersion core_version,
use_first_conv_
=
use_first_conv
;
mean_vec_
=
mean_vec
;
std_vec_
=
std_vec
;
input_layout_
=
input_layout
;
}
cnmlCoreVersion_t
DeviceInfo
::
MLUCoreVersion
()
{
return
mlu_core_version_
;
}
...
...
@@ -1121,6 +1123,8 @@ const std::vector<float>& DeviceInfo::MeanVec() const { return mean_vec_; }
const
std
::
vector
<
float
>&
DeviceInfo
::
StdVec
()
const
{
return
std_vec_
;
}
const
DataLayoutType
InputLayout
()
const
{
return
input_layout_
;
}
#endif // LITE_WITH_MLU
void
DeviceInfo
::
SetRunMode
(
lite_api
::
PowerMode
mode
,
int
thread_num
)
{
...
...
lite/core/device_info.h
浏览文件 @
12a1a095
...
...
@@ -60,12 +60,14 @@ class DeviceInfo {
int
core_number
,
bool
use_first_conv
,
const
std
::
vector
<
float
>&
mean_vec
,
const
std
::
vector
<
float
>&
std_vec
);
const
std
::
vector
<
float
>&
std_vec
,
DataLayoutType
input_layout
);
cnmlCoreVersion_t
MLUCoreVersion
();
int
MLUCoreNumber
();
bool
UseFirstConv
();
const
std
::
vector
<
float
>&
MeanVec
()
const
;
const
std
::
vector
<
float
>&
StdVec
()
const
;
const
DataLayoutType
InputLayout
()
const
;
#endif
void
SetCache
(
int
l1size
,
int
l2size
,
int
l3size
);
void
SetArch
(
ARMArch
arch
)
{
arch_
=
arch
;
}
...
...
@@ -124,6 +126,7 @@ class DeviceInfo {
static
thread_local
bool
use_first_conv_
;
static
thread_local
std
::
vector
<
float
>
mean_vec_
;
static
thread_local
std
::
vector
<
float
>
std_vec_
;
static
thread_local
DataLayoutType
input_layout_
;
#endif
void
SetDotInfo
(
int
argc
,
...);
...
...
lite/core/mir/mlu_postprocess_pass.cc
浏览文件 @
12a1a095
...
...
@@ -539,7 +539,9 @@ void MLUPostprocessPass::Apply(const std::unique_ptr<SSAGraph>& graph) {
// 1: feed->arg_in->subgraph->... 2: ...->subgraph->arg_out->fetch;
// arg_in and arg_out are assumed to be NHWC which user should be aware of.
// Thus here we change these args' layout to NHWC
ModifyLayout
(
graph
.
get
());
if
(
lite
::
DeviceInfo
::
Global
().
InputLayout
()
==
DATALAYOUT
(
kNHWC
)
{
ModifyLayout
(
graph
.
get
());
}
if
(
lite
::
DeviceInfo
::
Global
().
UseFirstConv
())
{
GatherFirstConvNodes
(
graph
.
get
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录