MCPcopy Create free account
hub / github.com/pytorch/executorch / is_unsqueezed_vector

Function is_unsqueezed_vector

backends/vulkan/utils.py:452–465  ·  view source on GitHub ↗

Returns True if the node's tensor has all dimensions equal to 1 except for the last dimension.

(node: torch.fx.Node)

Source from the content-addressed store, hash-verified

450
451
452def is_unsqueezed_vector(node: torch.fx.Node) -> bool:
453 """
454 Returns True if the node's tensor has all dimensions equal to 1 except for the last dimension.
455 """
456 if not is_single_tensor_node(node):
457 return False
458
459 tensor = node.meta["val"]
460 assert isinstance(tensor, FakeTensor)
461
462 if len(tensor.shape) < 1:
463 return False
464 # All dims except last are 1, last can be any size
465 return all(dim == 1 for dim in tensor.shape[:-1])
466
467
468def op_contains_bool_tensor(node: torch.fx.Node) -> bool:

Callers

nothing calls this directly

Calls 1

is_single_tensor_nodeFunction · 0.85

Tested by

no test coverage detected