Conversation
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
There was a problem hiding this comment.
lintrunner found more than 20 potential problems in the proposed changes. Check the Files changed tab for more details.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2808 +/- ##
==========================================
+ Coverage 70.52% 70.69% +0.17%
==========================================
Files 228 231 +3
Lines 27135 27564 +429
Branches 2727 2776 +49
==========================================
+ Hits 19137 19487 +350
- Misses 7065 7125 +60
- Partials 933 952 +19 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
| dtype = ir.DataType.STRING | ||
| else: | ||
| raise TypeError(f"Unsupported scalar type: {type(value)}") | ||
| tensor = ir.Tensor( |
Check failure
Code scanning / lintrunner
PYLINT/E1123 Error
| dtype = ir.DataType.STRING | ||
| else: | ||
| raise TypeError(f"Unsupported scalar type: {type(value)}") | ||
| tensor = ir.Tensor( |
Check failure
Code scanning / lintrunner
PYLINT/E1120 Error
|
|
||
| def _partition_inputs_attributes( | ||
| self, | ||
| schema: onnx.defs.OpSchema | None, |
Check warning
Code scanning / lintrunner
PYLINT/W0613 Warning
|
|
||
| def _cast_attributes( | ||
| self, | ||
| schema: onnx.defs.OpSchema | None, |
Check warning
Code scanning / lintrunner
PYLINT/W0613 Warning
| if attributes is None: | ||
| attrs: Sequence[ir.Attr] = () | ||
| else: | ||
| attrs = ir._convenience.convert_attributes(attributes) |
Check warning
Code scanning / lintrunner
PYLINT/W0212 Warning
| return value | ||
| elif isinstance(value, (int, float, bool, str)): | ||
| # Scalar constant | ||
| import numpy as np |
Check notice
Code scanning / lintrunner
PYLINT/C0415 Note
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
| t2 = op.CustomOp(t1, y, _domain="com.microsoft") | ||
|
|
||
| # Create another custom domain operation with different domain | ||
| t3 = op.AnotherOp(t2, x, _domain="com.custom") |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 days ago
In general, for an unused local variable whose assignment has side effects, keep the expression (to preserve side effects) but drop or rename the unused binding. Here, the call to op.AnotherOp must remain so that the third node is added to the graph, but we do not need to store its result.
The best minimal fix without changing functionality is to remove the t3 = part and just call op.AnotherOp(t2, x, _domain="com.custom") as a standalone statement. This preserves the graph mutation while eliminating the unused variable. No imports, helper methods, or additional definitions are needed, and no other lines in the file require modification.
| @@ -324,7 +324,7 @@ | ||
| t2 = op.CustomOp(t1, y, _domain="com.microsoft") | ||
|
|
||
| # Create another custom domain operation with different domain | ||
| t3 = op.AnotherOp(t2, x, _domain="com.custom") | ||
| op.AnotherOp(t2, x, _domain="com.custom") | ||
|
|
||
| # Verify all nodes were created with correct domains | ||
| nodes = list(op.builder.graph) |
|
|
||
| # Use operations through the custom domain opset builder | ||
| t1 = ms_op.CustomOp(x, y) | ||
| t2 = ms_op.AnotherOp(t1, x) |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 days ago
In general, to fix an unused local variable where the right-hand side has side effects, you should keep the expression call and remove only the binding of its result, or rename the variable to an “unused” name if you want to explicitly mark it as intentionally unused. Here, the right-hand side ms_op.AnotherOp(t1, x) clearly has the desired side effect of adding a node to op.builder.graph, and the variable t2 is never subsequently used.
The best minimal fix without changing functionality is to drop the assignment and just call the method. In onnxscript/_internal/builder_test.py, within test_opset_builder_for_custom_domain, change line 351 from t2 = ms_op.AnotherOp(t1, x) to ms_op.AnotherOp(t1, x). No new imports or helper methods are required, and no other lines in this file need to be touched.
| @@ -348,7 +348,7 @@ | ||
|
|
||
| # Use operations through the custom domain opset builder | ||
| t1 = ms_op.CustomOp(x, y) | ||
| t2 = ms_op.AnotherOp(t1, x) | ||
| ms_op.AnotherOp(t1, x) | ||
|
|
||
| # Verify all nodes were created with the correct domain | ||
| nodes = list(op.builder.graph) |
| # Mix operations from different domains | ||
| t1 = op.Add(x, y) # Standard domain operation | ||
| t2 = ms_op.MsAdd(t1, y) # Custom domain operation | ||
| t3 = op.Mul(t2, x) # Back to standard domain |
Check notice
Code scanning / CodeQL
Unused local variable Note
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 3 days ago
In general, to fix an unused local variable whose right-hand side has important side effects, you keep the expression but either remove the left-hand side entirely (if syntax allows) or bind it to a name that clearly indicates it is intentionally unused (such as _ or a name containing unused). This preserves behavior while silencing the warning and clarifying intent.
Here, we should not remove the op.Mul(t2, x) call, because its side effect (adding a node to the graph) is required for the later assertions about nodes[2]. The simplest, non-disruptive change is to rename t3 to _ on line 379. That makes it explicit that the result value is not used while leaving test logic unchanged. No imports or further definitions are required, and only that single line in onnxscript/_internal/builder_test.py needs modification.
| @@ -376,7 +376,7 @@ | ||
| # Mix operations from different domains | ||
| t1 = op.Add(x, y) # Standard domain operation | ||
| t2 = ms_op.MsAdd(t1, y) # Custom domain operation | ||
| t3 = op.Mul(t2, x) # Back to standard domain | ||
| _ = op.Mul(t2, x) # Back to standard domain | ||
|
|
||
| # Verify nodes were created with correct domains | ||
| nodes = list(op.builder.graph) |
| t2 = op.CustomOp(t1, y, _domain="com.microsoft") | ||
|
|
||
| # Create another custom domain operation with different domain | ||
| t3 = op.AnotherOp(t2, x, _domain="com.custom") |
|
|
||
| # Use operations through the custom domain opset builder | ||
| t1 = ms_op.CustomOp(x, y) | ||
| t2 = ms_op.AnotherOp(t1, x) |
| # Mix operations from different domains | ||
| t1 = op.Add(x, y) # Standard domain operation | ||
| t2 = ms_op.MsAdd(t1, y) # Custom domain operation | ||
| t3 = op.Mul(t2, x) # Back to standard domain |
|
|
||
|
|
||
| class GraphBuilder: | ||
| def __init__(self, graph: ir.Graph, is_function: bool) -> None: |
Check warning
Code scanning / lintrunner
PYLINT/W0613 Warning
| t2 = op.CustomOp(t1, y, _domain="com.microsoft") | ||
|
|
||
| # Create another custom domain operation with different domain | ||
| t3 = op.AnotherOp(t2, x, _domain="com.custom") |
Check warning
Code scanning / lintrunner
PYLINT/W0612 Warning
| t2 = op.CustomOp(t1, y, _domain="com.microsoft") | ||
|
|
||
| # Create another custom domain operation with different domain | ||
| t3 = op.AnotherOp(t2, x, _domain="com.custom") |
Check warning
Code scanning / lintrunner
RUFF/F841 Warning
|
|
||
| # Use operations through the custom domain opset builder | ||
| t1 = ms_op.CustomOp(x, y) | ||
| t2 = ms_op.AnotherOp(t1, x) |
Check warning
Code scanning / lintrunner
PYLINT/W0612 Warning
|
|
||
| # Use operations through the custom domain opset builder | ||
| t1 = ms_op.CustomOp(x, y) | ||
| t2 = ms_op.AnotherOp(t1, x) |
Check warning
Code scanning / lintrunner
RUFF/F841 Warning
| # Mix operations from different domains | ||
| t1 = op.Add(x, y) # Standard domain operation | ||
| t2 = ms_op.MsAdd(t1, y) # Custom domain operation | ||
| t3 = op.Mul(t2, x) # Back to standard domain |
Check warning
Code scanning / lintrunner
PYLINT/W0612 Warning
| # Mix operations from different domains | ||
| t1 = op.Add(x, y) # Standard domain operation | ||
| t2 = ms_op.MsAdd(t1, y) # Custom domain operation | ||
| t3 = op.Mul(t2, x) # Back to standard domain |
Check warning
Code scanning / lintrunner
RUFF/F841 Warning
|
Hmmm ... interesting, I don't remember creating this PR (as it is still WIP) ... |
No description provided.