Merge branch 'master' into master
commit
83cd15345a
|
@ -368,12 +368,11 @@ def export_onnx(model, im, file, opset, dynamic, simplify, prefix=colorstr("ONNX
|
||||||
if simplify:
|
if simplify:
|
||||||
try:
|
try:
|
||||||
cuda = torch.cuda.is_available()
|
cuda = torch.cuda.is_available()
|
||||||
check_requirements(("onnxruntime-gpu" if cuda else "onnxruntime", "onnx-simplifier>=0.4.1"))
|
check_requirements(("onnxruntime-gpu" if cuda else "onnxruntime", "onnxslim"))
|
||||||
import onnxsim
|
import onnxslim
|
||||||
|
|
||||||
LOGGER.info(f"{prefix} simplifying with onnx-simplifier {onnxsim.__version__}...")
|
LOGGER.info(f"{prefix} slimming with onnxslim {onnxslim.__version__}...")
|
||||||
model_onnx, check = onnxsim.simplify(model_onnx)
|
model_onnx = onnxslim.slim(model_onnx)
|
||||||
assert check, "assert check failed"
|
|
||||||
onnx.save(model_onnx, f)
|
onnx.save(model_onnx, f)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOGGER.info(f"{prefix} simplifier failure: {e}")
|
LOGGER.info(f"{prefix} simplifier failure: {e}")
|
||||||
|
|
Loading…
Reference in New Issue