Skip to content

Commit 10065a4

Browse files
committed
warn
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
1 parent 257e583 commit 10065a4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

onnxscript/function_libs/torch_lib/registration.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from __future__ import annotations
66

77
import re
8+
import warnings
89
from typing import Any, Callable, Generator, Optional
910

1011
import onnxscript
@@ -43,15 +44,19 @@ def register(self, func: Any, name: str, *, complex: bool = False) -> None:
4344

4445
if complex:
4546
if overloaded_function.complex:
46-
raise ValueError(
47-
f"Complex overload for '{name}' already registered: {overloaded_function.complex}."
47+
warnings.warn(
48+
f"Complex overload for '{name}' already registered: {overloaded_function.complex}.",
49+
stacklevel=3,
4850
)
51+
return
4952
overloaded_function.complex.append(func)
5053
else:
5154
if overloaded_function.overloads:
52-
raise ValueError(
53-
f"Real overload for '{name}' already registered: {overloaded_function.overloads}."
55+
warnings.warn(
56+
f"Real overload for '{name}' already registered: {overloaded_function.overloads}.",
57+
stacklevel=3,
5458
)
59+
return
5560
overloaded_function.overloads.append(func)
5661

5762
def __getitem__(self, name):
@@ -101,7 +106,6 @@ def torch_op(
101106
*,
102107
registry: Optional[Registry] = None,
103108
trace_only: bool = False,
104-
private: bool = False,
105109
complex: bool = False,
106110
) -> Callable[[Callable], onnxscript.OnnxFunction | onnxscript.values.TracedOnnxFunction]:
107111
"""Register a torch op.
@@ -113,8 +117,6 @@ def torch_op(
113117
i.e. "aten::relu" instead of "aten::relu.default".
114118
registry: Registry to register the function to. If None, the default registry is used.
115119
trace_only: Whether the function should only be traced and not compiled.
116-
private: Whether the function is private (not directly exposed). It should
117-
be true for all functions with names starting with "_".
118120
complex: Whether the function expects complex-valued inputs.
119121
"""
120122
if registry is None:
@@ -134,8 +136,6 @@ def wrapper(
134136

135137
assert registry is not None
136138
for name_ in _check_and_normalize_names(name):
137-
if private:
138-
continue
139139
registry.register(processed_func, name_, complex=complex)
140140
return processed_func
141141

0 commit comments

Comments
 (0)