[ASR] Remove fluid api and useless import, test=asr (#2944)

* remove fluid api and useless import.

* fix variable name
pull/2950/head
zxcd 2 years ago committed by GitHub
parent e8deb1d8c3
commit dcf8ef04e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from collections import defaultdict
from turtle import Turtle
from typing import Dict
from typing import List
from typing import Tuple

@ -56,15 +56,15 @@ class ClipGradByGlobalNormWithLog(paddle.nn.ClipGradByGlobalNorm):
if len(sum_square_list) == 0:
return params_grads
global_norm_var = layers.concat(sum_square_list)
global_norm_var = paddle.concat(sum_square_list)
global_norm_var = paddle.sum(global_norm_var)
global_norm_var = paddle.sqrt(global_norm_var)
# debug log
logger.debug(f"Grad Global Norm: {float(global_norm_var)}!!!!")
max_global_norm = layers.fill_constant(
shape=[1], dtype=global_norm_var.dtype, value=self.clip_norm)
max_global_norm = paddle.full(
shape=[1], dtype=global_norm_var.dtype, fill_value=self.clip_norm)
clip_var = paddle.divide(
x=max_global_norm,
y=paddle.maximum(x=global_norm_var, y=max_global_norm))

Loading…
Cancel
Save