From: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Date: Fri, 30 Sep 2022 11:36:02 +0000 (-0400) Subject: Use np.prod for compatibility with Python 3.7 (#14) X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=0d97bcd7869d55af2cbeebafdcf73a16c09c018d;p=safetensors.git Use np.prod for compatibility with Python 3.7 (#14) --- diff --git a/bindings/python/py_src/safetensors/torch.py b/bindings/python/py_src/safetensors/torch.py index 2a5485d..8e36a93 100644 --- a/bindings/python/py_src/safetensors/torch.py +++ b/bindings/python/py_src/safetensors/torch.py @@ -84,7 +84,7 @@ def _tobytes(tensor: torch.Tensor) -> bytes: import ctypes import numpy as np - length = math.prod(tensor.shape) + length = np.prod(tensor.shape).item() bytes_per_item = _SIZE[tensor.dtype] total_bytes = length * bytes_per_item