主要参考资料:
静态图语法支持 - MindSpore master documentation
定位错误:报错会生成rank_0/om/analyze_fail.dat
文件,按instruction定位即可
# 1.This file shows the parsed IR info when graph evaluating failed to help find the problem.
# 2.You can search the last `------------------------>` to the node which is inferred failed.
# 3.Refer to https://www.mindspore.cn/search?inputValue=analyze_fail.dat to get more instructions.
# ===============================================================================
1. 不支持对sequentialcell进行for循环(遍历)
Traceback (most recent call last):
File "mytest.py", line 18, in <module>
print(test().shape)
File "mytest.py", line 14, in test
y = model(dummy_input)
File ".conda/envs/mindspore/lib/python3.7/site-packages/mindspore/nn/cell.py", line 578, in __call__
out = self.compile_and_run(*args)
File ".conda/envs/mindspore/lib/python3.7/site-packages/mindspore/nn/cell.py", line 965, in compile_and_run
self.compile(*inputs)
File ".conda/envs/mindspore/lib/python3.7/site-packages/mindspore/nn/cell.py", line 938, in compile
jit_config_dict=self._jit_config_dict)
File ".conda/envs/mindspore/lib/python3.7/site-packages/mindspore/common/api.py", line 1137, in compile
result = self._graph_executor.compile(obj, args_list, phase, self._use_vm_mode())
RuntimeError: MindSpore not support to get attribute '__len__' of a type[Func]
----------------------------------------------------
- The Traceback of Net Construct Code:
----------------------------------------------------
The function call stack (See file '/rank_0/om/analyze_fail.dat' for more details. Get instructions about `analyze_fail.dat` at https://www.mindspore.cn/search?inputValue=analyze_fail.dat):
# 0 In file /models/mobilevit.py(594)
x = self.layer_3(x)
^
# 1 In file .conda/envs/mindspore/lib/python3.7/site-packages/mindspore/nn/layer/container.py(275)
for cell in self.cell_list:
# 2 In file .conda/envs/mindspore/lib/python3.7/site-packages/mindspore/nn/layer/container.py(276)
input_data = cell(input_data)
^
# 3 In file /models/mobilevit.py(448)
for transformer_layer in self.global_rep:
^
# 4 In file .conda/envs/mindspore/lib/python3.7/site-packages/mindspore/_extends/parse/standard_method.py(1739)
return data.__len__()
^
----------------------------------------------------
- C++ Call Stack: (For framework developers)
----------------------------------------------------
mindspore/ccsrc/pipeline/jit/static_analysis/prim.cc:1425 GetEvaluatedValueForBuiltinTypeAttrOrMethod
提示信息global_rep类型为func,for循环无法获取它的__len__属性,把global_rep从nn.sequentialcell改为nn.CellList。
2. 不支持对非常量进行强类型转换
Traceback (most recent call last):
File "mytest.py", line 18, in <module>
print(test().shape)
File "mytest.py", line 14, in test
y = model(dummy_input)
File ".conda/envs/mindspore/lib/python3.7/site-packages/mindspore/nn/cell.py", line 578, in __call__
out = self.compile_and_run(*args)
File ".conda/envs/mindspore/lib/python3.7/site-packages/mindspore/nn/cell.py", line 965, in compile_and_run
self.compile(*inputs)
File ".conda/envs/mindspore/lib/python3.7/site-packages/mindspore/nn/cell.py", line 938, in compile
jit_config_dict=self._jit_config_dict)
File ".conda/envs/mindspore/lib/python3.7/site-packages/mindspore/common/api.py", line 1137, in compile
result = self._graph_executor.compile(obj, args_list, phase, self._use_vm_mode())
ValueError: When using JIT Fallback to handle script 'int(H_end[idx_H].asnumpy())', the inputs should be constant, but found variable 'H_end' to be nonconstant.
----------------------------------------------------
- The Traceback of Net Construct Code:
----------------------------------------------------
The function call stack (See file '/rank_0/om/analyze_fail.dat' for more details. Get instructions about `analyze_fail.dat` at https://www.mindspore.cn/search?inputValue=analyze_fail.dat):
# 0 In file /models/mobilevit.py(599)
x = self.classifier(x)
^
# 1 In file .conda/envs/mindspore/lib/python3.7/site-packages/mindspore/nn/layer/container.py(275)
for cell in self.cell_list:
# 2 In file .conda/envs/mindspore/lib/python3.7/site-packages/mindspore/nn/layer/container.py(276)
input_data = cell(input_data)
^
# 3 In file /models/adaptive_avgpool2d.py(48)
x = self.adaptive_avgpool2d(x)
^
# 4 In file /models/adaptive_avgpool2d.py(23)
for idx_H in range(H):
# 5 In file /models/adaptive_avgpool2d.py(25)
for idx_W in range(W):
# 6 In file /models/adaptive_avgpool2d.py(31)
h_e = int(H_end[idx_H].asnumpy())
^
----------------------------------------------------
- C++ Call Stack: (For framework developers)
----------------------------------------------------
mindspore/ccsrc/pipeline/jit/static_analysis/prim.cc:1936 CheckInterpretInput
标签:MindSpore,静态,self,py,envs,conda,调试,file,mindspore
From: https://www.cnblogs.com/rthete/p/17296423.html