From 0d97bcd7869d55af2cbeebafdcf73a16c09c018d Mon Sep 17 00:00:00 2001 From: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Date: Fri, 30 Sep 2022 07:36:02 -0400 Subject: [PATCH] Use np.prod for compatibility with Python 3.7 (#14) --- bindings/python/py_src/safetensors/torch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- 2.43.0