cddb07a176
build container image / cpu (push) Waiting to run
build container image / cuda (push) Waiting to run
build container image / rocm (push) Waiting to run
frontend tests / frontend-tests (push) Waiting to run
openapi checks / openapi-checks (push) Waiting to run
python tests / py3.12: macos-default (push) Waiting to run
python tests / py3.11: windows-cpu (push) Waiting to run
python tests / py3.12: windows-cpu (push) Waiting to run
python tests / py3.11: linux-cpu (push) Waiting to run
python tests / py3.12: linux-cpu (push) Waiting to run
typegen checks / typegen-checks (push) Waiting to run
uv lock checks / uv-lock-checks (push) Waiting to run
frontend checks / frontend-checks (push) Waiting to run
lfs checks / lfs-check (push) Waiting to run
python checks / python-checks (push) Waiting to run
python tests / py3.11: macos-default (push) Waiting to run
docs / deploy (push) Has been cancelled
docs / changes (push) Has been cancelled
docs / check-and-build (push) Has been cancelled
12 lines
353 B
Python
12 lines
353 B
Python
import torch
|
|
|
|
|
|
def calc_tensor_size(t: torch.Tensor) -> int:
|
|
"""Calculate the size of a tensor in bytes."""
|
|
return t.nelement() * t.element_size()
|
|
|
|
|
|
def calc_tensors_size(tensors: list[torch.Tensor | None]) -> int:
|
|
"""Calculate the size of a list of tensors in bytes."""
|
|
return sum(calc_tensor_size(t) for t in tensors if t is not None)
|