Skip to content

Commit 0f5da54

Browse files
scripts/vsmlrt.py: add support for modelopt
1 parent 3b4df57 commit 0f5da54

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

scripts/vsmlrt.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "3.22.28"
1+
__version__ = "3.22.29"
22

33
__all__ = [
44
"Backend", "BackendV2",
@@ -2387,11 +2387,15 @@ def tensorrt_rtx(
23872387
fp16_network_path = f"{os.path.join(dirname, basename)}_{checksum}_fp16{'_io' if fp16_io else ''}.onnx"
23882388
if not os.access(fp16_network_path, mode=os.R_OK):
23892389
import onnx
2390-
from onnxconverter_common.float16 import convert_float_to_float16
2391-
model = onnx.load(network_path)
2392-
with warnings.catch_warnings():
2393-
warnings.simplefilter("ignore")
2394-
model = convert_float_to_float16(model, keep_io_types=not fp16_io)
2390+
try:
2391+
from modelopt.onnx.autocast import convert_to_mixed_precision
2392+
model = convert_to_mixed_precision(network_path, keep_io_types=not fp16_io)
2393+
except Exception:
2394+
from onnxconverter_common.float16 import convert_float_to_float16
2395+
model = onnx.load(network_path)
2396+
with warnings.catch_warnings():
2397+
warnings.simplefilter("ignore")
2398+
model = convert_float_to_float16(model, keep_io_types=not fp16_io)
23952399
onnx.save(model, fp16_network_path)
23962400
network_path = fp16_network_path
23972401
elif fp16_io:

0 commit comments

Comments
 (0)