1 Error description
1.1 System Environment
Hardware Environment(Ascend/GPU/CPU): GPU
Software Environment:
– MindSpore version (source or binary): 1.5.2
– Python version (eg, Python 3.7.5): 3.7.6
– OS platform and distribution (eg, Linux Ubuntu 16.04): Ubuntu 4.15.0-74-generic
– GCC/Compiler version (if compiled from source):
1.2 Basic information
1.2.1 Script
The training script calculates the minimum value of the corresponding elements of the input Tensor by constructing a single-operator network of Minimum. The script is as follows:
01 class Net(nn.Cell):
02 def __init__(self):
03 super(Net, self).__init__()
04 self.minimum = ops.minumum()
05 def construct(self, x,y):
06 output = self.minimum(x, y)
07 return output
08 net = Net()
09 x = Tensor(np.array([1.0, 2.0, 4.0]), mindspore.float64) .astype(mindspore.float32)
10 y = Tensor(np.array([3.0, 5.0, 6.0]), mindspore.float64) .astype(mindspore.float32)
11 output = net(x, y)
12 print('output', output)
1.2.2 Error reporting
The error message here is as follows:
[EXCEPTION] PYNATIVE(95109,7fe22ea22740,python):2022-06-14-21:59:02.837.339 [mindspore/ccsrc/pipeline/pynative/pynative_execute.cc:1331] SetImplicitCast] Minimum inputs size 0 does not match the requires signature size 2
Traceback (most recent call last):
File "182168.py", line 36, in <module>
net = Net()
File "182168.py", line 24, in __init__
self.minimum = ops.minimum()
File "/data2/llj/mindspores/r1.5/build/package/mindspore/ops/primitive.py", line 247, in __call__
return _run_op(self, self.name, args)
File "/data2/llj/mindspores/r1.5/build/package/mindspore/common/api.py", line 78, in wrapper
results = fn(*arg, **kwargs)
File "/data2/llj/mindspores/r1.5/build/package/mindspore/ops/primitive.py", line 682, in _run_op
output = real_run_op(obj, op_name, args)
ValueError: mindspore/ccsrc/pipeline/pynative/pynative_execute.cc:1331 SetImplicitCast] Minimum inputs size 0 does not match the requires signature size 2
Cause Analysis
Let’s look at the error message. In ValueError, it is written that Minimum inputs size 0 does not match the requires signature size 2, which probably means that two inputs are required, but there are actually no inputs. Combined with line 11, it is found that two inputs are actually passed in. So the problem may not lie in this line. We can add a print mark after lines 3, 5, and 11 to see where the program is executed. After execution, it is found that only 1 is printed, indicating that the problem lies in the fourth line. After careful inspection, it is found that the minimum is in lowercase when the minimum operator is initialized in the fourth line, which is equivalent to directly calling the functional interface minimum operator, so the error is not passed. input parameters.
2 Solutions
For the reasons known above, it is easy to make the following modifications:
01 class Net(nn.Cell):
02 def __init__(self):
03 super(Net, self).__init__()
04 self.minimum = ops.Minimum()
05 def construct(self, x,y):
06 output = self.minimum(x, y)
07 return output
08 net = Net()
09 x = Tensor(np.array([1.0, 2.0, 4.0]), mindspore.float64) .astype(mindspore.float32)
10 y = Tensor(np.array([3.0, 5.0, 6.0]), mindspore.float64) .astype(mindspore.float32)
11 output = net(x, y)
12 print('output', output)
At this point, the execution is successful, and the output is as follows:
output [1. 2. 3.]
3 Summary
Steps to locate the error report:
1. Find the line of user code that reports the error: self.minimum = ops.minimum() ;
2. According to the keywords in the log error message, narrow down the scope of the analysis problem. Minimum inputs size 0 does not match the requires signature size 2 ;
3. It is necessary to focus on the correctness of variable definition and initialization.
Read More:
- [Solved] MindSpore Error: ReduceMean in the Ascend environment does not support inputs of 8 or more dimensions
- [Solved] MindSpore Error: ValueError: For ‘AvgPool’ every dimension of the output shape must be greater than zero
- [Solved] MindSpore Error: ValueError: `padding_idx` in `Embedding` out of range
- [Solved] MindSpore Error: “ValueError:invalid literal for int()with base10’the’
- [Solved] MindSpore Error: “RuntimeError: Invalid data, Page size.”
- [Solved] Canal Error: CanalParseException: column size is not match,parse row data failed
- [Solved] MindSpore Error: Data type conversion of ‘Parameter’ is not supporte
- [Solved] Tensorflow/Keras Error reading weights: ValueError: axes don‘t match array
- [Solved] Camera Calibration Error: ErrorMessage: Image size does not match the measurement in camera parameters
- [Solved] MindSpore Error: Should not use Python in runtime
- [Solved] MindSpore Error: Select GPU kernel op * fail! Incompatible data type
- ValueError: Negative dimension size caused by subtracting 2 from 1 for…
- [Solved] MindSpore Error: For ‘MirrorPad‘, paddings must be a Tensor with *
- [Solved] MindSpore Error: StridedSlice operator does not support input of uint8 data type on Ascend hardware
- No match for ‘operator =’ both ends of the equal sign do not match
- [Solved] MindSpore Error: For primitive[TensorSummary], the v rank Must be greater than or equal to 0
- [Solved] MindSpore Error: TypeError: For ‘TopK’, the type of ‘x’ should be…
- [Solved] MindSpore Network custom reverse error: TypeError: The params of function ‘bprop’ of
- [Solved] MindSpore Error: task_fail_info or current_graph_ is nullptr
- [Solved] MindSpore Error: For ‘CellList’, each cell should be subclass of Cell