fix_renorm_op_bug

This commit is contained in:
lichen 2022-07-30 09:36:04 +08:00
parent 782a1a0e7f
commit bee3414336
2 changed files with 5 additions and 7 deletions

View File

@ -34,14 +34,12 @@ bool RenormGpuKernelMod::GetRenormAttr(const BaseOperatorPtr &base_operator) {
dim_ = GetValue<int64_t>(base_operator->GetAttr("dim"));
p_ = GetValue<float>(base_operator->GetAttr("p"));
if (p_ <= 0.0f) {
MS_LOG(ERROR) << "For '" << kernel_name_ << "', it's op attribute 'p'" << p_
<< "less than or equals to zero is invalid.";
MS_LOG(ERROR) << "For 'Renorm', it's op attribute 'p'" << p_ << "less than or equals to zero is invalid.";
return false;
}
max_norm_ = GetValue<float>(base_operator->GetAttr("maxnorm"));
if (max_norm_ < 0) {
MS_LOG(ERROR) << "For '" << kernel_name_ << "', it's op attribute 'maxnorm'" << max_norm_
<< "less than zero is invalid.";
MS_LOG(ERROR) << "For 'Renorm', it's op attribute 'maxnorm'" << max_norm_ << "less than zero is invalid.";
return false;
}
return true;
@ -102,8 +100,8 @@ void RenormGpuKernelMod::InitParams() {
auto shape_size = input_shape_.size();
MS_EXCEPTION_IF_ZERO("input shape", shape_size);
if (dim_ >= SizeToLong(shape_size) || dim_ < -SizeToLong(shape_size)) {
MS_LOG(EXCEPTION) << "For '" << kernel_name_ << "', it's op attribute 'dim' must be in range [" << -shape_size
<< ", " << shape_size << "), but got " << dim_;
MS_LOG(EXCEPTION) << "For 'Renorm', it's op attribute 'dim' must be in range [" << -SizeToLong(shape_size) << ", "
<< shape_size << "), but got " << dim_;
}
if (dim_ < 0) {
dim_ += shape_size;

View File

@ -6373,7 +6373,7 @@ class Renorm(Primitive):
Refer to :func::`mindspore.ops.renorm` for more detail.
Supported Platforms:
``Ascend`` ``CPU``
``Ascend`` ``CPU`` ``GPU``
Examples:
>>> x = Tensor(np.array([[1, 1, 1], [2, 2, 2], [3, 3, 3]]), mindspore.float32)