Browse Source

!599 fix clipbynorm op run error in pynative mode

Merge pull request !599 from dinghao/master
tags/v0.2.0-alpha
mindspore-ci-bot Gitee 5 years ago
parent
commit
99e7e43cbb
1 changed files with 3 additions and 0 deletions
  1. +3
    -0
      mindspore/nn/layer/basic.py

+ 3
- 0
mindspore/nn/layer/basic.py View File

@@ -23,6 +23,7 @@ from mindspore.ops import functional as F
from mindspore.ops.functional import identity
from mindspore.common.parameter import Parameter
from mindspore._extends import cell_attr_register
from mindspore.common.api import ms_function
from ..cell import Cell
from .activation import get_activation
from ..._checkparam import Validator as validator
@@ -261,7 +262,9 @@ class ClipByNorm(Cell):
self.expand_dims = P.ExpandDims()
self.dtype = P.DType()

@ms_function
def construct(self, x, clip_norm):
"""add ms_function decorator for pynative mode"""
mul_x = F.square(x)
l2sum = self.cast(self.reduce_sum(mul_x, self.axis), mstype.float32)
cond = self.greater_(l2sum, self.zero)


Loading…
Cancel
Save