Skip to content

Conversation

@titaiwangms
Copy link
Contributor

Split input (SymbolicTensor) could have no const_value, but with shape that gives us information of how many outputs an op.Split should return.

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 updates the SplitToSequence function in constant folding to handle cases where the Split input has no constant value but has shape information that can be used to determine the number of outputs. It also refactors the constant folding pass to improve its API and reduce verbosity in logging.

Key changes:

  • Enhanced split_to_sequence to use shape information when constant values aren't available
  • Replaced should_fold callback parameter with always_fold_ops collection for better API design
  • Streamlined logging and code structure in the constant folding pass

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
onnxscript/optimizer/_constant_folding.py Updated SplitToSequence logic, refactored FoldConstantsPass API, improved logging
onnxscript/function_libs/torch_lib/ops/core.py Added trace_only flag to aten_split_with_sizes function

Comment on lines +919 to +920
always_fold_ops: Collection of op types that should always be folded.
For ops from the default opset, only op_type is neede (e.g. "Transpose"),
Copy link

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

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

There's a typo in the docstring: 'neede' should be 'needed'.

Suggested change
always_fold_ops: Collection of op types that should always be folded.
For ops from the default opset, only op_type is neede (e.g. "Transpose"),
For ops from the default opset, only op_type is needed (e.g. "Transpose"),

Copilot uses AI. Check for mistakes.
Comment on lines +1280 to +1282
always_fold_ops: A collection of op types that should always be folded,
regardless of their input or output sizes. For ops from the default opset,
only op_type is neede (e.g. "Transpose"), otherwise specify the domain
Copy link

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

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

There's a typo in the docstring: 'neede' should be 'needed'.

Suggested change
always_fold_ops: A collection of op types that should always be folded,
regardless of their input or output sizes. For ops from the default opset,
only op_type is neede (e.g. "Transpose"), otherwise specify the domain
only op_type is needed (e.g. "Transpose"), otherwise specify the domain

Copilot uses AI. Check for mistakes.
Comment on lines +1105 to +1107
if logger.isEnabledFor(logging.DEBUG):
logger.debug(
"Skipping constant folding for node %s because it has non-constant inputs",
Copy link

Copilot AI Sep 4, 2025

Choose a reason for hiding this comment

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

The debug message format string expects one placeholder (%s) but receives two arguments: the node and the list of input names. Either add another %s placeholder or combine the arguments.

Suggested change
if logger.isEnabledFor(logging.DEBUG):
logger.debug(
"Skipping constant folding for node %s because it has non-constant inputs",
"Skipping constant folding for node %s because it has non-constant inputs: %s",

Copilot uses AI. Check for mistakes.
shape_inference=onnx_shape_inference,
input_size_limit=input_size_limit,
output_size_limit=output_size_limit,
should_fold=should_fold,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be reverted

@codecov
Copy link

codecov bot commented Sep 4, 2025

Codecov Report

❌ Patch coverage is 50.00000% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 63.26%. Comparing base (d98e3dd) to head (ecabee2).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
onnxscript/optimizer/_constant_folding.py 48.57% 13 Missing and 5 partials ⚠️

❗ There is a different number of reports uploaded between BASE (d98e3dd) and HEAD (ecabee2). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (d98e3dd) HEAD (ecabee2)
21 20
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2542      +/-   ##
==========================================
- Coverage   69.99%   63.26%   -6.73%     
==========================================
  Files         216      216              
  Lines       26074    26073       -1     
  Branches     2618     2619       +1     
==========================================
- Hits        18250    16496    -1754     
- Misses       6921     8745    +1824     
+ Partials      903      832      -71     

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

@titaiwangms
Copy link
Contributor Author

#2544

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

Projects

Development

Successfully merging this pull request may close these issues.

2 participants