Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
fcdc9c40
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fcdc9c40
编写于
8月 08, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
8月 08, 2020
浏览文件
操作
浏览文件
下载
差异文件
!4152 modify return type of Model::Import from std::shared_ptr<Model> to Model
Merge pull request !4152 from hangq/master
上级
867afc71
ca6c84b8
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
35 addition
and
25 deletion
+35
-25
build.sh
build.sh
+1
-1
mindspore/lite/include/model.h
mindspore/lite/include/model.h
+4
-4
mindspore/lite/src/model.cc
mindspore/lite/src/model.cc
+7
-4
mindspore/lite/src/model_impl.cc
mindspore/lite/src/model_impl.cc
+2
-2
mindspore/lite/src/model_impl.h
mindspore/lite/src/model_impl.h
+1
-1
mindspore/lite/test/ut/src/infer_test.cc
mindspore/lite/test/ut/src/infer_test.cc
+3
-3
mindspore/lite/tools/benchmark/benchmark.cc
mindspore/lite/tools/benchmark/benchmark.cc
+13
-8
mindspore/lite/tools/converter/quantizer/post_training.cc
mindspore/lite/tools/converter/quantizer/post_training.cc
+1
-1
mindspore/lite/tools/time_profile/time_profile.cc
mindspore/lite/tools/time_profile/time_profile.cc
+3
-1
未找到文件。
build.sh
浏览文件 @
fcdc9c40
...
...
@@ -397,7 +397,7 @@ checkndk() {
if
[
"
${
ANDROID_NDK
}
"
]
;
then
echo
-e
"
\e
[31mANDROID_NDK_PATH=
$ANDROID_NDK
\e
[0m"
else
echo
-e
"
\e
[31mplease set ANDROID_NDK
_PATH
in environment variable for example: export ANDROID_NDK=/root/usr/android-ndk-r20b/
\e
[0m"
echo
-e
"
\e
[31mplease set ANDROID_NDK in environment variable for example: export ANDROID_NDK=/root/usr/android-ndk-r20b/
\e
[0m"
exit
1
fi
}
...
...
mindspore/lite/include/model.h
浏览文件 @
fcdc9c40
...
...
@@ -45,7 +45,7 @@ class MS_API Model {
/// \param[in] size Define bytes numbers of model buffer.
///
/// \return Pointer of MindSpore Lite Model.
static
std
::
shared_ptr
<
Model
>
Import
(
const
char
*
model_buf
,
size_t
size
);
static
Model
*
Import
(
const
char
*
model_buf
,
size_t
size
);
/// \brief Constructor of MindSpore Lite Model using default value for parameters.
///
...
...
@@ -53,7 +53,7 @@ class MS_API Model {
Model
()
=
default
;
/// \brief Destructor of MindSpore Lite Model.
virtual
~
Model
()
=
default
;
virtual
~
Model
();
/// \brief Get MindSpore Lite Primitive by name.
///
...
...
@@ -70,13 +70,13 @@ class MS_API Model {
/// \brief Get MindSpore Lite ModelImpl.
///
/// \return A pointer of MindSpore Lite ModelImpl.
std
::
shared_ptr
<
ModelImpl
>
model_impl
();
ModelImpl
*
model_impl
();
/// \brief Free MetaGraph in MindSpore Lite Model.
void
FreeMetaGraph
();
protected:
std
::
shared_ptr
<
ModelImpl
>
model_impl_
=
nullptr
;
ModelImpl
*
model_impl_
=
nullptr
;
};
/// \brief ModelBuilder defined by MindSpore Lite.
...
...
mindspore/lite/src/model.cc
浏览文件 @
fcdc9c40
...
...
@@ -24,12 +24,16 @@
namespace
mindspore
::
lite
{
std
::
shared_ptr
<
Model
>
Model
::
Import
(
const
char
*
model_buf
,
size_t
size
)
{
auto
model
=
std
::
make_shared
<
Model
>
();
Model
*
Model
::
Import
(
const
char
*
model_buf
,
size_t
size
)
{
auto
model
=
new
Model
();
model
->
model_impl_
=
ModelImpl
::
Import
(
model_buf
,
size
);
return
model
;
}
Model
::~
Model
()
{
delete
(
this
->
model_impl_
);
}
lite
::
Primitive
*
Model
::
GetOp
(
const
std
::
string
&
name
)
const
{
MS_EXCEPTION_IF_NULL
(
model_impl_
);
return
const_cast
<
Primitive
*>
(
model_impl_
->
GetOp
(
name
));
...
...
@@ -45,9 +49,8 @@ const schema::MetaGraph *Model::GetMetaGraph() const {
return
model_impl_
->
GetMetaGraph
();
}
std
::
shared_ptr
<
ModelImpl
>
Model
::
model_impl
()
{
ModelImpl
*
Model
::
model_impl
()
{
MS_EXCEPTION_IF_NULL
(
model_impl_
);
return
this
->
model_impl_
;
}
}
// namespace mindspore::lite
mindspore/lite/src/model_impl.cc
浏览文件 @
fcdc9c40
...
...
@@ -20,7 +20,7 @@
#include "utils/log_adapter.h"
namespace
mindspore
::
lite
{
std
::
shared_ptr
<
ModelImpl
>
ModelImpl
::
Import
(
const
char
*
model_buf
,
size_t
size
)
{
ModelImpl
*
ModelImpl
::
Import
(
const
char
*
model_buf
,
size_t
size
)
{
MS_EXCEPTION_IF_NULL
(
model_buf
);
flatbuffers
::
Verifier
verify
((
const
uint8_t
*
)
model_buf
,
size
);
if
(
!
schema
::
VerifyMetaGraphBuffer
(
verify
))
{
...
...
@@ -33,7 +33,7 @@ std::shared_ptr<ModelImpl> ModelImpl::Import(const char *model_buf, size_t size)
return
nullptr
;
}
memcpy
(
inner_model_buf
,
model_buf
,
size
);
auto
model
=
std
::
make_shared
<
ModelImpl
>
(
inner_model_buf
,
size
);
auto
model
=
new
(
std
::
nothrow
)
ModelImpl
(
inner_model_buf
,
size
);
if
(
model
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"Create modelImpl failed"
;
return
nullptr
;
...
...
mindspore/lite/src/model_impl.h
浏览文件 @
fcdc9c40
...
...
@@ -27,7 +27,7 @@ namespace mindspore {
namespace
lite
{
class
ModelImpl
{
public:
static
std
::
shared_ptr
<
ModelImpl
>
Import
(
const
char
*
model_buf
,
size_t
size
);
static
ModelImpl
*
Import
(
const
char
*
model_buf
,
size_t
size
);
ModelImpl
()
=
default
;
explicit
ModelImpl
(
const
char
*
model_buf
,
size_t
size
)
:
model_buf_
(
model_buf
),
buf_size_
(
size
)
{
meta_graph
=
schema
::
GetMetaGraph
(
model_buf
);
...
...
mindspore/lite/test/ut/src/infer_test.cc
浏览文件 @
fcdc9c40
...
...
@@ -109,7 +109,7 @@ TEST_F(InferTest, TestConvNode) {
context
->
thread_num_
=
4
;
auto
session
=
session
::
LiteSession
::
CreateSession
(
context
);
ASSERT_NE
(
nullptr
,
session
);
auto
ret
=
session
->
CompileGraph
(
model
.
get
()
);
auto
ret
=
session
->
CompileGraph
(
model
);
ASSERT_EQ
(
lite
::
RET_OK
,
ret
);
auto
inputs
=
session
->
GetInputs
();
ASSERT_EQ
(
inputs
.
size
(),
1
);
...
...
@@ -206,7 +206,7 @@ TEST_F(InferTest, TestAddNode) {
context
->
thread_num_
=
4
;
auto
session
=
session
::
LiteSession
::
CreateSession
(
context
);
ASSERT_NE
(
nullptr
,
session
);
auto
ret
=
session
->
CompileGraph
(
model
.
get
()
);
auto
ret
=
session
->
CompileGraph
(
model
);
ASSERT_EQ
(
lite
::
RET_OK
,
ret
);
auto
inputs
=
session
->
GetInputs
();
ASSERT_EQ
(
inputs
.
size
(),
2
);
...
...
@@ -257,7 +257,7 @@ TEST_F(InferTest, TestModel) {
context
->
thread_num_
=
4
;
auto
session
=
session
::
LiteSession
::
CreateSession
(
context
);
ASSERT_NE
(
nullptr
,
session
);
auto
ret
=
session
->
CompileGraph
(
model
.
get
()
);
auto
ret
=
session
->
CompileGraph
(
model
);
ASSERT_EQ
(
lite
::
RET_OK
,
ret
);
auto
inputs
=
session
->
GetInputs
();
ASSERT_EQ
(
inputs
.
size
(),
1
);
...
...
mindspore/lite/tools/benchmark/benchmark.cc
浏览文件 @
fcdc9c40
...
...
@@ -371,7 +371,7 @@ int Benchmark::RunBenchmark(const std::string &deviceType) {
return
RET_ERROR
;
}
delete
[](
graphBuf
);
auto
context
=
new
(
std
::
nothrow
)
lite
::
Context
;
auto
context
=
new
(
std
::
nothrow
)
lite
::
Context
;
if
(
context
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"New context failed while running %s"
,
modelName
.
c_str
();
return
RET_ERROR
;
...
...
@@ -393,15 +393,16 @@ int Benchmark::RunBenchmark(const std::string &deviceType) {
}
context
->
thread_num_
=
_flags
->
numThreads
;
session
=
session
::
LiteSession
::
CreateSession
(
context
);
delete
(
context
);
delete
(
context
);
if
(
session
==
nullptr
)
{
MS_LOG
(
ERROR
)
<<
"CreateSession failed while running %s"
,
modelName
.
c_str
();
return
RET_ERROR
;
}
auto
ret
=
session
->
CompileGraph
(
model
.
get
()
);
auto
ret
=
session
->
CompileGraph
(
model
);
if
(
ret
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"CompileGraph failed while running %s"
,
modelName
.
c_str
();
delete
(
session
);
delete
(
session
);
delete
(
model
);
return
ret
;
}
msInputs
=
session
->
GetInputs
();
...
...
@@ -419,21 +420,24 @@ int Benchmark::RunBenchmark(const std::string &deviceType) {
auto
status
=
LoadInput
();
if
(
status
!=
0
)
{
MS_LOG
(
ERROR
)
<<
"Generate input data error"
;
delete
(
session
);
delete
(
session
);
delete
(
model
);
return
status
;
}
if
(
!
_flags
->
calibDataPath
.
empty
())
{
status
=
MarkAccuracy
();
if
(
status
!=
0
)
{
MS_LOG
(
ERROR
)
<<
"Run MarkAccuracy error: %d"
<<
status
;
delete
(
session
);
delete
(
session
);
delete
(
model
);
return
status
;
}
}
else
{
status
=
MarkPerformance
();
if
(
status
!=
0
)
{
MS_LOG
(
ERROR
)
<<
"Run MarkPerformance error: %d"
<<
status
;
delete
(
session
);
delete
(
session
);
delete
(
model
);
return
status
;
}
}
...
...
@@ -447,7 +451,8 @@ int Benchmark::RunBenchmark(const std::string &deviceType) {
calibData
.
clear
();
}
delete
(
session
);
delete
(
session
);
delete
(
model
);
return
RET_OK
;
}
...
...
mindspore/lite/tools/converter/quantizer/post_training.cc
浏览文件 @
fcdc9c40
...
...
@@ -920,7 +920,7 @@ STATUS PostTrainingQuantizer::DoQuantize(FuncGraphPtr funcGraph) {
return
RET_ERROR
;
}
auto
ret
=
session_
->
CompileGraph
(
model
.
get
()
);
auto
ret
=
session_
->
CompileGraph
(
model
);
if
(
ret
!=
lite
::
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"compile graph error"
;
return
RET_ERROR
;
...
...
mindspore/lite/tools/time_profile/time_profile.cc
浏览文件 @
fcdc9c40
...
...
@@ -278,7 +278,7 @@ int TimeProfile::RunTimeProfile() {
}
auto
model
=
lite
::
Model
::
Import
(
graphBuf
,
size
);
auto
ret
=
session_
->
CompileGraph
(
model
.
get
()
);
auto
ret
=
session_
->
CompileGraph
(
model
);
if
(
ret
!=
RET_OK
)
{
MS_LOG
(
ERROR
)
<<
"Compile graph failed."
;
return
RET_ERROR
;
...
...
@@ -336,6 +336,8 @@ int TimeProfile::RunTimeProfile() {
}
ms_inputs_
.
clear
();
delete
graphBuf
;
delete
session_
;
delete
model
;
return
ret
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录