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

Function num_tensors_in_node

backends/vulkan/utils.py:293–307  ·  view source on GitHub ↗

Returns the number of tensors associated a given node

(node: torch.fx.Node)

Source from the content-addressed store, hash-verified

291
292
293def num_tensors_in_node(node: torch.fx.Node) -> int:
294 """
295 Returns the number of tensors associated a given node
296 """
297 if "val" not in node.meta:
298 return 0
299
300 if isinstance(node.meta["val"], FakeTensor):
301 return 1
302
303 if isinstance(node.meta["val"], list) or isinstance(node.meta["val"], tuple):
304 if all(isinstance(x, FakeTensor) for x in node.meta["val"]):
305 return len(node.meta["val"])
306
307 return 0
308
309
310def get_vk_datatype(torch_dtype: torch.dtype) -> VkDataType:

Callers 3

__init__Method · 0.85
pick_representationsMethod · 0.85
set_node_reprFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected