[hotfix]: Remove math.prod dependency (#2837)

* Remove math.prod dependency

* Fix style

* Fix style

---------

Co-authored-by: Jiatong Han <jiatong.han@u.nus.edu>
This commit is contained in:
Jiatong (Julius) Han
2023-02-23 23:56:15 +08:00
committed by GitHub
parent 819e25d8b1
commit 8c8a39be95
2 changed files with 99 additions and 100 deletions

View File

@@ -1,6 +1,6 @@
import math
import operator
from copy import copy
from functools import lru_cache
from functools import lru_cache, reduce
from typing import Callable, Optional, Set
import torch
@@ -312,7 +312,7 @@ class ColoTensor(torch.Tensor):
def numel_global(self):
"""Returns the number of elements in the tensor when it's replicated.
"""
return math.prod(self.size_global())
return reduce(operator.mul, self.size_global(), 1)
# Some API for dist spec check