Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
79de8f4b
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看板
提交
79de8f4b
编写于
4月 16, 2020
作者:
X
Xiaoda Zhang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adjusting backward communication cost of some operators
上级
2d31ae97
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
69 addition
and
10 deletion
+69
-10
mindspore/ccsrc/parallel/auto_parallel/operator_costmodel.cc
mindspore/ccsrc/parallel/auto_parallel/operator_costmodel.cc
+67
-6
mindspore/ccsrc/parallel/auto_parallel/operator_costmodel.h
mindspore/ccsrc/parallel/auto_parallel/operator_costmodel.h
+1
-3
mindspore/ccsrc/parallel/ops_info/gather_v2_info.cc
mindspore/ccsrc/parallel/ops_info/gather_v2_info.cc
+1
-1
未找到文件。
mindspore/ccsrc/parallel/auto_parallel/operator_costmodel.cc
浏览文件 @
79de8f4b
...
...
@@ -287,6 +287,31 @@ double BatchParallelCost::GetBackwardComputationCost(const std::vector<mindspore
return
0.0
;
}
double
BatchParallelCost
::
GetBackwardCommCost
(
const
std
::
vector
<
TensorInfo
>&
inputs
,
const
std
::
vector
<
TensorInfo
>&
,
int32_t
stage_id
)
const
{
double
result
=
0.0
;
CheckGlobalDeviceManager
();
MS_EXCEPTION_IF_NULL
(
g_device_manager
);
auto
total_device_num
=
g_device_manager
->
GetDeviceListByStageId
(
stage_id
).
size
();
for
(
size_t
j
=
0
;
j
<
inputs
.
size
();
++
j
)
{
if
(
!
is_parameter_
[
j
])
{
continue
;
}
TensorInfo
input_a_tensor_info
=
inputs
[
j
];
Shape
input_a_shape
=
input_a_tensor_info
.
shape
();
Shape
input_a_slice_shape
=
input_a_tensor_info
.
slice_shape
();
int32_t
used_device_num
=
1
;
for
(
size_t
i
=
0
;
i
<
input_a_shape
.
size
();
++
i
)
{
used_device_num
*=
input_a_shape
[
i
]
/
input_a_slice_shape
[
i
];
}
if
(
total_device_num
!=
IntToSize
(
used_device_num
))
{
result
+=
ListProduct
(
input_a_slice_shape
)
*
static_cast
<
double
>
(
inputs_type_lengths_
[
0
]);
}
}
return
result
;
}
// return the per device communication cost in the forward phase.
double
PReLUCost
::
GetForwardCommCost
(
const
std
::
vector
<
TensorInfo
>&
,
const
std
::
vector
<
TensorInfo
>&
,
int32_t
)
const
{
// prelu does not need communication in the forward phase
...
...
@@ -432,8 +457,24 @@ double ReshapeCost::GetForwardCommCost(const std::vector<TensorInfo>& inputs, co
}
// return the per device communication cost in the backward phase.
double
ReshapeCost
::
GetBackwardCommCost
(
const
std
::
vector
<
TensorInfo
>&
,
const
std
::
vector
<
TensorInfo
>&
,
int32_t
)
const
{
return
0.0
;
double
ReshapeCost
::
GetBackwardCommCost
(
const
std
::
vector
<
TensorInfo
>&
inputs
,
const
std
::
vector
<
TensorInfo
>&
,
int32_t
stage_id
)
const
{
double
result
=
0.0
;
if
(
is_parameter_
[
0
])
{
TensorInfo
input1
=
inputs
[
0
];
MS_EXCEPTION_IF_NULL
(
g_device_manager
);
auto
total_device_num
=
g_device_manager
->
GetDeviceListByStageId
(
stage_id
).
size
();
Shape
input1_shape
=
input1
.
shape
();
Shape
input1_slice_shape
=
input1
.
slice_shape
();
int32_t
used_device_num
=
1
;
for
(
size_t
i
=
0
;
i
<
input1_shape
.
size
();
++
i
)
{
used_device_num
*=
input1_shape
[
i
]
/
input1_slice_shape
[
i
];
}
if
(
total_device_num
!=
IntToSize
(
used_device_num
))
{
result
=
ListProduct
(
input1_slice_shape
)
*
static_cast
<
double
>
(
inputs_type_lengths_
[
1
]);
}
}
return
result
;
}
// Return the per device computation cost in the forward phase. The cost is calculated according to the bytes
...
...
@@ -654,10 +695,30 @@ double GatherV2Cost::GetForwardCommCost(const std::vector<TensorInfo>&, const st
}
// return the per device communication cost in the backward phase.
double
GatherV2Cost
::
GetBackwardCommCost
(
const
std
::
vector
<
TensorInfo
>&
,
const
std
::
vector
<
TensorInfo
>&
,
int32_t
)
const
{
// GatherV2Cost does not need communication in the backward phase
return
0.0
;
double
GatherV2Cost
::
GetBackwardCommCost
(
const
std
::
vector
<
TensorInfo
>&
inputs
,
const
std
::
vector
<
TensorInfo
>&
,
int32_t
stage_id
)
const
{
double
result
=
0.0
;
CheckGlobalDeviceManager
();
MS_EXCEPTION_IF_NULL
(
g_device_manager
);
auto
total_device_num
=
g_device_manager
->
GetDeviceListByStageId
(
stage_id
).
size
();
for
(
size_t
j
=
0
;
j
<
inputs
.
size
();
++
j
)
{
if
(
!
is_parameter_
[
j
])
{
continue
;
}
TensorInfo
input_a_tensor_info
=
inputs
[
j
];
Shape
input_a_shape
=
input_a_tensor_info
.
shape
();
Shape
input_a_slice_shape
=
input_a_tensor_info
.
slice_shape
();
int32_t
used_device_num
=
1
;
for
(
size_t
i
=
0
;
i
<
input_a_shape
.
size
();
++
i
)
{
used_device_num
*=
input_a_shape
[
i
]
/
input_a_slice_shape
[
i
];
}
if
(
total_device_num
!=
IntToSize
(
used_device_num
))
{
result
+=
ListProduct
(
input_a_slice_shape
)
*
static_cast
<
double
>
(
inputs_type_lengths_
[
0
]);
}
}
return
result
;
}
double
GatherV2Cost
::
GetForwardComputationCost
(
const
std
::
vector
<
TensorInfo
>&
inputs
,
const
std
::
vector
<
TensorInfo
>&
,
...
...
mindspore/ccsrc/parallel/auto_parallel/operator_costmodel.h
浏览文件 @
79de8f4b
...
...
@@ -226,9 +226,7 @@ class BatchParallelCost : public OperatorCost {
double
GetForwardCommCost
(
const
std
::
vector
<
TensorInfo
>&
,
const
std
::
vector
<
TensorInfo
>&
,
int32_t
)
const
override
{
return
0.0
;
}
double
GetBackwardCommCost
(
const
std
::
vector
<
TensorInfo
>&
,
const
std
::
vector
<
TensorInfo
>&
,
int32_t
)
const
override
{
return
0.0
;
}
double
GetBackwardCommCost
(
const
std
::
vector
<
TensorInfo
>&
,
const
std
::
vector
<
TensorInfo
>&
,
int32_t
)
const
override
;
double
GetComputationCost
(
const
std
::
vector
<
TensorInfo
>&
inputs
,
const
std
::
vector
<
TensorInfo
>&
outputs
,
int32_t
stage_id
)
const
override
{
return
GetForwardComputationCost
(
inputs
,
outputs
,
stage_id
)
+
GetBackwardComputationCost
(
inputs
,
outputs
,
stage_id
);
...
...
mindspore/ccsrc/parallel/ops_info/gather_v2_info.cc
浏览文件 @
79de8f4b
...
...
@@ -291,7 +291,7 @@ Status GatherV2Info::GenerateStrategies(int32_t stage_id) {
}
is_auto_parallel_
=
true
;
Shape
input0_split
(
inputs_shape_
[
0
].
size
());
Shape
input0_split
(
inputs_shape_
[
0
].
size
()
,
1
);
Shapes
splittable_inputs
=
{
input0_split
};
std
::
vector
<
StrategyPtr
>
sp_vector
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录