Skip to content

Comments

opgen: make all OpSchema attributes keyword-only args in Python#773

Merged
abock merged 2 commits intomainfrom
abock/kwonlyattrs
Jun 15, 2023
Merged

opgen: make all OpSchema attributes keyword-only args in Python#773
abock merged 2 commits intomainfrom
abock/kwonlyattrs

Conversation

@abock
Copy link
Contributor

@abock abock commented Jun 8, 2023

⚠️🚨🔥 Note: this is an API break since all attributes are now keyword-only, so positional usage is no longer allowed. Our tests uncovered a handful of places where we were specifing attributes as positional arguments.

By explicitly projecting all OpSchema attributes to keyword-only arguments in Python, we do not need to reorder attributes based on whether or not they have default values. This allows the Python API to express the same ordering as the op itself for inputs and attributes.

This also makes attribute specification consistent with variadic input ops which already have that implicit requirement.

@abock abock force-pushed the abock/kwonlyattrs branch 7 times, most recently from bdd91a3 to c88a6bd Compare June 9, 2023 00:18
@justinchuby
Copy link
Collaborator

fyi I am bumping ort and nightly in #770

@abock
Copy link
Contributor Author

abock commented Jun 9, 2023

Yeah, just trying to see if the problem I am seeing on the ort-nightly CI was addressed already. Seems not.

@abock
Copy link
Contributor Author

abock commented Jun 9, 2023

Actually I think I'll rebase this for now on your branch so we're on the same page.

@abock abock force-pushed the abock/kwonlyattrs branch from d812ccd to b9cd240 Compare June 9, 2023 00:45
@abock
Copy link
Contributor Author

abock commented Jun 9, 2023

Nice. Thanks @justinchuby, your branch makes this PR go green.

@abock abock added change base before merge Remember to change the merge base to main when the PR is ready to merge topic: api topic: breaking changes labels Jun 9, 2023
@abock abock self-assigned this Jun 9, 2023
@abock abock force-pushed the abock/kwonlyattrs branch from b9cd240 to 5dd1cfb Compare June 9, 2023 01:17
@abock abock force-pushed the abock/kwonlyattrs branch from 5dd1cfb to 992c2f0 Compare June 9, 2023 20:20
@abock abock force-pushed the abock/kwonlyattrs branch from 992c2f0 to 4fbe12c Compare June 14, 2023 02:02
@abock abock marked this pull request as ready for review June 14, 2023 02:54
@abock abock requested a review from gramalingam June 14, 2023 03:19
@codecov
Copy link

codecov bot commented Jun 15, 2023

Codecov Report

Merging #773 (a4429ac) into main (c509f5c) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main     #773   +/-   ##
=======================================
  Coverage   75.86%   75.86%           
=======================================
  Files         113      113           
  Lines       13200    13200           
  Branches     1305     1305           
=======================================
  Hits        10014    10014           
  Misses       2866     2866           
  Partials      320      320           
Impacted Files Coverage Δ
onnxscript/onnx_opset/_impl/opset3.py 80.00% <ø> (ø)
onnxscript/onnx_opset/_impl/opset8.py 68.08% <ø> (ø)
onnxscript/onnx_opset/_impl/opset_ai_onnx_ml2.py 80.00% <ø> (ø)
onnxscript/onnx_opset/_impl/opset_ai_onnx_ml3.py 71.42% <ø> (ø)
...nnx_opset/_impl/opset_ai_onnx_preview_training1.py 65.71% <ø> (ø)
onnxscript/function_libs/torch_lib/ops/core.py 76.32% <100.00%> (ø)
onnxscript/onnx_opset/_impl/opset1.py 48.70% <100.00%> (ø)
onnxscript/onnx_opset/_impl/opset10.py 74.57% <100.00%> (ø)
onnxscript/onnx_opset/_impl/opset11.py 68.32% <100.00%> (ø)
onnxscript/onnx_opset/_impl/opset12.py 61.11% <100.00%> (ø)
... and 14 more

abock added 2 commits June 15, 2023 18:31
By explicitly projecting all OpSchema attributes to keyword-only
arguments in Python, we do not need to reorder attributes based on
whether or not they have default values. This allows the Python
API to express the same ordering as the op itself for inputs and
attributes.
With ONNX attributes now expressed as keyword-only arguments, we
do not need to appease Python with setting a default value on these
kwargs.
@abock abock force-pushed the abock/kwonlyattrs branch from 4fbe12c to a4429ac Compare June 15, 2023 22:31
@abock abock merged commit f106c1e into main Jun 15, 2023
@abock abock deleted the abock/kwonlyattrs branch June 15, 2023 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change base before merge Remember to change the merge base to main when the PR is ready to merge topic: api topic: breaking changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants