MCPcopy Create free account
hub / github.com/ModelTC/LightX2V / calculate_memory

Function calculate_memory

lightx2v_kernel/python/lightx2v_kernel/utils.py:108–110  ·  view source on GitHub ↗

Calculate memory usage in bytes for a tensor.

(tensor: torch.Tensor)

Source from the content-addressed store, hash-verified

106 input_tensors += [value for value in kwargs.values() if isinstance(value, torch.Tensor)]
107
108 def calculate_memory(tensor: torch.Tensor):
109 """Calculate memory usage in bytes for a tensor."""
110 return tensor.numel() * tensor.element_size()
111
112 input_memory = sum(calculate_memory(t) for t in input_tensors)
113

Callers 1

benchmarkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected