Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
f7bf4bcd
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看板
提交
f7bf4bcd
编写于
6月 28, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
6月 28, 2020
浏览文件
操作
浏览文件
下载
差异文件
!2560 optimize the graph output of all nop node
Merge pull request !2560 from limingqi107/master
上级
80dd3321
4949f6ca
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
33 addition
and
10 deletion
+33
-10
mindspore/ccsrc/device/kernel_runtime.cc
mindspore/ccsrc/device/kernel_runtime.cc
+21
-6
mindspore/ccsrc/device/kernel_runtime.h
mindspore/ccsrc/device/kernel_runtime.h
+2
-2
mindspore/ccsrc/session/session_basic.cc
mindspore/ccsrc/session/session_basic.cc
+10
-2
未找到文件。
mindspore/ccsrc/device/kernel_runtime.cc
浏览文件 @
f7bf4bcd
...
...
@@ -30,6 +30,7 @@
#include "kernel/common_utils.h"
#include "kernel/oplib/oplib.h"
#include "ir/value.h"
#include "pre_activate/common/helper.h"
using
mindspore
::
kernel
::
Address
;
using
mindspore
::
kernel
::
AddressPtr
;
...
...
@@ -632,7 +633,7 @@ void KernelRuntime::AssignWorkSpaceMem(int flag, const AnfNodePtr &node) {
}
}
void
KernelRuntime
::
GenLaunchArgs
(
const
mindspore
::
kernel
::
KernelMod
&
kernel_mod
,
const
mindspore
::
AnfNodePtr
&
kernel
,
void
KernelRuntime
::
GenLaunchArgs
(
const
session
::
KernelGraph
&
graph
,
const
mindspore
::
AnfNodePtr
&
kernel
,
AddressPtrList
*
kernel_inputs
,
AddressPtrList
*
const
kernel_workspaces
,
AddressPtrList
*
kernel_outputs
)
{
MS_EXCEPTION_IF_NULL
(
kernel
);
...
...
@@ -644,9 +645,15 @@ void KernelRuntime::GenLaunchArgs(const mindspore::kernel::KernelMod &kernel_mod
if
(
AnfAlgo
::
GetCNodeName
(
cnode
)
==
kAtomicAddrCleanOpName
)
{
return
GenAddrCleanLaunchArgs
(
cnode
,
kernel_inputs
);
}
auto
is_all_nop_node
=
opt
::
IsAllNopNode
(
&
graph
);
for
(
size_t
i
=
0
;
i
<
AnfAlgo
::
GetInputTensorNum
(
kernel
);
++
i
)
{
auto
real_input
=
AnfAlgo
::
GetRealInputIndex
(
kernel
,
i
);
auto
device_address
=
AnfAlgo
::
GetPrevNodeOutputAddr
(
kernel
,
real_input
);
DeviceAddressPtr
device_address
;
if
(
is_all_nop_node
)
{
device_address
=
AnfAlgo
::
GetPrevNodeMutableOutputAddr
(
kernel
,
real_input
,
false
);
}
else
{
device_address
=
AnfAlgo
::
GetPrevNodeMutableOutputAddr
(
kernel
,
real_input
,
true
);
}
MS_EXCEPTION_IF_NULL
(
device_address
);
kernel
::
AddressPtr
input
=
std
::
make_shared
<
kernel
::
Address
>
();
MS_EXCEPTION_IF_NULL
(
input
);
...
...
@@ -656,8 +663,16 @@ void KernelRuntime::GenLaunchArgs(const mindspore::kernel::KernelMod &kernel_mod
kernel_inputs
->
emplace_back
(
input
);
}
for
(
size_t
i
=
0
;
i
<
kernel_mod
.
GetOutputSizeList
().
size
();
++
i
)
{
auto
device_address
=
AnfAlgo
::
GetOutputAddr
(
kernel
,
i
);
auto
kernel_mod
=
AnfAlgo
::
GetKernelMod
(
kernel
);
MS_EXCEPTION_IF_NULL
(
kernel_mod
);
for
(
size_t
i
=
0
;
i
<
kernel_mod
->
GetOutputSizeList
().
size
();
++
i
)
{
DeviceAddressPtr
device_address
;
if
(
is_all_nop_node
)
{
device_address
=
AnfAlgo
::
GetMutableOutputAddr
(
kernel
,
i
,
false
);
}
else
{
device_address
=
AnfAlgo
::
GetMutableOutputAddr
(
kernel
,
i
,
true
);
}
MS_EXCEPTION_IF_NULL
(
device_address
);
kernel
::
AddressPtr
output
=
std
::
make_shared
<
kernel
::
Address
>
();
MS_EXCEPTION_IF_NULL
(
output
);
output
->
addr
=
device_address
->
ptr_
;
...
...
@@ -666,7 +681,7 @@ void KernelRuntime::GenLaunchArgs(const mindspore::kernel::KernelMod &kernel_mod
kernel_outputs
->
emplace_back
(
output
);
}
for
(
size_t
i
=
0
;
i
<
kernel_mod
.
GetWorkspaceSizeList
().
size
();
++
i
)
{
for
(
size_t
i
=
0
;
i
<
kernel_mod
->
GetWorkspaceSizeList
().
size
();
++
i
)
{
auto
device_address
=
AnfAlgo
::
GetWorkspaceAddr
(
kernel
,
i
);
kernel
::
AddressPtr
workspace
=
std
::
make_shared
<
kernel
::
Address
>
();
MS_EXCEPTION_IF_NULL
(
workspace
);
...
...
@@ -721,7 +736,7 @@ bool KernelRuntime::LaunchKernelMod(const session::KernelGraph &graph) {
AddressPtrList
kernel_inputs
;
AddressPtrList
kernel_workspaces
;
AddressPtrList
kernel_outputs
;
GenLaunchArgs
(
*
kernel_mod
,
kernel
,
&
kernel_inputs
,
&
kernel_workspaces
,
&
kernel_outputs
);
GenLaunchArgs
(
graph
,
kernel
,
&
kernel_inputs
,
&
kernel_workspaces
,
&
kernel_outputs
);
auto
ret
=
kernel_mod
->
Launch
(
kernel_inputs
,
kernel_workspaces
,
kernel_outputs
,
stream_
);
if
(
!
ret
)
{
MS_LOG
(
ERROR
)
<<
"Launch kernel failed."
;
...
...
mindspore/ccsrc/device/kernel_runtime.h
浏览文件 @
f7bf4bcd
...
...
@@ -96,8 +96,8 @@ class KernelRuntime {
private:
void
AssignStaticMemoryOutput
(
const
session
::
KernelGraph
*
graph
);
void
GenLaunchArgs
(
const
mindspore
::
kernel
::
KernelMod
&
kernel_mod
,
const
AnfNodePtr
&
kernel
,
AddressPtrList
*
kernel_
inputs
,
AddressPtrList
*
kernel_
workspaces
,
AddressPtrList
*
kernel_outputs
);
void
GenLaunchArgs
(
const
session
::
KernelGraph
&
graph
,
const
AnfNodePtr
&
kernel
,
AddressPtrList
*
kernel_inputs
,
AddressPtrList
*
kernel_workspaces
,
AddressPtrList
*
kernel_outputs
);
bool
LaunchKernelMod
(
const
session
::
KernelGraph
&
graph
);
void
GenAddrCleanLaunchArgs
(
const
CNodePtr
&
cnode
,
AddressPtrList
*
kernel_inputs
);
size_t
CountNodeDeviceMemorySize
(
const
AnfNodePtr
&
node
,
size_t
output_index
);
...
...
mindspore/ccsrc/session/session_basic.cc
浏览文件 @
f7bf4bcd
...
...
@@ -81,7 +81,15 @@ BaseRef CreateOneTensor(const AnfNodePtr &node, size_t output_index, const Kerne
}
}
// if proccess reach here,it remarks item_with_index is a real node(Parameter,or executable CNode)
auto
address
=
AnfAlgo
::
GetOutputAddr
(
node
,
output_index
);
DeviceAddressPtr
address
;
auto
is_all_nop_node
=
opt
::
IsAllNopNode
(
&
graph
);
if
(
is_all_nop_node
)
{
// The graph does not remove the nop node.
address
=
AnfAlgo
::
GetMutableOutputAddr
(
node
,
output_index
,
false
);
}
else
{
// The graph removes the nop node.
address
=
AnfAlgo
::
GetMutableOutputAddr
(
node
,
output_index
,
true
);
}
MS_EXCEPTION_IF_NULL
(
address
);
auto
shape
=
AnfAlgo
::
GetOutputInferShape
(
node
,
output_index
);
TypeId
type_id
=
kNumberTypeFloat32
;
...
...
@@ -93,7 +101,7 @@ BaseRef CreateOneTensor(const AnfNodePtr &node, size_t output_index, const Kerne
auto
ms_context
=
MsContext
::
GetInstance
();
MS_EXCEPTION_IF_NULL
(
ms_context
);
if
(
ms_context
->
execution_mode
()
==
kPynativeMode
||
ms_context
->
device_target
()
==
kGPUDevice
)
{
tensor
->
set_device_address
(
AnfAlgo
::
GetMutableOutputAddr
(
node
,
output_index
)
);
tensor
->
set_device_address
(
address
);
tensor
->
set_dirty
(
false
);
}
else
if
(
!
address
->
SyncDeviceToHost
(
trans
::
GetRuntimePaddingShape
(
node
,
output_index
),
LongToSize
(
tensor
->
data
().
nbytes
()),
tensor
->
data_type
(),
tensor
->
data_c
()))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录