未验证 提交 5577f411 编写于 作者: W Weilong Wu 提交者: GitHub

[Eager] Remove non static mode (#41422)

* [Eager] Support test_layers's test cases switch to eager mode

* Update batch_norm _C_ops action to fix CI

* Use None instead of new EmptyTensor

* Updated var name

* Make sure to switch eager mode, Fix Coverage_CI

* Remove _non_static_mode statement

* Remove batch_norm dispensable input statement

* Polish batch_norm code

* Fix CI issue

* Remove _non_static_mode()
上级 1dd82728
...@@ -186,24 +186,25 @@ def batch_norm(x, ...@@ -186,24 +186,25 @@ def batch_norm(x,
else: else:
trainable_statistics = not use_global_stats trainable_statistics = not use_global_stats
if _non_static_mode(): if in_dygraph_mode():
if in_dygraph_mode(): batch_norm_out, _, _, _, _, _ = _C_ops.final_state_batch_norm(
batch_norm_out, _, _, _, _, _ = _C_ops.final_state_batch_norm( x, weight, bias, running_mean, running_var, momentum, epsilon,
x, weight, bias, running_mean, running_var, momentum, epsilon, data_format, not training, use_global_stats, trainable_statistics,
data_format, not training, use_global_stats, False)
trainable_statistics, False)
return dygraph_utils._append_activation_in_dygraph(
elif _in_legacy_dygraph(): batch_norm_out, act=None)
# for dygraph need tuple
attrs = ("momentum", momentum, "epsilon", epsilon, "is_test", elif _in_legacy_dygraph():
not training, "data_layout", data_format, "use_mkldnn", # for dygraph need tuple
False, "fuse_with_relu", False, "use_global_stats", attrs = ("momentum", momentum, "epsilon", epsilon, "is_test",
use_global_stats, "trainable_statistics", not training, "data_layout", data_format, "use_mkldnn", False,
trainable_statistics) "fuse_with_relu", False, "use_global_stats", use_global_stats,
"trainable_statistics", trainable_statistics)
batch_norm_out, _, _, _, _, _ = _C_ops.batch_norm(
x, weight, bias, running_mean, running_var, None, mean_out, batch_norm_out, _, _, _, _, _ = _C_ops.batch_norm(
variance_out, *attrs) x, weight, bias, running_mean, running_var, None, mean_out,
variance_out, *attrs)
return dygraph_utils._append_activation_in_dygraph( return dygraph_utils._append_activation_in_dygraph(
batch_norm_out, act=None) batch_norm_out, act=None)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册