未验证 提交 a195ef3a 编写于 作者: D duanyanhui 提交者: GitHub

fix npu for norm (#54204)

上级 3777d4a9
...@@ -986,23 +986,24 @@ class BatchNorm(Layer): ...@@ -986,23 +986,24 @@ class BatchNorm(Layer):
_global_flags()['FLAGS_npu_storage_format'] _global_flags()['FLAGS_npu_storage_format']
and 'npu' in get_all_custom_device_type() and 'npu' in get_all_custom_device_type()
): ):
with no_grad(): if in_dynamic_mode():
weight_trans = _C_ops.npu_identity( with no_grad():
self.weight, 3 weight_trans = _C_ops.npu_identity(
) # ACL_FORMAT_NC1HWC0 = 3 self.weight, 3
bias_trans = _C_ops.npu_identity( ) # ACL_FORMAT_NC1HWC0 = 3
self.bias, 3 bias_trans = _C_ops.npu_identity(
) # ACL_FORMAT_NC1HWC0 = 3 self.bias, 3
mean_trans = _C_ops.npu_identity( ) # ACL_FORMAT_NC1HWC0 = 3
self._mean, 3 mean_trans = _C_ops.npu_identity(
) # ACL_FORMAT_NC1HWC0 = 3 self._mean, 3
var_trans = _C_ops.npu_identity( ) # ACL_FORMAT_NC1HWC0 = 3
self._variance, 3 var_trans = _C_ops.npu_identity(
) # ACL_FORMAT_NC1HWC0 = 3 self._variance, 3
weight_trans._share_underline_tensor_to(self.weight) ) # ACL_FORMAT_NC1HWC0 = 3
bias_trans._share_underline_tensor_to(self.bias) weight_trans._share_underline_tensor_to(self.weight)
mean_trans._share_underline_tensor_to(self._mean) bias_trans._share_underline_tensor_to(self.bias)
var_trans._share_underline_tensor_to(self._variance) mean_trans._share_underline_tensor_to(self._mean)
var_trans._share_underline_tensor_to(self._variance)
self._in_place = in_place self._in_place = in_place
self._data_layout = data_layout self._data_layout = data_layout
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册