Skip to content

Commit 813aa89

Browse files
authored
added filter to floordiv to only enable for pytorch 1.6+ (#511)
* added filter to floordiv to only enable for pytorch 1.6+ * enabled soft failure for missing torch method
1 parent f2066bc commit 813aa89

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

torch2trt/torch2trt.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ def trt_version():
1919
return trt.__version__
2020

2121

22+
def torch_version():
23+
return torch.__version__
24+
25+
2226
def torch_dtype_to_trt(dtype):
2327
if trt_version() >= '7.0' and dtype == torch.bool:
2428
return trt.bool
@@ -593,7 +597,10 @@ def tensorrt_converter(method, is_real=True, enabled=True, imports=[]):
593597
else:
594598
module, module_name, qual_name = importlib.import_module(method.__module__), method.__module__, method.__qualname__
595599

596-
method_impl = eval('copy.deepcopy(module.%s)' % qual_name)
600+
try:
601+
method_impl = eval('copy.deepcopy(module.%s)' % qual_name)
602+
except:
603+
enabled = False
597604

598605
def register_converter(converter):
599606
CONVERTERS[method] = {
@@ -615,4 +622,4 @@ def pass_converter(converter):
615622
else:
616623
return pass_converter
617624

618-
return register_converter
625+
return register_converter

0 commit comments

Comments
 (0)