Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
64abbeaa
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看板
提交
64abbeaa
编写于
4月 28, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
4月 28, 2020
浏览文件
操作
浏览文件
下载
差异文件
!705 add pynative cache
Merge pull request !705 from chujinjin/add_pynative_cache
上级
9c1a5db4
e2b0a281
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
31 addition
and
4 deletion
+31
-4
mindspore/ccsrc/device/ascend/ascend_memory_manager.cc
mindspore/ccsrc/device/ascend/ascend_memory_manager.cc
+1
-1
mindspore/ccsrc/pipeline/pipeline.cc
mindspore/ccsrc/pipeline/pipeline.cc
+2
-0
mindspore/ccsrc/pynative/pynative_execute.cc
mindspore/ccsrc/pynative/pynative_execute.cc
+8
-1
mindspore/ccsrc/pynative/pynative_execute.h
mindspore/ccsrc/pynative/pynative_execute.h
+3
-0
mindspore/ccsrc/session/ascend_session.cc
mindspore/ccsrc/session/ascend_session.cc
+14
-1
mindspore/ccsrc/session/ascend_session.h
mindspore/ccsrc/session/ascend_session.h
+2
-0
mindspore/ccsrc/session/session_basic.cc
mindspore/ccsrc/session/session_basic.cc
+1
-1
未找到文件。
mindspore/ccsrc/device/ascend/ascend_memory_manager.cc
浏览文件 @
64abbeaa
...
...
@@ -22,7 +22,7 @@ namespace mindspore {
namespace
device
{
namespace
ascend
{
const
uint64_t
kAscendDeviceMemGB
=
20
;
const
uint64_t
kAscendMemPoolGB
=
5
;
const
uint64_t
kAscendMemPoolGB
=
10
;
const
uint64_t
kAscendDeviceMemSize
=
(
kAscendDeviceMemGB
<<
30
);
const
uint64_t
kAscendMemPoolSize
=
(
kAscendMemPoolGB
<<
30
);
...
...
mindspore/ccsrc/pipeline/pipeline.cc
浏览文件 @
64abbeaa
...
...
@@ -38,6 +38,7 @@
#include "parallel/graph_util/get_parallel_info.h"
#include "device/kernel_runtime_manager.h"
#include "debug/trace.h"
#include "pynative/pynative_execute.h"
#if (ENABLE_GE || ENABLE_D)
#include "pipeline/pipeline_ge.h"
...
...
@@ -829,6 +830,7 @@ void FinalizeBackend() {
void
ClearResAtexit
()
{
MS_LOG
(
DEBUG
)
<<
"Pipeline clear all resource"
;
pynative
::
ClearPyNativeSession
();
device
::
KernelRuntimeManager
::
Instance
().
ClearRuntimeResource
();
ad
::
g_k_prims
.
clear
();
...
...
mindspore/ccsrc/pynative/pynative_execute.cc
浏览文件 @
64abbeaa
...
...
@@ -44,6 +44,7 @@ const std::set<std::string> vm_operators = {"partial", "depend", "make_ref", "ze
namespace
mindspore
{
namespace
pynative
{
static
std
::
shared_ptr
<
session
::
SessionBasic
>
session
=
nullptr
;
inline
ValuePtr
PyAttrValue
(
const
py
::
object
&
obj
)
{
ValuePtr
converted_ret
=
nullptr
;
bool
converted
=
parse
::
ConvertData
(
obj
,
&
converted_ret
);
...
...
@@ -310,7 +311,11 @@ py::object RunOpInMs(const OpExecInfoPtr &op_exec_info, PynativeStatusCode *stat
if
(
device_target
!=
kAscendDevice
&&
device_target
!=
kGPUDevice
)
{
MS_EXCEPTION
(
ArgumentError
)
<<
"Device target ["
<<
device_target
<<
"] is not supported in Pynative mode"
;
}
std
::
shared_ptr
<
session
::
SessionBasic
>
session
=
session
::
SessionFactory
::
Get
().
Create
(
device_target
);
if
(
session
==
nullptr
)
{
session
=
session
::
SessionFactory
::
Get
().
Create
(
device_target
);
}
MS_EXCEPTION_IF_NULL
(
session
);
session
->
Init
(
ms_context
->
device_id
());
...
...
@@ -407,5 +412,7 @@ py::tuple RunOp(const py::args &args) {
MS_LOG
(
INFO
)
<<
"RunOp end"
;
return
result
;
}
void
ClearPyNativeSession
()
{
session
=
nullptr
;
}
}
// namespace pynative
}
// namespace mindspore
mindspore/ccsrc/pynative/pynative_execute.h
浏览文件 @
64abbeaa
...
...
@@ -36,6 +36,9 @@ namespace py = pybind11;
py
::
object
RunOpInVM
(
const
OpExecInfoPtr
&
op_exec_info
,
PynativeStatusCode
*
status
);
py
::
tuple
RunOp
(
const
py
::
args
&
args
);
void
ClearPyNativeSession
();
}
// namespace pynative
}
// namespace mindspore
...
...
mindspore/ccsrc/session/ascend_session.cc
浏览文件 @
64abbeaa
...
...
@@ -249,10 +249,23 @@ void AscendSession::RunOpExecTask(const std::shared_ptr<KernelGraph> &kernel_gra
MS_LOG
(
INFO
)
<<
"Finish!"
;
}
bool
AscendSession
::
GraphCacheExist
(
const
GraphInfo
&
graph_info
)
const
{
if
(
run_op_graphs_
.
find
(
graph_info
)
!=
run_op_graphs_
.
end
())
{
return
true
;
}
return
false
;
}
void
AscendSession
::
BuildOp
(
const
OpRunInfo
&
op_run_info
,
const
GraphInfo
&
graph_info
,
const
std
::
vector
<
tensor
::
TensorPtr
>
&
input_tensors
,
const
std
::
vector
<
bool
>
&
tensors_mask
)
{
MS_LOG
(
INFO
)
<<
"Build op "
<<
op_run_info
.
op_name
<<
" start !"
;
if
(
GraphCacheExist
(
graph_info
))
{
MS_LOG
(
INFO
)
<<
"Build op "
<<
op_run_info
.
op_name
<<
" finish !"
;
return
;
}
// construct graph include one op
auto
graph
=
ConstructSingleOpGraph
(
op_run_info
,
input_tensors
,
tensors_mask
);
MS_EXCEPTION_IF_NULL
(
graph
);
...
...
@@ -267,6 +280,7 @@ void AscendSession::BuildOp(const OpRunInfo &op_run_info, const GraphInfo &graph
RunOpAdjustKernel
(
graph
);
BuildKernel
(
graph
);
run_op_graphs_
[
graph_info
]
=
graph
;
MS_LOG
(
INFO
)
<<
"Build op "
<<
op_run_info
.
op_name
<<
" finish !"
;
}
py
::
tuple
AscendSession
::
RunOp
(
const
OpRunInfo
&
op_run_info
,
const
GraphInfo
&
graph_info
,
...
...
@@ -291,7 +305,6 @@ py::tuple AscendSession::RunOp(const OpRunInfo &op_run_info, const GraphInfo &gr
}
py
::
object
tuple_obj
=
utils
::
cast
<
PyObjectRef
>
(
output_tensors
).
object_
;
py
::
tuple
tuple_tensors
=
py
::
cast
<
py
::
tuple
>
(
tuple_obj
);
run_op_graphs_
.
clear
();
MS_LOG
(
INFO
)
<<
"Run op "
<<
op_run_info
.
op_name
<<
" finish!"
;
return
tuple_tensors
;
}
...
...
mindspore/ccsrc/session/ascend_session.h
浏览文件 @
64abbeaa
...
...
@@ -111,6 +111,8 @@ class AscendSession : public SessionBasic {
std
::
vector
<
GraphType
>
&
GetGraphOrderType
(
GraphId
final_graph_id
);
// copy output of if and else
void
CopyOutputOfIf
(
GraphId
false_graph_id
);
// check if graph cache exist
bool
GraphCacheExist
(
const
GraphInfo
&
graph_info
)
const
;
// member variables
// key is final_graph_id,value is child graph execute order of final graph
...
...
mindspore/ccsrc/session/session_basic.cc
浏览文件 @
64abbeaa
...
...
@@ -125,7 +125,7 @@ BaseRef CreateOneTensor(const AnfNodePtr &node, size_t output_index, const Kerne
// if in paynative mode,data only copyed to host when user want to print data
auto
ms_context
=
MsContext
::
GetInstance
();
MS_EXCEPTION_IF_NULL
(
ms_context
);
if
(
ms_context
->
e
nable_pynative_infer
()
)
{
if
(
ms_context
->
e
xecution_mode
()
==
kPynativeMode
)
{
tensor
->
set_device_address
(
AnfAlgo
::
GetMutableOutputAddr
(
node
,
output_index
));
}
else
if
(
!
address
->
SyncDeviceToHost
(
trans
::
GetRuntimePaddingShape
(
node
,
output_index
),
LongToSize
(
tensor
->
data
().
nbytes
()),
tensor
->
data_type
(),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录