-
Notifications
You must be signed in to change notification settings - Fork 88
Generate opset24 ops #2523
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
Generate opset24 ops #2523
Conversation
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
| def Pad( | ||
| self, | ||
| data: T_Pad, | ||
| pads: INT64, | ||
| constant_value: Optional[T_Pad] = None, | ||
| axes: Optional[Tind_Pad] = None, | ||
| *, | ||
| mode: str = "constant", | ||
| ) -> T_Pad: |
Check warning
Code scanning / CodeQL
Signature mismatch in overriding method Warning
Opset1.Pad
This method requires at least 3 positional arguments, whereas overridden
Opset2.Pad
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 months ago
To fix the signature mismatch in the overriding method, we need to ensure that Opset24.Pad accepts all the parameters that are legal for Opset23.Pad. Specifically, we should:
- Obtain the exact signature of
PadinOpset23. - Edit the definition of
PadinOpset24(beginning on line 1229) to match the parameter names, types, order, default values, and kinds (positional/keyword). - Ideally, the docstring should also reflect or extend the parent method's description, and type annotations should be consistent.
- The implementation within
Opset24.Padshould preserve existing functionality and call the super method as needed.
Since the only code shown is in onnxscript/onnx_opset/_impl/opset24.py, and only the signature in Opset24 is available, all changes must remain within this region. We'll:
- Change the signature of
PadinOpset24to match that ofOpset23(using reasonable inference). - If the base method accepted additional parameters, e.g., extra positional or keyword arguments (
*args, **kwargs), we should add them here. - No new imports or dependencies are needed.
-
Copy modified lines R1237-R1238
| @@ -1234,6 +1234,8 @@ | ||
| axes: Optional[Tind_Pad] = None, | ||
| *, | ||
| mode: str = "constant", | ||
| *args, | ||
| **kwargs, | ||
| ) -> T_Pad: | ||
| r"""[🌐 Pad(24)](https://onnx.ai/onnx/operators/onnx__Pad.html#pad-24 "Online Documentation") | ||
|
|
| UINT8, | ||
| ) | ||
|
|
||
| def Reshape(self, data: T_Reshape, shape: INT64, *, allowzero: int = 0) -> T_Reshape: |
Check warning
Code scanning / CodeQL
Signature mismatch in overriding method Warning
Opset1.Reshape
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 months ago
To resolve a signature mismatch in an overriding method, the Reshape method in Opset24 must accept all the argument signatures accepted by the Reshape method in Opset23. The best way is to change the Reshape method of Opset24 to match exactly the signature from the base class, which likely does not use the *-based keyword-only arguments, and instead uses regular positional or optional arguments.
Steps:
- Verify the base method signature: Since only this file is shown, but assuming the pattern matches, the most reasonable fix is to change from the current:
to
def Reshape(self, data: T_Reshape, shape: INT64, *, allowzero: int = 0) -> T_Reshape:
i.e., makedef Reshape(self, data: T_Reshape, shape: INT64, allowzero: int = 0) -> T_Reshape:
allowzeroa normal (not keyword-only) parameter, accepting positional or keyword calls. - Update the body accordingly: The call to the operator should remain valid.
- No other code or imports need changing.
Edit file:
onnxscript/onnx_opset/_impl/opset24.py, at the definition ofReshape(def Reshape(self, data: T_Reshape, shape: INT64, *, allowzero: int = 0)): Remove the*so thatallowzerois not keyword-only and signature matches base.
-
Copy modified line R1527
| @@ -1524,7 +1524,7 @@ | ||
| UINT8, | ||
| ) | ||
|
|
||
| def Reshape(self, data: T_Reshape, shape: INT64, *, allowzero: int = 0) -> T_Reshape: | ||
| def Reshape(self, data: T_Reshape, shape: INT64, allowzero: int = 0) -> T_Reshape: | ||
| r"""[🌐 Reshape(24)](https://onnx.ai/onnx/operators/onnx__Reshape.html#reshape-24 "Online Documentation") | ||
|
|
||
|
|
| def TopK( | ||
| self, X: T_TopK, K: INT64, *, axis: int = -1, largest: int = 1, sorted: int = 1 | ||
| ) -> Tuple[T_TopK, I_TopK]: |
Check warning
Code scanning / CodeQL
Signature mismatch in overriding method Warning
Opset1.TopK
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 months ago
To fix this issue, align the signature of the overriding TopK method in Opset24 with that of its predecessor in Opset23. Specifically, inspect the TopK signature in Opset23 and update Opset24.TopK to match positional and keyword arguments exactly (defaults, order, and presence). This usually means allowing the same positional arguments, keyword arguments, and *args/**kwargs if present. Make changes only in onnxscript/onnx_opset/_impl/opset24.py, in the shown region of the TopK method header.
If the only difference is the use of the * to force keyword-only parameters, remove or adjust it in the overriding method signature to match the base method. If there are extra parameters or differences in parameter names or order, adjust to match the base.
Steps:
- Obtain the exact signature of
Opset23.TopK. - Edit line 2190 of
onnxscript/onnx_opset/_impl/opset24.pysoOpset24.TopKhas the exact same parameter list. - Leave the rest of the logic unchanged.
-
Copy modified line R2191
| @@ -2188,7 +2188,7 @@ | ||
| I_TopK: TypeAlias = INT64 | ||
|
|
||
| def TopK( | ||
| self, X: T_TopK, K: INT64, *, axis: int = -1, largest: int = 1, sorted: int = 1 | ||
| self, X: T_TopK, K: INT64, axis: int = -1, largest: int = 1, sorted: int = 1 | ||
| ) -> Tuple[T_TopK, I_TopK]: | ||
| r"""[🌐 TopK(24)](https://onnx.ai/onnx/operators/onnx__TopK.html#topk-24 "Online Documentation") | ||
|
|
| UINT8, | ||
| ) | ||
|
|
||
| def Unsqueeze(self, data: T_Unsqueeze, axes: INT64) -> T_Unsqueeze: |
Check warning
Code scanning / CodeQL
Signature mismatch in overriding method Warning
Opset1.Unsqueeze
This method requires 3 positional arguments, whereas overridden
Opset11.Unsqueeze
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 2 months ago
To fix this problem, we need to ensure that Opset24.Unsqueeze's method signature is compatible with the overridden base method in Opset23. Typically, this means matching all legal parameters, including optional and keyword arguments. The safest fix is to mirror the parent method's signature: if the base method specifies Unsqueeze(self, data, axes=None), then the overriding method must do likewise. Because we are only allowed to edit what we've been shown, we should update the signature of Unsqueeze in Opset24 to
def Unsqueeze(self, data: T_Unsqueeze, axes: Optional[INT64] = None) -> T_Unsqueeze:so it will accept the same calls as any version in the base class, covering both positional and keyword usage, and remain backwards compatible.
For the internal logic, we must account for the fact that axes may be None. The call to _prepare_inputs(schema, data, axes) should be adjusted so that, if axes is None, it's not passed to _prepare_inputs, or that method can accept None. Since we are only shown this single code snippet, the best option is to ensure it works if axes is None, likely by filtering it out of the call.
-
Copy modified line R2316 -
Copy modified lines R2342-R2345
| @@ -2313,7 +2313,7 @@ | ||
| UINT8, | ||
| ) | ||
|
|
||
| def Unsqueeze(self, data: T_Unsqueeze, axes: INT64) -> T_Unsqueeze: | ||
| def Unsqueeze(self, data: T_Unsqueeze, axes: Optional[INT64] = None) -> T_Unsqueeze: | ||
| r"""[🌐 Unsqueeze(24)](https://onnx.ai/onnx/operators/onnx__Unsqueeze.html#unsqueeze-24 "Online Documentation") | ||
|
|
||
|
|
||
| @@ -2339,4 +2339,7 @@ | ||
|
|
||
| schema = get_schema("Unsqueeze", 24, "") | ||
| op = Op(self, "Unsqueeze", schema) | ||
| return op(*self._prepare_inputs(schema, data, axes)) | ||
| if axes is not None: | ||
| return op(*self._prepare_inputs(schema, data, axes)) | ||
| else: | ||
| return op(*self._prepare_inputs(schema, data)) |
❌ 3 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Signed-off-by: Justin Chu <[email protected]>
Signed-off-by: Justin Chu <[email protected]>
Uh oh!
There was an error while loading. Please reload this page.