Skip to content

Commit 1f50da4

Browse files
committed
Added the string case
1 parent 807cfeb commit 1f50da4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

py/torch_tensorrt/dynamo/_settings.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from dataclasses import dataclass, field
22
from typing import Any, Collection, Optional, Set, Tuple, Union
33

4-
import torch
54
from torch.fx.node import Target
65
from torch_tensorrt._Device import Device
76
from torch_tensorrt._enums import EngineCapability, dtype
@@ -145,14 +144,20 @@ class CompilationSettings:
145144
offload_module_to_cpu: bool = OFFLOAD_MODULE_TO_CPU
146145

147146
def __getstate__(self) -> dict[str, Any]:
147+
from torch_tensorrt.dynamo.conversion._ConverterRegistry import (
148+
ConverterRegistry,
149+
)
150+
148151
state = self.__dict__.copy()
149-
state["torch_executed_ops"] = {str(op) for op in state["torch_executed_ops"]}
152+
state["torch_executed_ops"] = {
153+
op if isinstance(op, str) else ConverterRegistry.qualified_name_or_str(op)
154+
for op in state["torch_executed_ops"]
155+
}
150156
return state
151157

152158
def __setstate__(self, state: dict[str, Any]) -> None:
153159
self.__dict__.update(state)
154160
ops_str = self.torch_executed_ops
155-
self.torch_executed_ops = {getattr(torch.ops, op) for op in ops_str}
156161

157162

158163
_SETTINGS_TO_BE_ENGINE_INVARIANT = (

0 commit comments

Comments
 (0)