Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
8da4c1a7
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看板
提交
8da4c1a7
编写于
6月 04, 2020
作者:
Y
yanghaoran
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
synchronize latest ascend software 04 Jun 2020
上级
39338c86
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
86 addition
and
68 deletion
+86
-68
CMakeLists.txt
CMakeLists.txt
+3
-0
cmake/dependency_graphengine.cmake
cmake/dependency_graphengine.cmake
+2
-0
cmake/external_libs/gtest.cmake
cmake/external_libs/gtest.cmake
+1
-1
cmake/external_libs/opencv.cmake
cmake/external_libs/opencv.cmake
+1
-1
cmake/external_libs/protobuf.cmake
cmake/external_libs/protobuf.cmake
+4
-1
graphengine
graphengine
+1
-1
mindspore/ccsrc/kernel/tbe/tbe_adapter.cc
mindspore/ccsrc/kernel/tbe/tbe_adapter.cc
+3
-1
mindspore/ccsrc/pre_activate/ascend/ir_fusion/momentum_lossscale_fusion.cc
...re_activate/ascend/ir_fusion/momentum_lossscale_fusion.cc
+2
-20
mindspore/ccsrc/transform/convert.cc
mindspore/ccsrc/transform/convert.cc
+3
-3
mindspore/ccsrc/transform/op_declare.cc
mindspore/ccsrc/transform/op_declare.cc
+22
-12
mindspore/ccsrc/transform/op_declare.h
mindspore/ccsrc/transform/op_declare.h
+6
-4
mindspore/ops/_op_impl/tbe/apply_ftrl.py
mindspore/ops/_op_impl/tbe/apply_ftrl.py
+10
-8
mindspore/ops/_op_impl/tbe/apply_momentum.py
mindspore/ops/_op_impl/tbe/apply_momentum.py
+9
-8
mindspore/ops/operations/nn_ops.py
mindspore/ops/operations/nn_ops.py
+12
-2
tests/st/networks/models/bert/bert_tdt_lossscale.py
tests/st/networks/models/bert/bert_tdt_lossscale.py
+3
-3
tests/ut/cpp/python_input/gtest_input/pre_activate/momentum_lossscale_fusion_test.py
...test_input/pre_activate/momentum_lossscale_fusion_test.py
+1
-1
tests/ut/cpp/stub/hccl/hccl_stub.cc
tests/ut/cpp/stub/hccl/hccl_stub.cc
+1
-1
tests/ut/python/ops/test_momentum.py
tests/ut/python/ops/test_momentum.py
+1
-1
tests/ut/python/ops/test_ops.py
tests/ut/python/ops/test_ops.py
+1
-0
未找到文件。
CMakeLists.txt
浏览文件 @
8da4c1a7
...
...
@@ -7,6 +7,9 @@ endif ()
include
(
${
CMAKE_SOURCE_DIR
}
/cmake/options.cmake
)
set
(
CMAKE_MODULE_PATH
${
CMAKE_MODULE_PATH
}
"
${
CMAKE_SOURCE_DIR
}
/cmake/modules/"
)
if
(
NOT CMAKE_SYSTEM_NAME MATCHES
"Windows"
)
add_compile_definitions
(
_GLIBCXX_USE_CXX11_ABI=0
)
endif
()
if
(
${
CMAKE_SYSTEM_NAME
}
MATCHES
"Darwin"
)
set
(
CMAKE_CXX_FLAGS_RELEASE
"$ENV{CXXFLAGS} -O2 -Werror -Wno-return-std-move -Wno-unused-private-field -Wno-unused-lambda-capture -Wno-sign-compare -Wno-overloaded-virtual -Wno-unneeded-internal-declaration -Wno-unused-variable -Wno-pessimizing-move -Wno-inconsistent-missing-override -DHALF_ENABLE_CPP11_USER_LITERALS=0 -D_FORTIFY_SOURCE=2"
)
...
...
cmake/dependency_graphengine.cmake
浏览文件 @
8da4c1a7
...
...
@@ -36,6 +36,7 @@ elseif (DEFINED ENV{D_LINK_PATH})
find_library
(
hccl libhccl.so
${
GE_LIB_PATH
}
)
find_library
(
cce libcce.so
${
GE_LIB_PATH
}
)
find_library
(
resource libresource.so
${
GE_LIB_PATH
}
)
find_library
(
error_manager liberror_manager.so
${
GE_LIB_PATH
}
)
else
()
# Ascend mode
if
(
DEFINED ENV{ASCEND_CUSTOM_PATH}
)
...
...
@@ -54,6 +55,7 @@ else()
find_library
(
msprof libmsprof.so
${
ASCEND_RUNTIME_PATH
}
)
find_library
(
register libregister.so
${
ASCEND_RUNTIME_PATH
}
)
find_library
(
resource libresource.so
${
ASCEND_RUNTIME_PATH
}
)
find_library
(
error_manager liberror_manager.so
${
ASCEND_RUNTIME_PATH
}
)
endif
()
# compile libraries from following directories
...
...
cmake/external_libs/gtest.cmake
浏览文件 @
8da4c1a7
set
(
gtest_CXXFLAGS
"-D_FORTIFY_SOURCE=2 -O2"
)
set
(
gtest_CXXFLAGS
"-D_FORTIFY_SOURCE=2 -
D_GLIBCXX_USE_CXX11_ABI=0 -
O2"
)
set
(
gtest_CFLAGS
"-D_FORTIFY_SOURCE=2 -O2"
)
mindspore_add_pkg
(
gtest
VER 1.8.0
...
...
cmake/external_libs/opencv.cmake
浏览文件 @
8da4c1a7
...
...
@@ -8,7 +8,7 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set
(
opencv_CXXFLAGS
"
${
opencv_CXXFLAGS
}
-Wno-attributes -Wno-unknown-pragmas"
)
set
(
opencv_CXXFLAGS
"
${
opencv_CXXFLAGS
}
-Wno-unused-value -Wno-implicit-fallthrough"
)
else
()
set
(
opencv_CXXFLAGS
"-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2"
)
set
(
opencv_CXXFLAGS
"-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -
D_GLIBCXX_USE_CXX11_ABI=0 -
O2"
)
set
(
opencv_CFLAGS
"-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -D_FORTIFY_SOURCE=2 -O2"
)
set
(
opencv_LDFLAGS
"-Wl,-z,relro,-z,now,-z,noexecstack"
)
endif
()
...
...
cmake/external_libs/protobuf.cmake
浏览文件 @
8da4c1a7
set
(
protobuf_USE_STATIC_LIBS ON
)
if
(
${
CMAKE_SYSTEM_NAME
}
MATCHES
"Darwin"
)
set
(
protobuf_CXXFLAGS
"-fstack-protector-all -Wno-uninitialized -Wno-unused-parameter -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2"
)
else
(
)
else
if
(
${
CMAKE_SYSTEM_NAME
}
MATCHES
"Windows"
)
set
(
protobuf_CXXFLAGS
"-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -O2"
)
else
()
set
(
protobuf_CXXFLAGS
"-fstack-protector-all -Wno-maybe-uninitialized -Wno-unused-parameter -fPIC -fvisibility=hidden -D_FORTIFY_SOURCE=2 -D_GLIBCXX_USE_CXX11_ABI=0 -O2"
)
endif
()
set
(
protobuf_LDFLAGS
"-Wl,-z,relro,-z,now,-z,noexecstack"
)
set
(
_ms_tmp_CMAKE_CXX_FLAGS
${
CMAKE_CXX_FLAGS
}
)
set
(
CMAKE_CXX_FLAGS
${
_ms_tmp_CMAKE_CXX_FLAGS
}
)
...
...
graphengine
@
9248a2fd
Subproject commit
579dcb75a990b533f9182733a6424f2bd66f0f23
Subproject commit
9248a2fd15ffc64d9d04b40c6b2836d1c94ca0b4
mindspore/ccsrc/kernel/tbe/tbe_adapter.cc
浏览文件 @
8da4c1a7
...
...
@@ -32,6 +32,8 @@ namespace tbe {
static
std
::
map
<
string
,
string
>
tbe_func_adapter_map
=
{
{
"softmax"
,
"softmax_v2"
},
{
"log_softmax"
,
"log_softmax_v2"
},
{
"apply_momentum"
,
"apply_momentum_d"
},
{
"apply_ftrl"
,
"apply_ftrl_d"
},
{
"re_lu6"
,
"relu6"
},
{
"re_lu6_grad"
,
"relu6_grad"
},
{
"re_lu"
,
"relu"
},
...
...
@@ -89,7 +91,7 @@ static std::map<string, string> tbe_func_adapter_map = {
{
"batch_to_space_nd"
,
"batch_to_space_nd_d"
},
{
"resize_bilinear"
,
"resize_bilinear_v2_d"
},
{
"resize_bilinear_grad"
,
"resize_bilinear_v2_grad"
},
{
"adam"
,
"apply_adam"
},
{
"adam"
,
"apply_adam
_d
"
},
{
"r_oi_align"
,
"roi_align"
},
{
"r_oi_align_grad"
,
"roi_align_grad"
},
{
"i_ou"
,
"iou"
},
...
...
mindspore/ccsrc/pre_activate/ascend/ir_fusion/momentum_lossscale_fusion.cc
浏览文件 @
8da4c1a7
...
...
@@ -32,19 +32,6 @@ bool CheckValueNodeInputOfMul(const AnfNodePtr &node) {
std
::
vector
<
size_t
>
mul_input_shape
=
AnfAlgo
::
GetOutputInferShape
(
node
,
0
);
return
mul_input_shape
.
empty
()
||
(
mul_input_shape
.
size
()
==
1
&&
mul_input_shape
[
0
]
==
1
);
}
void
AddInputToOutput
(
const
FuncGraphPtr
&
func_graph
,
const
CNodePtr
&
old_cnode
,
const
AnfNodePtr
&
new_node
,
std
::
vector
<
AnfNodePtr
>
*
new_outputs
)
{
MS_EXCEPTION_IF_NULL
(
old_cnode
);
MS_EXCEPTION_IF_NULL
(
new_node
);
MS_EXCEPTION_IF_NULL
(
new_outputs
);
auto
node_to_output
=
old_cnode
->
input
(
kAccumIndex
+
1
);
MS_EXCEPTION_IF_NULL
(
node_to_output
);
AbstractBasePtrList
abstract_list
{
old_cnode
->
abstract
(),
node_to_output
->
abstract
()};
auto
abstract_tuple
=
std
::
make_shared
<
abstract
::
AbstractTuple
>
(
abstract_list
);
new_node
->
set_abstract
(
abstract_tuple
);
// Create Output
CreateMultipleOutputsOfAnfNode
(
func_graph
,
new_node
,
kFusedMulApplyMomentumOutputNum
,
new_outputs
);
}
}
// namespace
const
BaseRef
MomentumLossscaleFusion
::
DefinePattern
()
const
{
...
...
@@ -94,14 +81,9 @@ const AnfNodePtr MomentumLossscaleFusion::Process(const FuncGraphPtr &func_graph
input_names_value
[
3
]
=
"x1"
;
input_names_value
.
emplace_back
(
"x2"
);
AnfAlgo
::
SetNodeAttr
(
kAttrInputNames
,
MakeValue
(
input_names_value
),
new_node
);
new_node
->
set_abstract
(
node
->
abstract
());
new_node
->
set_scope
(
node
->
scope
());
// Create Outputs
std
::
vector
<
AnfNodePtr
>
new_outputs
;
AddInputToOutput
(
func_graph
,
cnode
,
new_node
,
&
new_outputs
);
if
(
new_outputs
.
size
()
!=
kFusedMulApplyMomentumOutputNum
)
{
MS_LOG
(
EXCEPTION
)
<<
"Failed to create outputs of "
<<
new_node
->
DebugString
();
}
return
new_outputs
[
0
];
return
new_node
;
}
}
// namespace opt
}
// namespace mindspore
mindspore/ccsrc/transform/convert.cc
浏览文件 @
8da4c1a7
...
...
@@ -212,7 +212,7 @@ std::unordered_map<std::string, OpAdapterDescPtr> &DfGraphConvertor::get_adpt_ma
{
string
(
kNameIOU
),
ADPT_DESC
(
Iou
)},
{
string
(
kNameGreaterEqual
),
ADPT_DESC
(
GreaterEqual
)},
{
string
(
kNameSlice
),
ADPT_DESC
(
SliceD
)},
{
string
(
kNameApplyMomentum
),
ADPT_DESC
(
ApplyMomentum
)},
{
string
(
kNameApplyMomentum
),
ADPT_DESC
(
ApplyMomentum
D
)},
{
string
(
kNameMaxPool
),
ADPT_DESC
(
MaxPool
)},
{
string
(
kNameAvgPool
),
ADPT_DESC
(
AvgPool
)},
{
string
(
kNameMaxPoolWithArgmax
),
ADPT_DESC
(
MaxPoolWithArgmax
)},
...
...
@@ -395,7 +395,7 @@ std::unordered_map<std::string, OpAdapterDescPtr> &DfGraphConvertor::get_adpt_ma
{
string
(
kNameDepthToSpace
),
ADPT_DESC
(
DepthToSpace
)},
{
string
(
kNameSign
),
ADPT_DESC
(
Sign
)},
{
string
(
kNameRound
),
ADPT_DESC
(
Round
)},
{
string
(
kNameApplyFtrl
),
ADPT_DESC
(
ApplyFtrl
)},
{
string
(
kNameApplyFtrl
),
ADPT_DESC
(
ApplyFtrl
D
)},
{
string
(
kNameDiag
),
ADPT_DESC
(
Diag
)},
{
string
(
kNameDiagPart
),
ADPT_DESC
(
DiagPart
)},
{
string
(
kNameSpaceToBatch
),
ADPT_DESC
(
SpaceToBatchD
)},
...
...
@@ -409,7 +409,7 @@ std::unordered_map<std::string, OpAdapterDescPtr> &DfGraphConvertor::get_adpt_ma
{
string
(
kNameSquareSumAll
),
ADPT_DESC
(
SquareSumAll
)}};
#ifdef ENABLE_GE
adpt_map
[
string
(
kNamePrint
)]
=
ADPT_DESC
(
Print
);
adpt_map
[
string
(
kNameApplyAdam
)]
=
ADPT_DESC
(
ApplyAdam
);
adpt_map
[
string
(
kNameApplyAdam
)]
=
ADPT_DESC
(
ApplyAdam
D
);
#endif
return
adpt_map
;
}
...
...
mindspore/ccsrc/transform/op_declare.cc
浏览文件 @
8da4c1a7
...
...
@@ -127,11 +127,12 @@ INPUT_MAP(Constant) = EMPTY_INPUT_MAP;
ATTR_MAP
(
Constant
)
=
{{
"value"
,
ATTR_DESC
(
value
,
AnyTraits
<
AnyValue
>
())}};
OUTPUT_MAP
(
Constant
)
=
{{
0
,
OUTPUT_DESC
(
y
)}};
// ApplyMomentum
INPUT_MAP
(
ApplyMomentum
)
=
{
// ApplyMomentum
D
INPUT_MAP
(
ApplyMomentum
D
)
=
{
{
1
,
INPUT_DESC
(
var
)},
{
2
,
INPUT_DESC
(
accum
)},
{
3
,
INPUT_DESC
(
lr
)},
{
4
,
INPUT_DESC
(
grad
)},
{
5
,
INPUT_DESC
(
momentum
)}};
ATTR_MAP
(
ApplyMomentum
)
=
{{
"use_nesterov"
,
ATTR_DESC
(
use_nesterov
,
AnyTraits
<
bool
>
())}};
OUTPUT_MAP
(
ApplyMomentum
)
=
{{
0
,
OUTPUT_DESC
(
var
)}};
ATTR_MAP
(
ApplyMomentumD
)
=
{{
"use_nesterov"
,
ATTR_DESC
(
use_nesterov
,
AnyTraits
<
bool
>
())},
{
"use_locking"
,
ATTR_DESC
(
use_locking
,
AnyTraits
<
bool
>
())}};
OUTPUT_MAP
(
ApplyMomentumD
)
=
{{
0
,
OUTPUT_DESC
(
var
)},
{
1
,
OUTPUT_DESC
(
accum
)}};
// ScalarSummary
INPUT_MAP
(
Summary
)
=
{{
2
,
INPUT_DESC
(
x
)}};
...
...
@@ -470,7 +471,16 @@ INPUT_MAP(ApplyAdam) = {{1, INPUT_DESC(var)}, {2, INPUT_DESC(m)},
{
10
,
INPUT_DESC
(
grad
)}};
ATTR_MAP
(
ApplyAdam
)
=
{{
"use_locking"
,
ATTR_DESC
(
use_locking
,
AnyTraits
<
bool
>
())},
{
"use_nesterov"
,
ATTR_DESC
(
use_nesterov
,
AnyTraits
<
bool
>
())}};
OUTPUT_MAP
(
ApplyAdam
)
=
{{
0
,
OUTPUT_DESC
(
var
)},
{
1
,
OUTPUT_DESC
(
m
)},
{
2
,
OUTPUT_DESC
(
v
)}};
OUTPUT_MAP
(
ApplyAdam
)
=
{{
0
,
OUTPUT_DESC
(
var
)}};
// ApplyAdamD
INPUT_MAP
(
ApplyAdamD
)
=
{{
1
,
INPUT_DESC
(
var
)},
{
2
,
INPUT_DESC
(
m
)},
{
3
,
INPUT_DESC
(
v
)},
{
4
,
INPUT_DESC
(
beta1_power
)},
{
5
,
INPUT_DESC
(
beta2_power
)},
{
6
,
INPUT_DESC
(
lr
)},
{
7
,
INPUT_DESC
(
beta1
)},
{
8
,
INPUT_DESC
(
beta2
)},
{
9
,
INPUT_DESC
(
epsilon
)},
{
10
,
INPUT_DESC
(
grad
)}};
ATTR_MAP
(
ApplyAdamD
)
=
{{
"use_locking"
,
ATTR_DESC
(
use_locking
,
AnyTraits
<
bool
>
())},
{
"use_nesterov"
,
ATTR_DESC
(
use_nesterov
,
AnyTraits
<
bool
>
())}};
OUTPUT_MAP
(
ApplyAdamD
)
=
{{
0
,
OUTPUT_DESC
(
var
)},
{
1
,
OUTPUT_DESC
(
m
)},
{
2
,
OUTPUT_DESC
(
v
)}};
// Relu6
INPUT_MAP
(
Relu6
)
=
{{
1
,
INPUT_DESC
(
x
)}};
...
...
@@ -823,7 +833,7 @@ OUTPUT_MAP(RealDiv) = {{0, OUTPUT_DESC(y)}};
// Cast
INPUT_MAP
(
Cast
)
=
{{
1
,
INPUT_DESC
(
x
)}};
INPUT_ATTR_MAP
(
Cast
)
=
{{
2
,
ATTR_DESC
(
dst_type
,
AnyTraits
<
GEType
>
())}};
ATTR_MAP
(
Cast
)
=
{{
"Truncate"
,
ATTR_DESC
(
truncate
,
AnyTraits
<
bool
>
())}}
;
ATTR_MAP
(
Cast
)
=
EMPTY_ATTR_MAP
;
OUTPUT_MAP
(
Cast
)
=
{{
0
,
OUTPUT_DESC
(
y
)}};
// Reciprocal
...
...
@@ -1194,12 +1204,12 @@ INPUT_MAP(Round) = {{1, INPUT_DESC(x)}};
ATTR_MAP
(
Round
)
=
EMPTY_ATTR_MAP
;
OUTPUT_MAP
(
Round
)
=
{{
0
,
OUTPUT_DESC
(
y
)}};
// ApplyFtrl
INPUT_MAP
(
ApplyFtrl
)
=
{{
1
,
INPUT_DESC
(
var
)},
{
2
,
INPUT_DESC
(
accum
)},
{
3
,
INPUT_DESC
(
linear
)},
{
4
,
INPUT_DESC
(
grad
)},
{
5
,
INPUT_DESC
(
lr
)},
{
6
,
INPUT_DESC
(
l1
)},
{
7
,
INPUT_DESC
(
l2
)},
{
8
,
INPUT_DESC
(
lr_power
)}};
ATTR_MAP
(
ApplyFtrl
)
=
{{
"use_locking"
,
ATTR_DESC
(
use_locking
,
AnyTraits
<
bool
>
())}};
OUTPUT_MAP
(
ApplyFtrl
)
=
{{
0
,
OUTPUT_DESC
(
v
ar
)}};
// ApplyFtrl
D
INPUT_MAP
(
ApplyFtrl
D
)
=
{{
1
,
INPUT_DESC
(
var
)},
{
2
,
INPUT_DESC
(
accum
)},
{
3
,
INPUT_DESC
(
linear
)},
{
4
,
INPUT_DESC
(
grad
)},
{
5
,
INPUT_DESC
(
lr
)},
{
6
,
INPUT_DESC
(
l1
)},
{
7
,
INPUT_DESC
(
l2
)},
{
8
,
INPUT_DESC
(
lr_power
)}};
ATTR_MAP
(
ApplyFtrl
D
)
=
{{
"use_locking"
,
ATTR_DESC
(
use_locking
,
AnyTraits
<
bool
>
())}};
OUTPUT_MAP
(
ApplyFtrl
D
)
=
{{
0
,
OUTPUT_DESC
(
var
)},
{
1
,
OUTPUT_DESC
(
accum
)},
{
2
,
OUTPUT_DESC
(
line
ar
)}};
// Diag
INPUT_MAP
(
Diag
)
=
{{
1
,
INPUT_DESC
(
x
)}};
...
...
mindspore/ccsrc/transform/op_declare.h
浏览文件 @
8da4c1a7
...
...
@@ -120,6 +120,8 @@ DECLARE_OP_ADAPTER(ResizeNearestNeighborV2Grad)
DECLARE_OP_USE_OUTPUT
(
ResizeNearestNeighborV2Grad
)
DECLARE_OP_ADAPTER
(
ApplyAdam
)
DECLARE_OP_USE_OUTPUT
(
ApplyAdam
)
DECLARE_OP_ADAPTER
(
ApplyAdamD
)
DECLARE_OP_USE_OUTPUT
(
ApplyAdamD
)
DECLARE_OP_ADAPTER
(
Relu6
)
DECLARE_OP_USE_OUTPUT
(
Relu6
)
DECLARE_OP_ADAPTER
(
Relu6Grad
)
...
...
@@ -319,8 +321,8 @@ DECLARE_OP_ADAPTER(Assign)
DECLARE_OP_USE_OUTPUT
(
Assign
)
DECLARE_OP_ADAPTER
(
Constant
)
DECLARE_OP_USE_OUTPUT
(
Constant
)
DECLARE_OP_ADAPTER
(
ApplyMomentum
)
DECLARE_OP_USE_OUTPUT
(
ApplyMomentum
)
DECLARE_OP_ADAPTER
(
ApplyMomentum
D
)
DECLARE_OP_USE_OUTPUT
(
ApplyMomentum
D
)
// ** Summary Operations **
DECLARE_OP_ADAPTER
(
Summary
)
...
...
@@ -454,8 +456,8 @@ DECLARE_OP_ADAPTER(LarsV2Update)
DECLARE_OP_USE_OUTPUT
(
LarsV2Update
)
DECLARE_OP_ADAPTER
(
Round
)
DECLARE_OP_USE_OUTPUT
(
Round
)
DECLARE_OP_ADAPTER
(
ApplyFtrl
)
DECLARE_OP_USE_OUTPUT
(
ApplyFtrl
)
DECLARE_OP_ADAPTER
(
ApplyFtrl
D
)
DECLARE_OP_USE_OUTPUT
(
ApplyFtrl
D
)
DECLARE_OP_ADAPTER
(
SparseApplyFtrlD
)
DECLARE_OP_USE_OUTPUT
(
SparseApplyFtrlD
)
DECLARE_OP_ADAPTER
(
Diag
)
...
...
mindspore/ops/_op_impl/tbe/apply_ftrl.py
浏览文件 @
8da4c1a7
...
...
@@ -32,30 +32,32 @@ apply_ftrl_op_info = TBERegOp("ApplyFtrl") \
.
input
(
6
,
"l2"
,
False
,
"required"
,
"all"
)
\
.
input
(
7
,
"lr_power"
,
False
,
"required"
,
"all"
)
\
.
output
(
0
,
"var"
,
False
,
"required"
,
"all"
)
\
.
output
(
1
,
"accum"
,
False
,
"required"
,
"all"
)
\
.
output
(
2
,
"linear"
,
False
,
"required"
,
"all"
)
\
.
dtype_format
(
DataType
.
F16_5HD
,
DataType
.
F16_5HD
,
DataType
.
F16_5HD
,
DataType
.
F16_5HD
,
DataType
.
F16_5HD
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_5HD
)
\
DataType
.
F16_5HD
,
DataType
.
F16_5HD
,
DataType
.
F16_5HD
)
\
.
dtype_format
(
DataType
.
F16_FracZ
,
DataType
.
F16_FracZ
,
DataType
.
F16_FracZ
,
DataType
.
F16_FracZ
,
DataType
.
F16_FracZ
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_FracZ
)
\
DataType
.
F16_FracZ
,
DataType
.
F16_FracZ
,
DataType
.
F16_FracZ
)
\
.
dtype_format
(
DataType
.
F16_C1HWNCoC0
,
DataType
.
F16_C1HWNCoC0
,
DataType
.
F16_C1HWNCoC0
,
DataType
.
F16_C1HWNCoC0
,
DataType
.
F16_C1HWNCoC0
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_C1HWNCoC0
)
\
DataType
.
F16_C1HWNCoC0
,
DataType
.
F16_C1HWNCoC0
,
DataType
.
F16_C1HWNCoC0
)
\
.
dtype_format
(
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
)
\
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
)
\
.
dtype_format
(
DataType
.
F32_5HD
,
DataType
.
F32_5HD
,
DataType
.
F32_5HD
,
DataType
.
F32_5HD
,
DataType
.
F32_5HD
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_5HD
)
\
DataType
.
F32_5HD
,
DataType
.
F32_5HD
,
DataType
.
F32_5HD
)
\
.
dtype_format
(
DataType
.
F32_FracZ
,
DataType
.
F32_FracZ
,
DataType
.
F32_FracZ
,
DataType
.
F32_FracZ
,
DataType
.
F32_FracZ
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_FracZ
)
\
DataType
.
F32_FracZ
,
DataType
.
F32_FracZ
,
DataType
.
F32_FracZ
)
\
.
dtype_format
(
DataType
.
F32_C1HWNCoC0
,
DataType
.
F32_C1HWNCoC0
,
DataType
.
F32_C1HWNCoC0
,
DataType
.
F32_C1HWNCoC0
,
DataType
.
F32_C1HWNCoC0
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_C1HWNCoC0
)
\
DataType
.
F32_C1HWNCoC0
,
DataType
.
F32_C1HWNCoC0
,
DataType
.
F32_C1HWNCoC0
)
\
.
dtype_format
(
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
)
\
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
)
\
.
get_op_info
()
...
...
mindspore/ops/_op_impl/tbe/apply_momentum.py
浏览文件 @
8da4c1a7
...
...
@@ -30,22 +30,23 @@ apply_momentum_op_info = TBERegOp("ApplyMomentum") \
.
input
(
3
,
"grad"
,
False
,
"required"
,
"all"
)
\
.
input
(
4
,
"momentum"
,
False
,
"required"
,
"all"
)
\
.
output
(
0
,
"var"
,
False
,
"required"
,
"all"
)
\
.
output
(
1
,
"accum"
,
False
,
"required"
,
"all"
)
\
.
dtype_format
(
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
)
\
DataType
.
F16_Default
,
DataType
.
F16_Default
,
DataType
.
F16_Default
)
\
.
dtype_format
(
DataType
.
F16_5HD
,
DataType
.
F16_5HD
,
DataType
.
F16_Default
,
DataType
.
F16_5HD
,
DataType
.
F16_Default
,
DataType
.
F16_5HD
)
\
DataType
.
F16_Default
,
DataType
.
F16_5HD
,
DataType
.
F16_5HD
)
\
.
dtype_format
(
DataType
.
F16_C1HWNCoC0
,
DataType
.
F16_C1HWNCoC0
,
DataType
.
F16_Default
,
DataType
.
F16_C1HWNCoC0
,
DataType
.
F16_Default
,
DataType
.
F16_C1HWNCoC0
)
\
DataType
.
F16_Default
,
DataType
.
F16_C1HWNCoC0
,
DataType
.
F16_C1HWNCoC0
)
\
.
dtype_format
(
DataType
.
F16_FracZ
,
DataType
.
F16_FracZ
,
DataType
.
F16_Default
,
DataType
.
F16_FracZ
,
DataType
.
F16_Default
,
DataType
.
F16_FracZ
)
\
DataType
.
F16_Default
,
DataType
.
F16_FracZ
,
DataType
.
F16_FracZ
)
\
.
dtype_format
(
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
)
\
DataType
.
F32_Default
,
DataType
.
F32_Default
,
DataType
.
F32_Default
)
\
.
dtype_format
(
DataType
.
F32_5HD
,
DataType
.
F32_5HD
,
DataType
.
F32_Default
,
DataType
.
F32_5HD
,
DataType
.
F32_Default
,
DataType
.
F32_5HD
)
\
DataType
.
F32_Default
,
DataType
.
F32_5HD
,
DataType
.
F32_5HD
)
\
.
dtype_format
(
DataType
.
F32_C1HWNCoC0
,
DataType
.
F32_C1HWNCoC0
,
DataType
.
F32_Default
,
DataType
.
F32_C1HWNCoC0
,
DataType
.
F32_Default
,
DataType
.
F32_C1HWNCoC0
)
\
DataType
.
F32_Default
,
DataType
.
F32_C1HWNCoC0
,
DataType
.
F32_C1HWNCoC0
)
\
.
dtype_format
(
DataType
.
F32_FracZ
,
DataType
.
F32_FracZ
,
DataType
.
F32_Default
,
DataType
.
F32_FracZ
,
DataType
.
F32_Default
,
DataType
.
F32_FracZ
)
\
DataType
.
F32_Default
,
DataType
.
F32_FracZ
,
DataType
.
F32_FracZ
)
\
.
get_op_info
()
...
...
mindspore/ops/operations/nn_ops.py
浏览文件 @
8da4c1a7
...
...
@@ -1507,8 +1507,11 @@ class ApplyMomentum(PrimitiveWithInfer):
def
__init__
(
self
,
use_nesterov
=
False
,
use_locking
=
False
,
gradient_scale
=
1.0
):
self
.
init_prim_io_names
(
inputs
=
[
'variable'
,
'accumulation'
,
'learning_rate'
,
'gradient'
,
'momentum'
],
outputs
=
[
'output'
])
self
.
is_tbe
=
context
.
get_context
(
"device_target"
)
==
"Ascend"
def
infer_shape
(
self
,
v_shape
,
a_shape
,
l_shape
,
g_shape
,
m_shape
):
if
self
.
is_tbe
:
return
v_shape
,
v_shape
return
v_shape
def
infer_dtype
(
self
,
v_dtype
,
a_dtype
,
l_dtype
,
g_dtype
,
m_dtype
):
...
...
@@ -1519,6 +1522,8 @@ class ApplyMomentum(PrimitiveWithInfer):
validator
.
check_scalar_or_tensor_type_same
({
"l_dtype"
:
l_dtype
},
valid_types
,
self
.
name
)
validator
.
check_scalar_or_tensor_type_same
({
"g_dtype"
:
g_dtype
},
valid_types
,
self
.
name
)
validator
.
check_scalar_or_tensor_type_same
({
"m_dtype"
:
m_dtype
},
valid_types
,
self
.
name
)
if
self
.
is_tbe
:
return
g_dtype
,
g_dtype
return
g_dtype
...
...
@@ -2810,13 +2815,13 @@ class SparseApplyAdagrad(PrimitiveWithInfer):
validator
.
check
(
'var_shape[1:]'
,
var_shape
[
1
:],
'grad_shape[1:]'
,
grad_shape
[
1
:],
Rel
.
EQ
,
self
.
name
)
validator
.
check_integer
(
"indices rank"
,
len
(
indices_shape
),
1
,
Rel
.
EQ
,
self
.
name
)
validator
.
check
(
'grad_shape[0]'
,
grad_shape
[
0
],
'indices_shape[0]'
,
indices_shape
[
0
],
Rel
.
EQ
,
self
.
name
)
return
var_shape
return
var_shape
,
accum_shape
def
infer_dtype
(
self
,
var_type
,
accum_type
,
grad_type
,
indices_type
):
args
=
{
'var'
:
var_type
,
'accum'
:
accum_type
,
'grad'
:
grad_type
}
validator
.
check_tensor_type_same
(
args
,
(
mstype
.
float32
,),
self
.
name
)
validator
.
check_tensor_type_same
({
'indices'
:
indices_type
},
[
mstype
.
int32
],
self
.
name
)
return
var_type
return
var_type
,
accum_type
class
ApplyProximalAdagrad
(
PrimitiveWithInfer
):
...
...
@@ -3074,11 +3079,14 @@ class ApplyFtrl(PrimitiveWithInfer):
self
.
init_prim_io_names
(
inputs
=
[
'var'
,
'accum'
,
'linear'
,
'grad'
,
'lr'
,
'l1'
,
'l2'
,
'lr_power'
],
outputs
=
[
'output'
])
self
.
use_locking
=
validator
.
check_value_type
(
"use_locking"
,
use_locking
,
[
bool
],
self
.
name
)
self
.
is_tbe
=
context
.
get_context
(
"device_target"
)
==
"Ascend"
def
infer_shape
(
self
,
var_shape
,
accum_shape
,
linear_shape
,
grad_shape
,
lr_shape
,
l1_shape
,
l2_shape
,
lr_power_shape
):
validator
.
check
(
'var shape'
,
var_shape
,
'accum shape'
,
accum_shape
,
Rel
.
EQ
,
self
.
name
)
validator
.
check
(
'var shape'
,
var_shape
,
'linear shape'
,
linear_shape
,
Rel
.
EQ
,
self
.
name
)
if
self
.
is_tbe
:
return
var_shape
,
var_shape
,
var_shape
return
var_shape
def
infer_dtype
(
self
,
var_type
,
accum_type
,
linear_type
,
grad_type
,
lr_type
,
l1_type
,
l2_type
,
lr_power_type
):
...
...
@@ -3090,6 +3098,8 @@ class ApplyFtrl(PrimitiveWithInfer):
validator
.
check_scalar_or_tensor_type_same
({
"l1"
:
l1_type
},
valid_types
,
self
.
name
)
validator
.
check_scalar_or_tensor_type_same
({
"l2"
:
l2_type
},
valid_types
,
self
.
name
)
validator
.
check_scalar_or_tensor_type_same
({
"lr_power"
:
lr_power_type
},
valid_types
,
self
.
name
)
if
self
.
is_tbe
:
return
var_type
,
var_type
,
var_type
return
var_type
...
...
tests/st/networks/models/bert/bert_tdt_lossscale.py
浏览文件 @
8da4c1a7
...
...
@@ -199,10 +199,10 @@ def test_bert_percision():
# assertion occurs while the loss value, overflow state or loss_scale value is wrong
loss_value
=
np
.
array
(
callback
.
loss_list
)
assert
np
.
allclose
(
loss_value
[
0
],
12.20
7198
,
0
,
0.000001
)
assert
np
.
allclose
(
loss_value
[
0
],
12.20
6575
,
0
,
0.000001
)
expect_loss_value
=
[
12.20
7198
,
11.980881
,
11.984844
,
11.879381
,
11.832978
,
12.411333
,
12.009284
,
12.62
1277
,
12.223178
,
12.42738
5
]
expect_loss_value
=
[
12.20
6575
,
11.980493
,
11.984225
,
11.878742
,
11.832555
,
12.410444
,
12.008799
,
12.62
0619
,
12.22254
,
12.426105
5
]
print
(
"loss value: {}"
.
format
(
loss_value
))
assert
np
.
allclose
(
loss_value
,
expect_loss_value
,
0
,
0.0005
)
...
...
tests/ut/cpp/python_input/gtest_input/pre_activate/momentum_lossscale_fusion_test.py
浏览文件 @
8da4c1a7
...
...
@@ -47,6 +47,6 @@ def test_momentum_lossscale_fusion(tag):
@
fns
def
after
(
input0
,
input1
,
input2
,
input3
,
input4
):
return
make_tuple
(
tuple_getitem
(
FusedMulApplyMomentum
(
input0
,
input1
,
input2
,
input3
,
input4
,
constant
),
0
))
return
make_tuple
(
FusedMulApplyMomentum
(
input0
,
input1
,
input2
,
input3
,
input4
,
constant
))
return
fns
[
tag
]
tests/ut/cpp/stub/hccl/hccl_stub.cc
浏览文件 @
8da4c1a7
...
...
@@ -103,7 +103,7 @@ hcclResult_t hcom_receive(const char *tag, void *outputPtr, u64 count, hcclDataT
/* 获取梯度参数切分方案 */
hcclResult_t
hcom_get_split_strategy
(
const
char
*
group
,
const
struct
model_feature
*
feature
,
u32
maxSegmentNum
,
u32
*
segmentNum
,
u32
*
segmentIdx
)
{
u32
*
segmentNum
,
u32
*
segmentIdx
,
GradSplitForceMode
force
)
{
return
HCCL_SUCCESS
;
}
...
...
tests/ut/python/ops/test_momentum.py
浏览文件 @
8da4c1a7
...
...
@@ -41,7 +41,7 @@ def tensor_run_opt(opt, iters, learning_rate, momentum,
gradient
,
variable
,
moment
):
""" tensor_run_opt """
success
=
True
new_weight
=
opt
(
variable
,
moment
,
learning_rate
,
gradient
,
momentum
)
new_weight
=
opt
(
variable
,
moment
,
learning_rate
,
gradient
,
momentum
)
[
0
]
success
=
F
.
depend
(
success
,
F
.
assign
(
variable
,
new_weight
))
return
success
...
...
tests/ut/python/ops/test_ops.py
浏览文件 @
8da4c1a7
...
...
@@ -1058,6 +1058,7 @@ test_case_nn_ops = [
(
'SparseApplyAdagrad'
,
{
'block'
:
P
.
SparseApplyAdagrad
(
0.5
),
'desc_inputs'
:
[[
3
,
3
],
[
3
,
3
],
[
3
,
3
],
Tensor
(
np
.
ones
((
3
,),
np
.
int32
))],
'desc_bprop'
:
[[
3
,
3
],
[
3
,
3
]],
'skip'
:
[
'backward'
]}),
(
'SparseApplyFtrl'
,
{
'block'
:
SparseApplyFtrlNet
(),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录