Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
8f1984a8
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看板
提交
8f1984a8
编写于
4月 27, 2020
作者:
W
Wei Luning
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
only cast when level is O2
上级
3dd369ce
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
12 addition
and
6 deletion
+12
-6
mindspore/ccsrc/operator/composite/unpack_call.h
mindspore/ccsrc/operator/composite/unpack_call.h
+0
-2
mindspore/ccsrc/pipeline/pipeline.cc
mindspore/ccsrc/pipeline/pipeline.cc
+4
-0
mindspore/nn/wrap/cell_wrapper.py
mindspore/nn/wrap/cell_wrapper.py
+7
-3
mindspore/train/model.py
mindspore/train/model.py
+1
-1
未找到文件。
mindspore/ccsrc/operator/composite/unpack_call.h
浏览文件 @
8f1984a8
...
...
@@ -35,7 +35,6 @@
namespace
mindspore
{
// namespace to support composite operators definition
namespace
prim
{
// Expand the tuple and dict parameters generated when parsing the function call,
// and generate positional parameters and key-value pairs for function.
class
UnpackCall
:
public
MetaFuncGraph
{
...
...
@@ -47,7 +46,6 @@ class UnpackCall : public MetaFuncGraph {
friend
bool
operator
==
(
const
UnpackCall
&
lhs
,
const
UnpackCall
&
rhs
)
{
return
lhs
.
name_
==
rhs
.
name_
;
}
};
using
UnpackCallPtr
=
std
::
shared_ptr
<
UnpackCall
>
;
}
// namespace prim
}
// namespace mindspore
...
...
mindspore/ccsrc/pipeline/pipeline.cc
浏览文件 @
8f1984a8
...
...
@@ -300,6 +300,10 @@ void ExecutorPy::SaveCompiledGraphToPb(const std::string &phase_s) {
// save the graph to file in protobuf format
FuncGraphPtr
func_graph
=
info_
[
phase_s
]
->
resource
->
func_graph
();
MS_EXCEPTION_IF_NULL
(
func_graph
);
if
(
phase_s
.
empty
())
{
MS_LOG
(
ERROR
)
<<
"`phase` is empty '"
<<
phase_s
<<
"'!"
;
return
;
}
std
::
string
name_prefix
=
phase_s
.
substr
(
0
,
phase_s
.
find
(
"."
));
std
::
string
pb_filename
=
std
::
string
(
"ms_output_"
)
+
name_prefix
+
".pb"
;
std
::
string
filename
=
GetFilePathName
(
pb_filename
);
...
...
mindspore/nn/wrap/cell_wrapper.py
浏览文件 @
8f1984a8
...
...
@@ -304,15 +304,19 @@ class WithEvalCell(Cell):
>>> eval_net = nn.WithEvalCell(net, loss_fn)
"""
def
__init__
(
self
,
network
,
loss_fn
):
def
__init__
(
self
,
network
,
loss_fn
,
add_cast_fp32
=
False
):
super
(
WithEvalCell
,
self
).
__init__
(
auto_prefix
=
False
)
self
.
_network
=
network
self
.
_loss_fn
=
loss_fn
self
.
add_cast_fp32
=
add_cast_fp32
def
construct
(
self
,
data
,
label
):
outputs
=
self
.
_network
(
data
)
label
=
_mp_cast_helper
(
mstype
.
float32
,
label
)
loss
=
self
.
_loss_fn
(
F
.
cast
(
outputs
,
mstype
.
float32
),
label
)
if
self
.
add_cast_fp32
:
label
=
_mp_cast_helper
(
mstype
.
float32
,
label
)
outputs
=
F
.
cast
(
outputs
,
mstype
.
float32
)
loss
=
self
.
_loss_fn
(
outputs
,
label
)
return
loss
,
outputs
,
label
...
...
mindspore/train/model.py
浏览文件 @
8f1984a8
...
...
@@ -162,7 +162,7 @@ class Model:
else
:
if
self
.
_loss_fn
is
None
:
raise
ValueError
(
"loss_fn can not be None."
)
self
.
_eval_network
=
nn
.
WithEvalCell
(
self
.
_network
,
self
.
_loss_fn
)
self
.
_eval_network
=
nn
.
WithEvalCell
(
self
.
_network
,
self
.
_loss_fn
,
self
.
_amp_level
==
"O2"
)
self
.
_eval_indexes
=
[
0
,
1
,
2
]
def
_build_predict_network
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录