Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
8e0a526f
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看板
提交
8e0a526f
编写于
3月 06, 2020
作者:
D
DannyIsFunny
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add GetMutableTensor test=develop
上级
56a3e8d2
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
28 addition
and
0 deletion
+28
-0
lite/api/cxx_api.cc
lite/api/cxx_api.cc
+7
-0
lite/api/cxx_api.h
lite/api/cxx_api.h
+7
-0
lite/api/cxx_api_impl.cc
lite/api/cxx_api_impl.cc
+6
-0
lite/api/paddle_api.h
lite/api/paddle_api.h
+8
-0
未找到文件。
lite/api/cxx_api.cc
浏览文件 @
8e0a526f
...
@@ -314,9 +314,16 @@ void Predictor::GenRuntimeProgram() {
...
@@ -314,9 +314,16 @@ void Predictor::GenRuntimeProgram() {
const
lite
::
Tensor
*
Predictor
::
GetTensor
(
const
std
::
string
&
name
)
const
{
const
lite
::
Tensor
*
Predictor
::
GetTensor
(
const
std
::
string
&
name
)
const
{
auto
*
var
=
exec_scope_
->
FindVar
(
name
);
auto
*
var
=
exec_scope_
->
FindVar
(
name
);
CHECK
(
var
)
<<
"no variable named with "
<<
name
<<
" in exec_scope"
;
return
&
var
->
Get
<
lite
::
Tensor
>
();
return
&
var
->
Get
<
lite
::
Tensor
>
();
}
}
lite
::
Tensor
*
Predictor
::
GetMutableTensor
(
const
std
::
string
&
name
)
const
{
auto
*
var
=
exec_scope_
->
FindVar
(
name
);
CHECK
(
var
)
<<
"no variable named with "
<<
name
<<
" in exec_scope"
;
return
var
->
GetMutable
<
lite
::
Tensor
>
();
}
// get input by name
// get input by name
lite
::
Tensor
*
Predictor
::
GetInputByName
(
const
std
::
string
&
name
)
{
lite
::
Tensor
*
Predictor
::
GetInputByName
(
const
std
::
string
&
name
)
{
auto
element
=
std
::
find
(
input_names_
.
begin
(),
input_names_
.
end
(),
name
);
auto
element
=
std
::
find
(
input_names_
.
begin
(),
input_names_
.
end
(),
name
);
...
...
lite/api/cxx_api.h
浏览文件 @
8e0a526f
...
@@ -91,6 +91,9 @@ class LITE_API Predictor {
...
@@ -91,6 +91,9 @@ class LITE_API Predictor {
std
::
vector
<
const
lite
::
Tensor
*>
GetOutputs
()
const
;
std
::
vector
<
const
lite
::
Tensor
*>
GetOutputs
()
const
;
const
cpp
::
ProgramDesc
&
program_desc
()
const
;
const
cpp
::
ProgramDesc
&
program_desc
()
const
;
// get a mutable tensor according to its name
lite
::
Tensor
*
GetMutableTensor
(
const
std
::
string
&
name
);
// get a const tensor according to its name
const
lite
::
Tensor
*
GetTensor
(
const
std
::
string
&
name
)
const
;
const
lite
::
Tensor
*
GetTensor
(
const
std
::
string
&
name
)
const
;
const
RuntimeProgram
&
runtime_program
()
const
;
const
RuntimeProgram
&
runtime_program
()
const
;
...
@@ -142,8 +145,12 @@ class CxxPaddleApiImpl : public lite_api::PaddlePredictor {
...
@@ -142,8 +145,12 @@ class CxxPaddleApiImpl : public lite_api::PaddlePredictor {
std
::
vector
<
std
::
string
>
GetInputNames
()
override
;
std
::
vector
<
std
::
string
>
GetInputNames
()
override
;
std
::
vector
<
std
::
string
>
GetOutputNames
()
override
;
std
::
vector
<
std
::
string
>
GetOutputNames
()
override
;
// get tensor according to tensor's name
std
::
unique_ptr
<
const
lite_api
::
Tensor
>
GetTensor
(
std
::
unique_ptr
<
const
lite_api
::
Tensor
>
GetTensor
(
const
std
::
string
&
name
)
const
override
;
const
std
::
string
&
name
)
const
override
;
// get a mutable tensor according to tensor's name
std
::
unique_ptr
<
lite_api
::
Tensor
>
GetMutableTensor
(
const
std
::
string
&
name
)
override
;
// Get InputTebsor by name
// Get InputTebsor by name
std
::
unique_ptr
<
lite_api
::
Tensor
>
GetInputByName
(
std
::
unique_ptr
<
lite_api
::
Tensor
>
GetInputByName
(
...
...
lite/api/cxx_api_impl.cc
浏览文件 @
8e0a526f
...
@@ -101,6 +101,12 @@ std::unique_ptr<const lite_api::Tensor> CxxPaddleApiImpl::GetTensor(
...
@@ -101,6 +101,12 @@ std::unique_ptr<const lite_api::Tensor> CxxPaddleApiImpl::GetTensor(
return
std
::
unique_ptr
<
const
lite_api
::
Tensor
>
(
new
lite_api
::
Tensor
(
x
));
return
std
::
unique_ptr
<
const
lite_api
::
Tensor
>
(
new
lite_api
::
Tensor
(
x
));
}
}
std
::
unique_ptr
<
lite_api
::
Tensor
>
CxxPaddleApiImpl
::
GetMutableTensor
(
const
std
::
string
&
name
)
{
return
std
::
unique_ptr
<
lite_api
::
Tensor
>
(
new
lite_api
::
Tensor
(
raw_predictor_
.
GetMutableTensor
(
name
)));
}
std
::
unique_ptr
<
lite_api
::
Tensor
>
CxxPaddleApiImpl
::
GetInputByName
(
std
::
unique_ptr
<
lite_api
::
Tensor
>
CxxPaddleApiImpl
::
GetInputByName
(
const
std
::
string
&
name
)
{
const
std
::
string
&
name
)
{
return
std
::
unique_ptr
<
lite_api
::
Tensor
>
(
return
std
::
unique_ptr
<
lite_api
::
Tensor
>
(
...
...
lite/api/paddle_api.h
浏览文件 @
8e0a526f
...
@@ -94,6 +94,14 @@ class LITE_API PaddlePredictor {
...
@@ -94,6 +94,14 @@ class LITE_API PaddlePredictor {
virtual
std
::
unique_ptr
<
const
Tensor
>
GetTensor
(
virtual
std
::
unique_ptr
<
const
Tensor
>
GetTensor
(
const
std
::
string
&
name
)
const
=
0
;
const
std
::
string
&
name
)
const
=
0
;
/// Get a readonly tensor, return null if no one called `name` exists.
virtual
std
::
unique_ptr
<
const
Tensor
>
GetTensor
(
const
std
::
string
&
name
)
const
=
0
;
/// Get a mutable tensor, return null if on one called `name` exists
/// internal infereces API, not recommanded.
virtual
std
::
unique_ptr
<
Tensor
>
GetMutableTensor
(
const
std
::
string
&
name
)
const
=
0
;
/// Persist the optimized model to disk. This API is only supported by
/// Persist the optimized model to disk. This API is only supported by
/// CxxConfig, and the persisted model can be reused for MobileConfig.
/// CxxConfig, and the persisted model can be reused for MobileConfig.
virtual
void
SaveOptimizedModel
(
virtual
void
SaveOptimizedModel
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录