Fetch the repository succeeded.
name | about | labels |
---|---|---|
Bug Report | Use this template for reporting a bug | kind/bug |
Ascend
/GPU
/CPU
):Uncomment only one
/device <>
line, hit enter to put that in a new line, and remove leading whitespaces from that line:/device ascend
def test_padding_input_shape_1d():
fact = PaddingFactory(input_shape=(1,), pad_dim_size=7, dtype=np.float32)
with pytest.raises(ValueError) as err:
fact.forward_mindspore_impl()
assert "must >" in str(err)
../share/ops/padding_ops.py:30: in forward_mindspore_impl
out = net(input)
../share/utils.py:127: in __call__
out = super().__call__(*args, **kwargs )
/root/archiconda3/envs/liwuxia_vm/lib/python3.7/site-packages/mindspore/nn/cell.py:279: in __call__
out = self.compile_and_run(*inputs)
/root/archiconda3/envs/liwuxia_vm/lib/python3.7/site-packages/mindspore/nn/cell.py:533: in compile_and_run
self.compile(*inputs)
/root/archiconda3/envs/liwuxia_vm/lib/python3.7/site-packages/mindspore/nn/cell.py:520: in compile
_executor.compile(self, *inputs, phase=self.phase, auto_parallel_mode=self._auto_parallel_mode)
/root/archiconda3/envs/liwuxia_vm/lib/python3.7/site-packages/mindspore/common/api.py:411: in compile
result = self._executor.compile(obj, args_list, phase, use_vm)
/root/archiconda3/envs/liwuxia_vm/lib/python3.7/site-packages/mindspore/ops/operations/array_ops.py:739: in __infer__
validator.check_int(len(x_shape), 1, Rel.GT, "rank of x", self.name)
/root/archiconda3/envs/liwuxia_vm/lib/python3.7/site-packages/mindspore/_checkparam.py:181: in check_int
return check_number(arg_value, value, rel, int, arg_name, prim_name)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
arg_value = 1, value = 1, rel = <Rel.GT: 5>, arg_type = <class 'int'>, arg_name = '`rank of x`', prim_name = 'in `Padding`'
def check_number(arg_value, value, rel, arg_type=int, arg_name=None, prim_name=None):
"""
Check argument integer.
Usage:
- number = check_int(number, 0, Rel.GE, "number", None) # number >= 0
"""
rel_fn = Rel.get_fns(rel)
type_mismatch = not isinstance(arg_value, arg_type) or isinstance(arg_value, bool)
type_except = TypeError if type_mismatch else ValueError
prim_name = f'in `{prim_name}`' if prim_name else ''
arg_name = f'`{arg_name}`' if arg_name else ''
if math.isinf(arg_value) or math.isnan(arg_value) or np.isinf(arg_value) or np.isnan(arg_value):
raise ValueError(f'{arg_name} {prim_name} must be legal value, but got `{arg_value}`.')
if type_mismatch or not rel_fn(arg_value, value):
rel_str = Rel.get_strs(rel).format(value)
> raise type_except(f'{arg_name} {prim_name} should be an {type(arg_type).__name__} and must {rel_str}, '
f'but got `{arg_value}` with type `{type(arg_value).__name__}`.')
E ValueError: `rank of x` in `Padding` should be an type and must > 1, but got `1` with type `int`.
/root/archiconda3/envs/liwuxia_vm/lib/python3.7/site-packages/mindspore/_checkparam.py:112: ValueError
Show legitimate data types
根因分析
check_number错误显示的type信息不对
修改方法
修改check_number错误显示,显示正确的数据type
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
回归通过
Sign in to comment