Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues when using interpolate in versions of python >= 3.8 #800

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions torch2trt/converters/interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import torch.nn as nn
from torch2trt.torch2trt import *
from torch2trt.module_test import add_module_test
import collections
try:
from collections import Sequence
except ImportError:
from collections.abc import Sequence


def has_interpolate_plugin():
Expand Down Expand Up @@ -66,7 +69,7 @@ def convert_interpolate_trt7(ctx):

shape = size
if shape != None:
if isinstance(shape, collections.Sequence):
if isinstance(shape, Sequence):
shape = [input.size(0), input.size(1)] + list(shape)
else:
shape = [input.size(0), input.size(1)] + [shape] * input_dim
Expand All @@ -75,7 +78,7 @@ def convert_interpolate_trt7(ctx):

scales = scale_factor
if scales != None:
if not isinstance(scales, collections.Sequence):
if not isinstance(scales, Sequence):
scales = [scales] * input_dim
layer.scales = [1, 1] + list(scales)

Expand Down