Skip to content

Conversation

@gramalingam
Copy link
Collaborator

Redo #2703, thanks to Titai.

Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>
@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

❌ Patch coverage is 40.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.04%. Comparing base (c1bfdfc) to head (4553011).
⚠️ Report is 13 commits behind head on main.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
onnxscript/utils/replace.py 40.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2708      +/-   ##
==========================================
- Coverage   70.04%   70.04%   -0.01%     
==========================================
  Files         226      226              
  Lines       27177    27179       +2     
  Branches     2734     2734              
==========================================
+ Hits        19036    19037       +1     
- Misses       7197     7198       +1     
  Partials      944      944              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the replace_functions utility by extracting the core logic into a new replace_functions_inplace function that operates directly on IR models. The original replace_functions now acts as a wrapper that handles proto conversion and calls the new inplace variant.

Key changes:

  • Introduces replace_functions_inplace that operates on ir.Model and ir.Function types directly
  • Refactors replace_functions to convert protos and delegate to the inplace function

@titaiwangms titaiwangms merged commit 9dbf685 into main Nov 18, 2025
39 checks passed
@titaiwangms titaiwangms deleted the rama/inplace-replace branch November 18, 2025 21:26
def replace_functions(
model: onnx.ModelProto, functions: Sequence[onnx.FunctionProto]
) -> onnx.ModelProto:
def replace_functions_inplace(irmodel: ir.Model, irfunctions: Sequence[ir.Function]) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
def replace_functions_inplace(irmodel: ir.Model, irfunctions: Sequence[ir.Function]) -> None:
def replace_functions_inplace(model: ir.Model, functions: Collection[ir.Function]) -> None:

Consider consistent names

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

4 participants