Vulkan: handle a single tensor output arriving as a list - #22308
Open
msluszniak wants to merge 1 commit into
Open
Vulkan: handle a single tensor output arriving as a list#22308msluszniak wants to merge 1 commit into
msluszniak wants to merge 1 commit into
Conversation
num_tensors_in_node() counts the tensors associated with a node rather
than the nesting of meta["val"], so it returns 1 both for a bare
FakeTensor and for a one-element list. OpRepSets treats that count as
proof of the former and passes meta["val"] straight to
filter_invalid_reprs(), which then does tensor_val.shape on a list:
File "backends/vulkan/utils.py", line 1203, in filter_invalid_reprs
extents = required_image_extents(tensor_val.shape, memory_layout)
AttributeError: 'list' object has no attribute 'shape'
Any op declared to return Tensor[] hits this whenever it happens to
produce exactly one tensor. aten.split_with_sizes_copy.default is the
case seen in the wild (RF-DETR); it aborts partitioning for the whole
model instead of the node being reported unsupported.
Unwrap the single element before filtering, matching what the
multiple-output branch below already does per element.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22308
Note: Links to docs will display an error until the docs builds have been completed.
|
This PR needs a
|
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.
Summary
Fixes #22306.
num_tensors_in_node()counts the tensors associated with a node rather than the nesting ofmeta["val"], so it returns 1 both for a bareFakeTensorand for a one-element list.OpRepSetstreats that count as proof of the former and passesmeta["val"]straight tofilter_invalid_reprs(), which then doestensor_val.shapeon a list:Any op declared to return
Tensor[]hits this whenever it happens to produce exactly one tensor.aten.split_with_sizes_copy.defaultis the case seen in the wild (lowering RF-DETR nano). Because the exception escapes the partitioner, one such node aborts partitioning for the whole model instead of the node being reported unsupported.Unwrap the single element before filtering, matching what the multiple-output branch immediately below already does per element.
Test plan
New case in
backends/vulkan/test/test_vulkan_tensor_repr.pybuilding anOpRepSetsforsplit_with_sizes_copywhosemeta["val"]is a one-element list. It reproduces theAttributeErroronmainand passes with this change.cc @SS-JIA @manuelcandales @digantdesai @cbilgin