Skip to content

Commit

Permalink
Introduce OpSignature to IR (#1838)
Browse files Browse the repository at this point in the history
Introduce OpSignature accessible from the `.op_signature` property of
all OpLike objects (traced function, onnx function and op). The
OpSignature class leverages the IR to represent the signature of an
operator, preserving ordering of all inputs and provides easy to work
with type representations.

The PR also deprecates the ParamSchema class and properties.

Fixes #1697

The next PR will replace param_schemas usage.
  • Loading branch information
justinchuby authored Oct 29, 2024
1 parent 561a600 commit 3e795f2
Show file tree
Hide file tree
Showing 4 changed files with 820 additions and 17 deletions.
10 changes: 7 additions & 3 deletions onnxscript/_internal/deprecation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
T = TypeVar("T")


@functools.lru_cache(maxsize=1024)
def _warn_once(message: str):
"""Issue a FutureWarning only once per message."""
warnings.warn(message, category=FutureWarning, stacklevel=3)


def deprecated(since: str, removed_in: str, instructions: str) -> Callable[[T], T]:
"""Marks functions as deprecated.
Expand All @@ -30,12 +36,10 @@ def deprecated(since: str, removed_in: str, instructions: str) -> Callable[[T],
def decorator(function):
@functools.wraps(function)
def wrapper(*args, **kwargs):
warnings.warn(
_warn_once(
f"'{function.__module__}.{function.__qualname__}' "
f"is deprecated in version {since} and will be "
f"removed in {removed_in}. Please {instructions}.",
category=FutureWarning,
stacklevel=2,
)
return function(*args, **kwargs)

Expand Down
Loading

0 comments on commit 3e795f2

Please sign in to comment.