Environment:
Hardware Environment(Ascend/GPU/CPU): All
Software Environment:
MindSpore version (source or binary): 1.6.0 & Earlier versions
Python version (e.g., Python 3.7.5): 3.7.6
OS platform and distribution (e.g., Linux Ubuntu 16.04): Ubuntu
GCC/Compiler version (if compiled from source): gcc 9.4.0
python code examples
from mindspore import nn
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
def construct(self, x):
return self.y + x
net = Net()
output = net(1)
Error reporting information
Traceback (most recent call last):
File "test_self.py", line 11, in <module>
output = net(1)
File "mindspore\nn\cell.py", line 477, in __call__
out = self.compile_and_run(*args)
File "mindspore\nn\cell.py", line 803, in compile_and_run
self.compile(*inputs)
File "mindspore\nn\cell.py", line 790, in compile
_cell_graph_executor.compile(self, *inputs, phase=self.phase, auto_parallel_mode=self._auto_parallel_mode)
File "mindspore\common\api.py", line 632, in compile
result = self._graph_executor.compile(obj, args_list, phase, self._use_vm_mode())
RuntimeError: mindspore\ccsrc\frontend\operator\composite\multitype_funcgraph.cc:162 GenerateFromTypes] The 'add' operation does not support the type [kMetaTypeNone, Int64].
The supported types of overload function `add` is: [Tuple, Tuple], [RowTensor, Tensor], [Tensor, Tensor], [List, List], [Tensor, List], [List, Tensor], [String, String], [Tuple, Tensor], [kMetaTypeNone, kMetaTypeNone], [Number, Number], [Number, Tensor], [Tensor, Number], [Tensor, Tuple].
The function call stack (See file 'rank_0/om/analyze_fail.dat' for more details):
# 0 In file test_self.py(8)
return self.y + x
Solution:
Since the execution error is caused by using an undefined variable, the solution is to define the variable in the network’s initialization function __init__(self):. Note that only variables defined as members of self can be used in the construct(self, x) method.
from mindspore import nn
class Net(nn.Cell):
def __init__(self):
super(Net, self).__init__()
self.y = 1.0
def construct(self, x):
return self.y + x
net = Net()
output = net(1)
If you write self.y = 1.0 instead of y = 1.0, you will also get an error because the variable is undefined.
Read More:
- [Solved] This error might have occurred since this system does not have Windows Long Path support enabled.
- [Solved] Mindspore 1.3.0 Compile Error: CMake Error at cmake/utils
- Import * has a red wavy line, but the operation does not report an error
- Panda error in modifying line name index does not support mutable operations
- [Solved] RuntimeError: cuda runtime error (801) : operation not supported at
- [Solved] TypeError: Object of type ‘bytes’ is not JSON serializable
- TypeError: Decimal type object is not a JSON serialization solution
- [Solved] torchsummary Error: RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.F
- [Solved] RuntimeError: Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the
- VScode debug error: configured debug type ‘Python’ is not supported
- [Solved] RuntimeError : PyTorch was compiled without NumPy support
- [Solved] pip Install Error: Missing dependencies for SOCKS support
- [Solved] Property ‘xxx‘ does not exist on type ‘{ xxx(file: any, fileList: any): void;
- Graphviz Install Error: There is no layout engine support for “dot“
- OSError: [WinError 1455] The page file is too small to complete the operation. Error loading…
- Segmentation fault (core dumped) in open3d operation [Solved]
- [Solved] RuntimeError: a view of a leaf Variable that requires grad is being used in an in-place operation
- Python: Django exception when executing migrate operation: django.db.utils.OperationalError: (1051, “Unknown table’xxx’”)
- Python 3.X error: valueerror: data type must provide an itemsize
- [Solved] Backtrader_plotting Error: RuntimeError: Unexpected data type