Returns true if the given node produces a tensor value, or a collection of tensor values
(node: Any)
| 246 | |
| 247 | |
| 248 | def is_tensor_node(node: Any) -> bool: |
| 249 | """ |
| 250 | Returns true if the given node produces a tensor value, or a collection of tensor values |
| 251 | """ |
| 252 | if not isinstance(node, torch.fx.Node): |
| 253 | return False |
| 254 | |
| 255 | if "val" not in node.meta: |
| 256 | return False |
| 257 | |
| 258 | if isinstance(node.meta["val"], FakeTensor): |
| 259 | return True |
| 260 | |
| 261 | if isinstance(node.meta["val"], list) or isinstance(node.meta["val"], tuple): |
| 262 | return all(isinstance(x, FakeTensor) for x in node.meta["val"]) |
| 263 | |
| 264 | return False |
| 265 | |
| 266 | |
| 267 | def is_tensor_arg_node(node: Any) -> bool: |
no outgoing calls
no test coverage detected