Fix GetItemList setting an incorrect static output shape#2275
Open
zlee-cf wants to merge 2 commits into
Open
Conversation
GetItemList.make_node returned x.type(), cloning x's full static shape. For a SparseConstant the row count is fully specified, so the output was typed with the parent's rows regardless of the index length, breaking vectorize_graph via a spurious SpecifyShape. Take the row dim from the index and keep x's column dim, matching infer_shape.
1a58ad8 to
8805b8c
Compare
Member
|
I fixed a few more wrong make_nodes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
sparse.get_item_list(x, index)selects rows of a sparse matrix, so its output haslen(index)rows. ButGetItemList.make_nodereturned the output asx.type(), which clonesx's full static shape (including its row count).For a
SparseConstant, that shape is fully specified (e.g.(500, 40)), so the output was statically typed with the parent's row count regardless of the index length. A symbolic (shared) matrix has shape(None, None), so it never hit this.infer_shapeand the runtime value were always correct — only the static output type was wrong.This broke
vectorize_graphwhich trusts the static shape, inserts aSpecifyShape, and then asserts at runtime:The fix builds the output type with the row dim taken from the index (
Nonewhen unknown, or its statically-known length) and the column dim preserved fromx, matchinginfer_shape.Related Issue
Checklist
Type of change