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: Wrap import of ConstantFold utilities #2312

Merged
merged 1 commit into from
Sep 12, 2023
Merged
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
13 changes: 12 additions & 1 deletion py/torch_tensorrt/dynamo/backend/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,27 @@
import torch
import torch._dynamo as td
import torch.utils._pytree as pytree
import torch_tensorrt
from torch._dynamo.utils import detect_fake_mode
from torch._functorch.aot_autograd import _aot_export_function
from torch._inductor.constant_folding import ConstantFolder, replace_node_with_constant
from torch._ops import OpOverload
from torch_tensorrt.dynamo import CompilationSettings
from torch_tensorrt.dynamo.compile import compile_module
from torch_tensorrt.dynamo.lowering._decompositions import get_decompositions
from torch_tensorrt.dynamo.lowering._pre_aot_lowering import pre_aot_substitutions
from torch_tensorrt.dynamo.utils import parse_dynamo_kwargs

from packaging import version

# Modify import location of utilities based on Torch version
if version.parse(torch_tensorrt.sanitized_torch_version()) <= version.parse("2.1.0"):
from torch._inductor.freezing import ConstantFolder, replace_node_with_constant
else:
from torch._inductor.constant_folding import (
ConstantFolder,
replace_node_with_constant,
)

logger = logging.getLogger(__name__)


Expand Down