发生异常: AssertionError (note: full exception trace is shown but execution is paused at: _run_module_as_main) exception: no description File "/usr/local/lib/python3.10/site-packages/torch/onnx/symbolic_opset9.py", line 539, in cat assert all( File "/usr/local/lib/python3.10/site-packages/torch/onnx/symbolic_helper.py", line 306, in wrapper return fn(g, *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/torch/onnx/symbolic_opset11.py", line 551, in cat return opset9.cat(g, tensor_list, dim) File "/usr/local/lib/python3.10/site-packages/torch/onnx/symbolic_helper.py", line 392, in wrapper return fn(g, *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/torch/onnx/utils.py", line 1891, in _run_symbolic_function return symbolic_fn(graph_context, *inputs, **attrs) File "/usr/local/lib/python3.10/site-packages/torch/onnx/utils.py", line 665, in _optimize_graph graph = _C._jit_pass_onnx(graph, operator_export_type) File "/usr/local/lib/python3.10/site-packages/torch/onnx/utils.py", line 1117, in _model_to_graph graph = _optimize_graph( File "/usr/local/lib/python3.10/site-packages/torch/onnx/utils.py", line 1548, in _export graph, params_dict, torch_out = _model_to_graph( File "/usr/local/lib/python3.10/site-packages/torch/onnx/utils.py", line 506, in export _export( File "/work/hu/alg_sources/llm-export/llm_export.py", line 228, in export_block torch.onnx.export( File "/work/hu/alg_sources/llm-export/llm_export.py", line 251, in export_blocks self.export_block(i) File "/work/hu/alg_sources/llm-export/llm_export.py", line 868, in <module> llm_exporter.export_blocks() File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main (Current frame) return _run_code(code, main_globals, None, AssertionError:
报错代码位置
@_onnx_symbolic("aten::cat")
@symbolic_helper.parse_args("v", "i")
@_beartype.beartype
def cat(g: jit_utils.GraphContext, tensor_list, dim):
tensors = symbolic_helper._unpack_list(tensor_list)
# torch.cat ignores empty tensors such as `torch.Tensor([])`
# These needs to be removed as input from ONNX's concat too, otherwise shape inference
# will likely fail due to inputs with different ranks (0 for empty tensor, > 0 for anything else)
nonempty_tensors = []
for t in tensors:
if symbolic_helper._is_constant(t) and not symbolic_helper._get_tensor_dim_size(
t, 0
):
continue
nonempty_tensors.append(t)
assert len(nonempty_tensors) > 0
assert all(
[
symbolic_helper._get_tensor_rank(nonempty_tensors[0]) is None
or symbolic_helper._get_tensor_rank(t) is None
or symbolic_helper._get_tensor_rank(t)
== symbolic_helper._get_tensor_rank(nonempty_tensors[0])
for t in nonempty_tensors
]
)
tensor_list.node().removeAllInputs()
for t in nonempty_tensors:
tensor_list.node().addInput(t)
tensors = symbolic_helper._unpack_list(tensor_list)
return g.op("Concat", *tensors, axis_i=dim)
报错提示
发生异常: AssertionError (note: full exception trace is shown but execution is paused at: _run_module_as_main) exception: no description File "/usr/local/lib/python3.10/site-packages/torch/onnx/symbolic_opset9.py", line 539, in cat assert all( File "/usr/local/lib/python3.10/site-packages/torch/onnx/symbolic_helper.py", line 306, in wrapper return fn(g, *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/torch/onnx/symbolic_opset11.py", line 551, in cat return opset9.cat(g, tensor_list, dim) File "/usr/local/lib/python3.10/site-packages/torch/onnx/symbolic_helper.py", line 392, in wrapper return fn(g, *args, **kwargs) File "/usr/local/lib/python3.10/site-packages/torch/onnx/utils.py", line 1891, in _run_symbolic_function return symbolic_fn(graph_context, *inputs, **attrs) File "/usr/local/lib/python3.10/site-packages/torch/onnx/utils.py", line 665, in _optimize_graph graph = _C._jit_pass_onnx(graph, operator_export_type) File "/usr/local/lib/python3.10/site-packages/torch/onnx/utils.py", line 1117, in _model_to_graph graph = _optimize_graph( File "/usr/local/lib/python3.10/site-packages/torch/onnx/utils.py", line 1548, in _export graph, params_dict, torch_out = _model_to_graph( File "/usr/local/lib/python3.10/site-packages/torch/onnx/utils.py", line 506, in export _export( File "/work/hu/alg_sources/llm-export/llm_export.py", line 228, in export_block torch.onnx.export( File "/work/hu/alg_sources/llm-export/llm_export.py", line 251, in export_blocks self.export_block(i) File "/work/hu/alg_sources/llm-export/llm_export.py", line 868, in <module> llm_exporter.export_blocks() File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code exec(code, run_globals) File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main (Current frame) return _run_code(code, main_globals, None, AssertionError:
报错代码位置
情况
nonempty_tensors的两个tensor的shape分别为【1,32,0,128】【1,1,3,32,3,128】,不能够cat Llama-2-7b-chat-ms模型下载地址: https://modelscope.cn/models/modelscope/Llama-2-7b-ms/files python环境: