Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
正统之独孤求败
mindspore
提交
d22f5064
M
mindspore
项目概览
正统之独孤求败
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
0
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看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d22f5064
编写于
9月 03, 2020
作者:
L
lichenever
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add BatchNormEx op
上级
1c3fc5c4
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
86 addition
and
28 deletion
+86
-28
mindspore/ccsrc/frontend/parallel/ops_info/gather_v2_p_info.h
...spore/ccsrc/frontend/parallel/ops_info/gather_v2_p_info.h
+6
-8
mindspore/ccsrc/frontend/parallel/ops_info/ops_utils.h
mindspore/ccsrc/frontend/parallel/ops_info/ops_utils.h
+1
-0
mindspore/ccsrc/frontend/parallel/step_auto_parallel.cc
mindspore/ccsrc/frontend/parallel/step_auto_parallel.cc
+1
-1
mindspore/ccsrc/frontend/parallel/step_parallel.cc
mindspore/ccsrc/frontend/parallel/step_parallel.cc
+1
-2
mindspore/ccsrc/utils/comm_manager.cc
mindspore/ccsrc/utils/comm_manager.cc
+1
-1
tests/ut/python/parallel/test_batchnorm_ex_batch_parallel.py
tests/ut/python/parallel/test_batchnorm_ex_batch_parallel.py
+76
-0
tests/ut/python/parallel/test_sparse_gather_v2.py
tests/ut/python/parallel/test_sparse_gather_v2.py
+0
-16
未找到文件。
mindspore/ccsrc/frontend/parallel/ops_info/gather_v2_p_info.h
浏览文件 @
d22f5064
...
...
@@ -32,12 +32,13 @@ namespace parallel {
class
GatherV2PInfo
:
public
OperatorInfo
{
public:
GatherV2PInfo
(
const
std
::
string
&
name
,
const
Shapes
&
inputs_shape
,
const
Shapes
&
outputs_shape
,
const
PrimitiveAttrs
&
attrs
)
const
PrimitiveAttrs
&
attrs
,
const
std
::
string
&
replace_op_name
=
GATHERV2
)
:
OperatorInfo
(
name
,
inputs_shape
,
outputs_shape
,
attrs
,
std
::
make_shared
<
GatherV2PCost
>
()),
axis_
(
0
),
bias_
(
0
),
index_offset_
(
0
),
slice_size_
(
0
)
{}
slice_size_
(
0
),
replace_op_name_
(
replace_op_name
)
{}
~
GatherV2PInfo
()
override
=
default
;
Status
Init
(
const
StrategyPtr
&
strategy
)
override
;
Status
InitForCostModel
(
const
StrategyPtr
&
strategy
)
override
;
...
...
@@ -69,10 +70,10 @@ class GatherV2PInfo : public OperatorInfo {
int32_t
axis_
;
std
::
string
target_
=
DEVICE
;
std
::
string
replace_op_name_
=
GATHERV2
;
int64_t
bias_
;
int64_t
index_offset_
;
int64_t
slice_size_
;
std
::
string
replace_op_name_
=
GATHERV2
;
Shape
out_dev_matrix_shape_
;
Group
group_
;
bool
manual_split_
=
false
;
...
...
@@ -83,12 +84,9 @@ class GatherV2PInfo : public OperatorInfo {
class
SparseGatherV2Info
:
public
GatherV2PInfo
{
public:
SparseGatherV2Info
(
const
std
::
string
&
name
,
const
Shapes
&
inputs_shape
,
const
Shapes
&
outputs_shape
,
const
PrimitiveAttrs
&
attrs
)
:
GatherV2PInfo
(
name
,
inputs_shape
,
outputs_shape
,
attrs
)
{}
const
PrimitiveAttrs
&
attrs
,
const
std
::
string
&
replace_op_name
=
SPARSE_GATHERV2
)
:
GatherV2PInfo
(
name
,
inputs_shape
,
outputs_shape
,
attrs
,
replace_op_name
)
{}
~
SparseGatherV2Info
()
override
=
default
;
private:
std
::
string
replace_op_name_
=
SPARSE_GATHERV2
;
};
class
EmbeddingLookupInfo
:
public
GatherV2PInfo
{
...
...
mindspore/ccsrc/frontend/parallel/ops_info/ops_utils.h
浏览文件 @
d22f5064
...
...
@@ -197,6 +197,7 @@ constexpr char ARGMAXWITHVALUE[] = "ArgMaxWithValue";
constexpr
char
ARGMINWITHVALUE
[]
=
"ArgMinWithValue"
;
constexpr
char
CONV2D
[]
=
"Conv2D"
;
constexpr
char
FUSE_BATCH_NORM
[]
=
"FusedBatchNorm"
;
constexpr
char
FUSE_BATCH_NORM_EX
[]
=
"FusedBatchNormEx"
;
constexpr
char
BATCH_NORM
[]
=
"BatchNorm"
;
constexpr
char
LAYER_NORM
[]
=
"LayerNorm"
;
constexpr
char
POOLING
[]
=
"Pooling"
;
...
...
mindspore/ccsrc/frontend/parallel/step_auto_parallel.cc
浏览文件 @
d22f5064
...
...
@@ -263,7 +263,7 @@ bool IsSplittableOperator(const std::string &op_name) {
LOG
,
REDUCE_MEAN
,
REAL_DIV
,
SIGMOID
,
POW
,
MAXIMUM
,
MINIMUM
,
EQUAL
,
NOT_EQUAL
,
LOGICALNOT
,
GATHERV2
,
SQRT
,
CONCAT
,
STRIDEDSLICE
,
GET_NEXT
,
CAST
,
NEG
,
SQUARE
,
BATCH_MATMUL
,
EXPAND_DIMS
,
SQUEEZE
,
SPARSE_GATHERV2
,
TILE
,
DROPOUT
,
SOFTMAX_CROSS_ENTROPY_WITH_LOGITS
,
SIGMOID_CROSS_ENTROPY_WITH_LOGITS
,
SPARSE_SOFTMAX_CROSS_ENTROPY_WITH_LOGITS
,
EMBEDDING_LOOKUP
};
EMBEDDING_LOOKUP
,
FUSE_BATCH_NORM_EX
};
// clang-format on
auto
iter
=
splittable_op
.
find
(
op_name
);
...
...
mindspore/ccsrc/frontend/parallel/step_parallel.cc
浏览文件 @
d22f5064
...
...
@@ -570,8 +570,7 @@ std::vector<AnfNodePtr> ReplaceOpInput(const Operator &replace_op, const std::st
MS_LOG
(
EXCEPTION
)
<<
"Failure: "
<<
node
->
ToString
()
<<
" size is smaller than 2"
;
}
std
::
vector
<
AnfNodePtr
>
replace_input
=
{
NewValueNode
(
pyop_instance
),
node
->
input
(
1
)};
auto
prim
=
GetValueNode
<
PrimitivePtr
>
(
node
->
input
(
0
));
if
(
prim
->
name
()
==
EMBEDDING_LOOKUP
)
{
if
(
replace_op
.
first
==
EMBEDDING_LOOKUP
)
{
replace_input
=
{
NewValueNode
(
pyop_instance
),
node
->
input
(
1
),
node
->
input
(
2
)};
}
if
(
!
params
.
empty
())
{
...
...
mindspore/ccsrc/utils/comm_manager.cc
浏览文件 @
d22f5064
...
...
@@ -40,7 +40,7 @@ CommManager &CommManager::GetInstance() noexcept {
#define HCCL_RUN_CHECK(op_name, group, op) \
do { \
auto hccl_result = (op); \
if (hccl_result !=
tagHcclResult::HCCL_SUCCESS) {
\
if (hccl_result !=
0) {
\
MS_LOG(ERROR) << op_name << " failed: #" << group << "#"; \
return false; \
} \
...
...
tests/ut/python/parallel/test_batchnorm_ex_batch_parallel.py
0 → 100644
浏览文件 @
d22f5064
# Copyright 2020 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import
numpy
as
np
import
mindspore
as
ms
from
mindspore
import
Tensor
from
mindspore
import
context
from
mindspore.common.api
import
_executor
from
mindspore.common.parameter
import
Parameter
from
mindspore.ops
import
composite
as
C
from
mindspore.ops
import
operations
as
P
import
mindspore.nn
as
nn
from
tests.ut.python.ops.test_math_ops
import
VirtualLoss
grad_all
=
C
.
GradOperation
(
get_all
=
True
)
class
NetWithLoss
(
nn
.
Cell
):
def
__init__
(
self
,
network
):
super
(
NetWithLoss
,
self
).
__init__
()
self
.
loss
=
VirtualLoss
()
self
.
network
=
network
def
construct
(
self
,
x
,
y
,
b
):
predict
=
self
.
network
(
x
,
y
,
b
)
return
self
.
loss
(
predict
)
class
GradWrap
(
nn
.
Cell
):
def
__init__
(
self
,
network
):
super
(
GradWrap
,
self
).
__init__
()
self
.
network
=
network
def
construct
(
self
,
x
,
y
,
b
):
return
grad_all
(
self
.
network
)(
x
,
y
,
b
)
# model_parallel test
def
test_two_matmul_batchnorm_ex
():
class
Net
(
nn
.
Cell
):
def
__init__
(
self
,
strategy1
,
strategy2
):
super
().
__init__
()
self
.
matmul1
=
P
.
MatMul
().
set_strategy
(
strategy1
)
self
.
norm
=
P
.
FusedBatchNormEx
()
self
.
gamma
=
Parameter
(
Tensor
(
np
.
ones
([
64
]),
dtype
=
ms
.
float32
),
name
=
"gamma"
)
self
.
beta
=
Parameter
(
Tensor
(
np
.
ones
([
64
]),
dtype
=
ms
.
float32
),
name
=
"beta"
)
self
.
mean
=
Parameter
(
Tensor
(
np
.
ones
([
64
]),
dtype
=
ms
.
float32
),
name
=
"mean"
)
self
.
var
=
Parameter
(
Tensor
(
np
.
ones
([
64
]),
dtype
=
ms
.
float32
),
name
=
"var"
)
self
.
matmul2
=
P
.
MatMul
().
set_strategy
(
strategy2
)
def
construct
(
self
,
x
,
y
,
b
):
out
=
self
.
matmul1
(
x
,
y
)
out
=
self
.
norm
(
out
,
self
.
gamma
,
self
.
beta
,
self
.
mean
,
self
.
var
)[
0
]
out
=
self
.
matmul2
(
out
,
b
)
return
out
context
.
set_auto_parallel_context
(
parallel_mode
=
"auto_parallel"
,
device_num
=
8
)
strategy1
=
((
4
,
2
),
(
2
,
1
))
strategy2
=
((
1
,
8
),
(
8
,
1
))
net
=
GradWrap
(
NetWithLoss
(
Net
(
strategy1
,
strategy2
)))
net
.
set_auto_parallel
()
x
=
Tensor
(
np
.
ones
([
128
,
32
]),
dtype
=
ms
.
float32
)
y
=
Tensor
(
np
.
ones
([
32
,
64
]),
dtype
=
ms
.
float32
)
b
=
Tensor
(
np
.
ones
([
64
,
64
]),
dtype
=
ms
.
float32
)
_executor
.
compile
(
net
,
x
,
y
,
b
)
tests/ut/python/parallel/test_sparse_gather_v2.py
浏览文件 @
d22f5064
...
...
@@ -13,7 +13,6 @@
# limitations under the License.
# ============================================================================
import
numpy
as
np
import
pytest
import
mindspore
as
ms
import
mindspore.nn
as
nn
...
...
@@ -158,18 +157,6 @@ def test_gatherv2_semi_auto7():
_executor
.
compile
(
net
,
x
,
y
)
def
test_gatherv2_semi_auto8
():
context
.
set_auto_parallel_context
(
device_num
=
8
,
global_rank
=
0
,
parallel_mode
=
"semi_auto_parallel"
)
strategy1
=
((
8
,),
(
1
,
1
))
strategy2
=
((
4
,
2
),
(
4
,
2
))
net
=
GradWrap
(
NetWithLoss
(
Net
(
0
,
strategy1
,
strategy2
)))
net
.
set_auto_parallel
()
x
=
Tensor
(
np
.
ones
([
64
]),
dtype
=
ms
.
float32
)
y
=
Tensor
(
np
.
ones
([
64
,
64
]),
dtype
=
ms
.
float32
)
_executor
.
compile
(
net
,
x
,
y
)
def
test_gatherv2_auto0
():
context
.
set_auto_parallel_context
(
device_num
=
8
,
global_rank
=
0
,
parallel_mode
=
"auto_parallel"
)
net
=
GradWrap
(
NetWithLoss
(
Net
(
0
)))
...
...
@@ -188,7 +175,6 @@ def test_gatherv2_auto1():
_executor
.
compile
(
net
,
x
,
y
)
@
pytest
.
mark
.
skip
(
reason
=
"The transition from GatherV2 to EmbeddingLookup needs adjusting. by lichen"
)
def
test_gatherv2_cpu0
():
context
.
set_auto_parallel_context
(
device_num
=
8
,
global_rank
=
0
,
parallel_mode
=
"semi_auto_parallel"
)
strategy1
=
((
8
,
1
),
(
1
,
1
))
...
...
@@ -201,7 +187,6 @@ def test_gatherv2_cpu0():
_executor
.
compile
(
net
,
x
,
y
)
@
pytest
.
mark
.
skip
(
reason
=
"The transition from GatherV2 to EmbeddingLookup needs adjusting. by lichen"
)
def
test_gatherv2_cpu1
():
context
.
set_auto_parallel_context
(
device_num
=
16
,
global_rank
=
0
,
parallel_mode
=
"semi_auto_parallel"
)
strategy1
=
((
16
,
1
),
(
1
,
1
))
...
...
@@ -214,7 +199,6 @@ def test_gatherv2_cpu1():
_executor
.
compile
(
net
,
x
,
y
)
@
pytest
.
mark
.
skip
(
reason
=
"The transition from GatherV2 to EmbeddingLookup needs adjusting. by lichen"
)
def
test_gatherv2_cpu2
():
context
.
set_auto_parallel_context
(
device_num
=
8
,
global_rank
=
0
,
parallel_mode
=
"semi_auto_parallel"
)
strategy1
=
((
1
,
8
),
(
1
,
1
))
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录