From 9481bd6e2358f92c022974befe5415d60f29a1b5 Mon Sep 17 00:00:00 2001 From: LianLiguang Date: Wed, 17 Mar 2021 15:31:08 +0800 Subject: [PATCH] raise valueerror when range ops input delat is 0 --- mindspore/nn/layer/math.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mindspore/nn/layer/math.py b/mindspore/nn/layer/math.py index 16af27f855..0044360e79 100644 --- a/mindspore/nn/layer/math.py +++ b/mindspore/nn/layer/math.py @@ -137,6 +137,8 @@ class Range(Cell): def __init__(self, start, limit=None, delta=1): super(Range, self).__init__() + if delta == 0: + raise ValueError("The input of `delta` can not be equal to zero.") data = np.arange(start, limit, delta) if data.dtype == np.float: self.ms_dtype = mstype.float32