From 0800c694f8cd6dc9407430acb64942fe01e9f369 Mon Sep 17 00:00:00 2001 From: inisis Date: Sun, 9 Jun 2024 09:28:29 +0000 Subject: [PATCH] add Concat elimination --- onnxslim/core/optimizer.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/onnxslim/core/optimizer.py b/onnxslim/core/optimizer.py index 96ed3b0..f22a963 100644 --- a/onnxslim/core/optimizer.py +++ b/onnxslim/core/optimizer.py @@ -160,6 +160,13 @@ def graph_constant_fold_inplace(graph): if len(node.inputs) > 1 and isinstance(node.inputs[1], Constant) and np.all(node.inputs[1].values == 1): idx = 0 if idx == 1 else 1 delete_node(node, idx) + elif node.op == "Concat": + if len(node.inputs) == 1: + delete_node(node) + else: + for input in node.inputs: + if isinstance(input, Constant) and input.values.size == 0: + node.inputs.remove(input) @register_fusion_pattern("FusionPadConv")