Skip to content

Commit 118a170

Browse files
committed
check
1 parent 75069e1 commit 118a170

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

onnx_diagnostic/torch_export_patches/onnx_export_errors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ def get_function(name: str) -> Tuple[type, Callable]:
1616
module_name = ".".join(spl[:-1])
1717
fname = spl[-1]
1818
mod = importlib.import_module(module_name)
19+
if not hasattr(mod, fname):
20+
return None, None
1921
return mod, getattr(mod, fname)
2022

2123

@@ -39,6 +41,10 @@ def get_patches(mod, verbose: int = 0) -> Tuple[str, List[Any]]:
3941
len(fall) == 1
4042
), f"Unable to find patching information for {v} in \n{doc}"
4143
fmod, f = get_function(fall[0])
44+
if fmod is None and f is None:
45+
# The function does not exist in this version of transformers.
46+
# No patch is needed.
47+
continue
4248
to_patch.append({"module": fmod, "function": f, "patch": v})
4349

4450
name = mod.__name__

0 commit comments

Comments
 (0)