Skip to content

Commit 4c2b8cb

Browse files
committed
use math instead of numpy for prod()
Signed-off-by: Hao Wu <[email protected]>
1 parent 4104842 commit 4c2b8cb

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

emerging_optimizers/utils/modules.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
import math
1617
from typing import Any, Self
1718

18-
import numpy as np
1919
import torch
2020
import torch.nn as nn
2121
import torch.nn.functional as F
@@ -54,7 +54,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
5454
self.weight: nn.Parameter[torch.Tensor]
5555
self.bias: nn.Parameter[torch.Tensor] | None | str
5656

57-
flat_weight_shape = [self.out_channels, np.prod(self.weight.shape[1:])]
57+
flat_weight_shape = [self.out_channels, math.prod(self.weight.shape[1:])]
5858
if self.bias is not None:
5959
flat_weight_shape[1] += 1
6060
flat_weight_buffer = torch.empty(flat_weight_shape, device=self.weight.device, dtype=self.weight.dtype)

0 commit comments

Comments
 (0)