Skip to content

fix: annotate script() #245

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion onnxscript/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import inspect
import sys
import textwrap
from typing import Any, Callable, Optional

import onnx.helper

Expand Down Expand Up @@ -52,7 +53,9 @@ def script_check(f: ast.FunctionDef, opset, global_names, source, default_opset=
return convert.top_level_stmt(f)


def script(opset=None, default_opset=None, **kwargs):
def script(
opset: Optional[values.Opset] = None, default_opset: Optional[Any] = None, **kwargs: Any
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Optional[values.Opset] for default_opset too

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

) -> Callable[[Callable[..., Any]], onnxscript.OnnxFunction]:
"""Main decorator. Declares a function as an onnx function.

Args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ def wrapped(fn):
# Modify this section ##########################################################

# Ops to be tested for numerical consistency between onnx and pytorch
OPINFO_FUNCTION_MAPPING = {
# Find the names of the OpInfos in torch/testing/_internal/common_methods_invocations.py
OPINFO_FUNCTION_MAPPING: dict[str, Callable[..., Any]] = {
"add": core_ops.aten_add,
"mul": core_ops.aten_mul,
"nn.functional.elu": nn_ops.aten_elu,
Expand Down