Spaces:
Runtime error
Runtime error
Commit
·
941fdd9
1
Parent(s):
b07ecc4
Update monotonic_align/__init__.py
Browse files- monotonic_align/__init__.py +11 -15
monotonic_align/__init__.py
CHANGED
|
@@ -1,19 +1,15 @@
|
|
| 1 |
-
|
| 2 |
-
import
|
| 3 |
-
from .monotonic_align.core import maximum_path_c
|
| 4 |
|
|
|
|
| 5 |
|
| 6 |
def maximum_path(neg_cent, mask):
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
device = neg_cent.device
|
| 12 |
-
dtype = neg_cent.dtype
|
| 13 |
-
neg_cent = neg_cent.data.cpu().numpy().astype(np.float32)
|
| 14 |
-
path = np.zeros(neg_cent.shape, dtype=np.int32)
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
| 1 |
+
from numpy import zeros, int32, float32
|
| 2 |
+
from torch import from_numpy
|
|
|
|
| 3 |
|
| 4 |
+
from .core import maximum_path_jit
|
| 5 |
|
| 6 |
def maximum_path(neg_cent, mask):
|
| 7 |
+
device = neg_cent.device
|
| 8 |
+
dtype = neg_cent.dtype
|
| 9 |
+
neg_cent = neg_cent.data.cpu().numpy().astype(float32)
|
| 10 |
+
path = zeros(neg_cent.shape, dtype=int32)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
t_t_max = mask.sum(1)[:, 0].data.cpu().numpy().astype(int32)
|
| 13 |
+
t_s_max = mask.sum(2)[:, 0].data.cpu().numpy().astype(int32)
|
| 14 |
+
maximum_path_jit(path, neg_cent, t_t_max, t_s_max)
|
| 15 |
+
return from_numpy(path).to(device=device, dtype=dtype)
|