Skip to content

Commit

Permalink
Skip dce when feed is constant (#50)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
inisis and UltralyticsAssistant authored Nov 25, 2024
1 parent 3049e6b commit 8e0105e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.41
0.1.42
4 changes: 2 additions & 2 deletions onnxslim/core/utils.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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()
Expand Down

0 comments on commit 8e0105e

Please sign in to comment.