Skip to content
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

Cleanup _libcall and _usercall distinction #199

Merged
merged 14 commits into from
Nov 22, 2022
Merged

Conversation

gramalingam
Copy link
Collaborator

Cleanup _libcall and _usercall distinction

onnxscript/values.py Fixed Show resolved Hide resolved
onnxscript/values.py Fixed Show fixed Hide fixed
@codecov
Copy link

codecov bot commented Nov 18, 2022

Codecov Report

Merging #199 (5e5ef98) into main (7d8afbf) will increase coverage by 0.11%.
The diff coverage is 86.48%.

@@            Coverage Diff             @@
##             main     #199      +/-   ##
==========================================
+ Coverage   81.47%   81.58%   +0.11%     
==========================================
  Files          67       67              
  Lines        5052     5040      -12     
==========================================
- Hits         4116     4112       -4     
+ Misses        936      928       -8     
Impacted Files Coverage Δ
onnxscript/values.py 84.83% <86.48%> (+3.25%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

onnxscript/values.py Fixed Show resolved Hide resolved
onnxscript/values.py Outdated Show resolved Hide resolved
onnxscript/values.py Outdated Show resolved Hide resolved
onnxscript/values.py Outdated Show resolved Hide resolved
onnxscript/values.py Outdated Show resolved Hide resolved
onnxscript/values.py Outdated Show resolved Hide resolved
@@ -142,6 +142,70 @@ class OnnxClosure:
function: Any


def adapt_to_eager_mode(inputs):
Copy link
Collaborator

@justinchuby justinchuby Nov 19, 2022

Choose a reason for hiding this comment

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

Should we hide this function? Same for the other

Suggested change
def adapt_to_eager_mode(inputs):
def _adapt_to_eager_mode(inputs: np.ndarray | tensor.Tensor | bool | Number | list[Any] | tuple[Any, ...]):

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

For the type, the ideal would be to use a recursive type definition (python/mypy#731) ... do you think we can use it, or is it too experimental still?

Copy link
Collaborator

@justinchuby justinchuby Nov 21, 2022

Choose a reason for hiding this comment

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

From the comments it's on by default for mypy 0.990. since we are using 0.991 it may be worth a try

raise TypeError(f"Unexpected input type {type(input)}.")

result = adapt(inputs)
return result, has_array
Copy link
Collaborator

Choose a reason for hiding this comment

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

optional but I think some tests will be helpful

@gramalingam
Copy link
Collaborator Author

@justinchuby do you know why the lint check is failing? It's complaining about "cls.atol = 1e-7 # type: ignore[attr-defined]", but I didn't touch this line at all ... I guess it must already have been there

@justinchuby
Copy link
Collaborator

justinchuby commented Nov 21, 2022

I fixed it in the previous PR. Does rebasing help? The issue was because lintrunner previously ignored some mypy errors that it shouldn’t and I fixed it in the package

onnxscript/values.py Fixed Show fixed Hide fixed
onnxscript/values.py Fixed Show fixed Hide fixed
onnxscript/values.py Fixed Show fixed Hide fixed
onnxscript/values.py Fixed Show fixed Hide fixed
onnxscript/values.py Fixed Show fixed Hide fixed

def _adapt_to_eager_mode(inputs):
UserModeValue = Union[
Copy link
Collaborator

Choose a reason for hiding this comment

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

Quotes are not needed since they are delayed evaluated.

onnxscript/values.py Fixed Show fixed Hide fixed
@gramalingam
Copy link
Collaborator Author

I ended up leaving the type-definitions commented out: it is a bit non-trivial to get all typing annotations to work (as other existing code doesn't have necessary type annotations), and I will need to get other things setup to tackle something like this.

@gramalingam gramalingam merged commit 830f8dc into main Nov 22, 2022
@gramalingam gramalingam deleted the rama/user-lib-call branch November 22, 2022 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants