Skip to content

Commit 90c5a67

Browse files
msluszniakSS-JIA
authored andcommitted
Vulkan: handle a single tensor output arriving as a list
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.
1 parent 1e937f2 commit 90c5a67

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎backends/vulkan/test/test_vulkan_tensor_repr.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,29 @@ def test_unary_op_construction(self):
605605
self.assertEqual(op_repsets.primary_arg_idx, 0)
606606
self.assertTrue(op_repsets.sync_primary_io_repr)
607607

608+
def test_single_tensor_output_in_list_construction(self):
609+
"""An op declared to return Tensor[] that yields exactly one tensor.
610+
611+
num_tensors_in_node() counts tensors rather than nesting, so such a
612+
node reports 1 while meta["val"] is a one-element list rather than a
613+
bare FakeTensor.
614+
"""
615+
arg = _make_tensor_arg_node((1, 3, 8, 8))
616+
node = _make_op_node(
617+
target=torch.ops.aten.split_with_sizes_copy.default,
618+
args=(arg, [3]),
619+
output_val=[_make_fake_tensor((1, 3, 8, 8))],
620+
)
621+
622+
op_repsets = OpRepSets(
623+
TensorRepSetList(ANY_STORAGE),
624+
TensorRepSetList(ANY_STORAGE),
625+
node,
626+
DEFAULT_TEXTURE_LIMITS,
627+
)
628+
629+
self.assertFalse(op_repsets.any_is_empty())
630+
608631
def test_binary_op_syncs_args(self):
609632
"""When a single repset covers all inputs, sync_args_repr is True."""
610633
op_repsets = self._make_binary_op()

‎backends/vulkan/utils.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1442,8 +1442,15 @@ def __init__( # noqa: C901
14421442
outs_repset_list = TensorRepSetList([])
14431443
common_out_repset = ANY_STORAGE_INCL_PACKED_INT8
14441444
if num_tensors_in_node(op_node) == 1:
1445+
out_val = op_node.meta["val"]
1446+
# num_tensors_in_node counts tensors, not nesting: an op declared
1447+
# to return Tensor[] still lands here when it happens to produce
1448+
# exactly one, and meta["val"] is then a one-element list rather
1449+
# than a bare FakeTensor.
1450+
if isinstance(out_val, (list, tuple)):
1451+
out_val = out_val[0]
14451452
common_out_repset = filter_invalid_reprs(
1446-
op_node.meta["val"], outputs_repsets[0], texture_limits
1453+
out_val, outputs_repsets[0], texture_limits
14471454
)
14481455
outs_repset_list.append(common_out_repset)
14491456
# Multiple output tensors

0 commit comments

Comments
 (0)