Returns True if the node's tensor has all dimensions equal to 1 except for the last dimension.
(node: torch.fx.Node)
| 450 | |
| 451 | |
| 452 | def 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 | |
| 468 | def op_contains_bool_tensor(node: torch.fx.Node) -> bool: |
nothing calls this directly
no test coverage detected