Conversation
There was a problem hiding this comment.
Pull request overview
This pull request improves constant folding for Reshape operations by materializing shape inputs as constants when the output shape is known from shape inference. It also adds support for INT32 dtype shape inputs, which are common in TFLite models.
Changes:
- Added INT32 fallback support in
get_shape_value()for shape inputs (common in TFLite models) - Implemented
_try_materialize_reshape_shape()to create constant shape inputs from inferred output shapes - Updated
reshape()function to leverage shape materialization for optimization
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2807 +/- ##
==========================================
+ Coverage 70.50% 70.63% +0.12%
==========================================
Files 228 230 +2
Lines 27114 27261 +147
Branches 2726 2746 +20
==========================================
+ Hits 19116 19255 +139
- Misses 7065 7066 +1
- Partials 933 940 +7 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
a67ab69 to
3c550df
Compare
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Justin Chu <justinchuby@users.noreply.github.com>
|
|
||
| if sym_count == 0: | ||
| self._new_dims = [int(d) for d in dims] | ||
| elif sym_count == 1: |
There was a problem hiding this comment.
Nit: We can omit the first branch and generalize this condition to sym_count <= 1 since the logic below handles both cases correctly.
| ) | ||
|
|
||
| # Preserve allowzero attribute from original node | ||
| self._allowzero = context.nodes[0].attributes.get_int("allowzero", 0) |
There was a problem hiding this comment.
This may not be correct. I think we may need to make allowzero=1 in the rewritten node
There was a problem hiding this comment.
Let me rephrase. May be it is correct. But verifying it is correct seems less trivial. It seems easier if allowzero=1.
There was a problem hiding this comment.
I thought about this and thought the current is correct. Let me look at this again
Uh oh!
There was an error while loading. Please reload this page.