From 8e0105e443e9714ce73b8a325e6ed43e4adbf0b5 Mon Sep 17 00:00:00 2001 From: inisis Date: Tue, 26 Nov 2024 02:34:36 +0800 Subject: [PATCH] Skip dce when feed is constant (#50) * skip cast dce in subgraph * loose restriction for cast dce in subgraph * Auto-format by https://ultralytics.com/actions * [Release] 0.1.42 --------- Co-authored-by: UltralyticsAssistant --- VERSION | 2 +- onnxslim/core/utils.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VERSION b/VERSION index 37f868f..4a3e97d 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.41 +0.1.42 diff --git a/onnxslim/core/utils.py b/onnxslim/core/utils.py index 8e77335..71a8168 100644 --- a/onnxslim/core/utils.py +++ b/onnxslim/core/utils.py @@ -1,5 +1,5 @@ from onnxslim.core.pattern import get_node_feeds, get_node_users -from onnxslim.third_party.onnx_graphsurgeon.ir.tensor import Variable +from onnxslim.third_party.onnx_graphsurgeon.ir.tensor import Constant, Variable def delete_node(node, input_var_idx=0, output_var_idx=0): @@ -17,7 +17,7 @@ def delete_node(node, input_var_idx=0, output_var_idx=0): if output_var: feeds = get_node_feeds(node) feed = feeds[0] - if not isinstance(feed, Variable): + if not isinstance(feed, (Variable, Constant)): feed.outputs.remove(node.inputs[input_var_idx]) feed.outputs.append(node.outputs[output_var_idx]) node.outputs.clear()