使用 Altas300 对 GroundingDino 进行模型部署,导出的 onnx 模型为动态模型,在转换为 om 模型时,固定了其尺寸。
我在论坛上查找了相似问题,最相似的问题是 “华为atlas 200idka2和atlas 200dk部署groundingdino出现的问题” 以及 “[GroundingDINO]ONNX模型转OM模型过程中遇到input shape dim未对齐问题” 等。前者似乎成功解决了这个问题,但是显示帖子被删除,后者版主回复了两个参考思路。
- 针对第一个思路,使用
onnxsim 进行优化后转换,爆同样的错误。 - 针对第二个思路,我使用下方代码删除了
concat 3 4 5 6 四个算子的 unsqueeze 节点,在进行模型转换时,没有报 concat 算子问题,但是爆了几百个算子不支持问题,报错信息类似于 No supported Ops kernel and engine are found for [/encoder/blocks.1/attn/Einsum], optype [Einsum]
使用 Altas300 对 GroundingDino 进行模型部署,导出的 onnx 模型为动态模型,在转换为 om 模型时,固定了其尺寸。
ATC start working now, please wait for a moment. ... ATC run failed, Please check the detail log, Try 'atc --help' for more information E10042: 2025-04-26-11:53:07.780.080 GenerateOfflineModel execute failed. TraceBack (most recent call last): op[/Concat_3], the input shape dims should be equal except merge axis,shapes:[[1, ], [1, 1, ], ]axis:0[FUNC:ConcatInferShapeCommon][FILE:split_combination_ops.cc][LINE:1213] Call InferShapeAndType for node:/Concat_3(ConcatD) failed[FUNC:Infer][FILE:infershape_pass.cc][LINE:120] process pass InferShapePass on node:/Concat_3 failed, ret:4294967295[FUNC:RunPassesOnNode][FILE:base_pass.cc][LINE:570] build graph failed, graph id:0, ret:1343242270[FUNC:BuildModelWithGraphId][FILE:ge_generator.cc][LINE:1615] GenerateOfflineModel execute failed.我在论坛上查找了相似问题,最相似的问题是 “华为atlas 200idka2和atlas 200dk部署groundingdino出现的问题” 以及 “[GroundingDINO]ONNX模型转OM模型过程中遇到input shape dim未对齐问题” 等。前者似乎成功解决了这个问题,但是显示帖子被删除,后者版主回复了两个参考思路。
onnxsim进行优化后转换,爆同样的错误。concat 3 4 5 6四个算子的unsqueeze节点,在进行模型转换时,没有报concat算子问题,但是爆了几百个算子不支持问题,报错信息类似于No supported Ops kernel and engine are found for [/encoder/blocks.1/attn/Einsum], optype [Einsum]import onnx # concat 3 (3 4 5) # concat 4 (6 7 8) # concat 6 (9 10) # concat 7 (11 12) # concat 9 (13) # concat 10 (14) # concat 11 (15 16) # concat 13 (17 18 19 20 21 22) # concat 14 (23 24 25 26 27 28) def main(node_name_del, node_name_main): model = onnx.load("groundingdino_swint_ogc_modified.onnx") graph = model.graph # 创建映射:unsqueeze_output → 原始 input unsqueeze_map = {} # 记录要删除的节点 nodes_to_remove = [] for node in graph.node: if node.name in node_name_del: unsqueeze_map[node.output[0]] = node.input[0] nodes_to_remove.append(node) # 替换 Concat_3 中的输入 for node in graph.node: if node.name == node_name_main: node.input[:] = [unsqueeze_map.get(inp, inp) for inp in node.input] # 移除 unsqueeze 节点 for node in nodes_to_remove: graph.node.remove(node) onnx.save(model, "groundingdino_swint_ogc_modified.onnx") node_name_main_list = ["/Concat_3", "/Concat_4", "/Concat_6", "/Concat_7"] # "/Concat_9", "/Concat_10", "/Concat_11", "/Concat_13", "/Concat_14" node_name_del_dict = { "/Concat_3": ["/Unsqueeze_3", "/Unsqueeze_4", "/Unsqueeze_5"], "/Concat_4": ["/Unsqueeze_6", "/Unsqueeze_7", "/Unsqueeze_8"], "/Concat_6": ["/Unsqueeze_9", "/Unsqueeze_10"], "/Concat_7": ["/Unsqueeze_11", "/Unsqueeze_12"], "/Concat_9": ["/Unsqueeze_13"], "/Concat_10": ["/Unsqueeze_14"], "/Concat_11": ["/Unsqueeze_15", "/Unsqueeze_16"], "/Concat_13": ["/Unsqueeze_17", "/Unsqueeze_18", "/Unsqueeze_19", "/Unsqueeze_20", "/Unsqueeze_21", "/Unsqueeze_22"], "/Concat_14": ["/Unsqueeze_23", "/Unsqueeze_24", "/Unsqueeze_25", "/Unsqueeze_26", "/Unsqueeze_27", "/Unsqueeze_28"], } for node_name_main in node_name_main_list: print(f"Processing {node_name_main}...") node_name_del = node_name_del_dict[node_name_main] main(node_name_del, node_name_main)