Skip to content

Commit

Permalink
Replace ONNXSim with ONNXSlim (#13236)
Browse files Browse the repository at this point in the history
Signed-off-by: Kayzwer <[email protected]>
  • Loading branch information
Kayzwer authored Aug 11, 2024
1 parent 6096750 commit 19ce902
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions export.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,11 @@ def export_onnx(model, im, file, opset, dynamic, simplify, prefix=colorstr("ONNX
if simplify:
try:
cuda = torch.cuda.is_available()
check_requirements(("onnxruntime-gpu" if cuda else "onnxruntime", "onnx-simplifier>=0.4.1"))
import onnxsim
check_requirements(("onnxruntime-gpu" if cuda else "onnxruntime", "onnxslim"))
import onnxslim

LOGGER.info(f"{prefix} simplifying with onnx-simplifier {onnxsim.__version__}...")
model_onnx, check = onnxsim.simplify(model_onnx)
assert check, "assert check failed"
LOGGER.info(f"{prefix} slimming with onnxslim {onnxslim.__version__}...")
model_onnx = onnxslim.slim(model_onnx)
onnx.save(model_onnx, f)
except Exception as e:
LOGGER.info(f"{prefix} simplifier failure: {e}")
Expand Down

0 comments on commit 19ce902

Please sign in to comment.