rustat-python-api 0.6.6__py3-none-any.whl → 0.7.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- rustat_python_api/kernels/__init__.py +4 -1
- rustat_python_api/kernels/maha.py +76 -71
- rustat_python_api/pitch_control.py +4 -2
- {rustat_python_api-0.6.6.dist-info → rustat_python_api-0.7.1.dist-info}/METADATA +1 -1
- {rustat_python_api-0.6.6.dist-info → rustat_python_api-0.7.1.dist-info}/RECORD +8 -8
- {rustat_python_api-0.6.6.dist-info → rustat_python_api-0.7.1.dist-info}/LICENSE +0 -0
- {rustat_python_api-0.6.6.dist-info → rustat_python_api-0.7.1.dist-info}/WHEEL +0 -0
- {rustat_python_api-0.6.6.dist-info → rustat_python_api-0.7.1.dist-info}/top_level.txt +0 -0
|
@@ -1,72 +1,77 @@
|
|
|
1
1
|
import torch
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
2
|
+
|
|
3
|
+
try:
|
|
4
|
+
import triton
|
|
5
|
+
import triton.language as tl
|
|
6
|
+
|
|
7
|
+
@triton.jit
|
|
8
|
+
def influence_kernel(
|
|
9
|
+
MU, # (F,P,2)
|
|
10
|
+
SIGMA_INV, # (F,P,2,2)
|
|
11
|
+
LOCS, # (N,2) – read-only
|
|
12
|
+
OUT, # (F,N)
|
|
13
|
+
F, P, N, # sizes
|
|
14
|
+
BLOCK_N: tl.constexpr, # кол-во точек на блок
|
|
15
|
+
):
|
|
16
|
+
pid_f = tl.program_id(0) # какой frame
|
|
17
|
+
offs_n = tl.program_id(1) * BLOCK_N + tl.arange(0, BLOCK_N) # chunk точек
|
|
18
|
+
mask_n = offs_n < N
|
|
19
|
+
|
|
20
|
+
loc_ptr = LOCS + offs_n[:, None] * 2 # strides=(2,)
|
|
21
|
+
x = tl.load(loc_ptr, mask=mask_n[:, None]) # (BLOCK_N,2)
|
|
22
|
+
|
|
23
|
+
acc = tl.zeros([BLOCK_N], dtype=tl.float32)
|
|
24
|
+
|
|
25
|
+
for p in tl.static_range(0, 32):
|
|
26
|
+
is_valid = p < P
|
|
27
|
+
|
|
28
|
+
# --- pointers ---
|
|
29
|
+
mu_ptr = MU + pid_f * P * 2 + p * 2
|
|
30
|
+
s_ptr = SIGMA_INV + pid_f * P * 4 + p * 4
|
|
31
|
+
|
|
32
|
+
# --- scalar loads ---
|
|
33
|
+
mu0 = tl.load(mu_ptr + 0, mask=is_valid)
|
|
34
|
+
mu1 = tl.load(mu_ptr + 1, mask=is_valid)
|
|
35
|
+
|
|
36
|
+
s00 = tl.load(s_ptr + 0, mask=is_valid)
|
|
37
|
+
s01 = tl.load(s_ptr + 1, mask=is_valid)
|
|
38
|
+
s10 = tl.load(s_ptr + 2, mask=is_valid)
|
|
39
|
+
s11 = tl.load(s_ptr + 3, mask=is_valid)
|
|
40
|
+
|
|
41
|
+
# --- grid coords (also scalar) ---
|
|
42
|
+
x0 = tl.load(LOCS + offs_n * 2 + 0, mask=mask_n) # (BLOCK_N,)
|
|
43
|
+
x1 = tl.load(LOCS + offs_n * 2 + 1, mask=mask_n)
|
|
44
|
+
|
|
45
|
+
diff0 = x0 - mu0
|
|
46
|
+
diff1 = x1 - mu1
|
|
47
|
+
|
|
48
|
+
tmp0 = diff0 * s00 + diff1 * s01
|
|
49
|
+
tmp1 = diff0 * s10 + diff1 * s11
|
|
50
|
+
maha = diff0 * tmp0 + diff1 * tmp1
|
|
51
|
+
|
|
52
|
+
acc += tl.where(is_valid, tl.exp(-0.5 * maha), 0.0)
|
|
53
|
+
|
|
54
|
+
out_ptr = OUT + pid_f*N + offs_n
|
|
55
|
+
tl.store(out_ptr, acc, mask=mask_n)
|
|
56
|
+
|
|
57
|
+
def triton_influence(mu, sigma_inv, locs, BLOCK_N=64):
|
|
58
|
+
F, P, _ = mu.shape
|
|
59
|
+
N = locs.shape[0]
|
|
60
|
+
out = torch.empty((F, N), device=mu.device, dtype=mu.dtype)
|
|
61
|
+
|
|
62
|
+
grid = (F, triton.cdiv(N, BLOCK_N))
|
|
63
|
+
influence_kernel[grid](
|
|
64
|
+
mu, sigma_inv, locs, out,
|
|
65
|
+
F, P, N,
|
|
66
|
+
BLOCK_N=BLOCK_N,
|
|
67
|
+
num_warps=4
|
|
68
|
+
)
|
|
69
|
+
return out
|
|
70
|
+
|
|
71
|
+
except ImportError:
|
|
72
|
+
def triton_influence(*args, **kwargs):
|
|
73
|
+
raise RuntimeError(
|
|
74
|
+
"Triton not available. This function requires Linux with NVIDIA GPU. "
|
|
75
|
+
"For CPU fallback, please use the .calculate_influence() method with device='cpu'. "
|
|
76
|
+
"On macOS, the package installs without GPU acceleration."
|
|
77
|
+
)
|
|
@@ -7,8 +7,10 @@ import matplotsoccer as mpl
|
|
|
7
7
|
import torch
|
|
8
8
|
from tqdm import tqdm
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
try:
|
|
11
|
+
from .kernels import triton_influence
|
|
12
|
+
except ImportError:
|
|
13
|
+
triton_influence = None
|
|
12
14
|
|
|
13
15
|
class PitchControl:
|
|
14
16
|
def __init__(self, tracking: pd.DataFrame, events: pd.DataFrame, ball_data: pd.DataFrame = None):
|
|
@@ -2,13 +2,13 @@ rustat_python_api/__init__.py,sha256=Ij-PAm2y5ss_XAZhKTZus35cRPLzvXFyIswDa_Iq3rs
|
|
|
2
2
|
rustat_python_api/config.py,sha256=eMvi1p8Cfvnbp6Cd4bBOwgehVN7thKnaQV5uzWyGZXM,1844
|
|
3
3
|
rustat_python_api/models_api.py,sha256=oHXEqeCupvZwjVEdoxf7W9LP7ELFKA8-9DuRXpQHLno,1701
|
|
4
4
|
rustat_python_api/parser.py,sha256=c5SW9p5N1PLYnza1olZbnvxkWtCAYYty2ifjyaUwXkw,10280
|
|
5
|
-
rustat_python_api/pitch_control.py,sha256=
|
|
5
|
+
rustat_python_api/pitch_control.py,sha256=iJiF0_3j6yh3riV8kTZ_mtJibPqotQZOUgpumSyS-Zw,26338
|
|
6
6
|
rustat_python_api/processing.py,sha256=WES2D77uu3ScpjN0nW8ozatHteCZJQmmF9WpHPgGfJo,2835
|
|
7
7
|
rustat_python_api/urls.py,sha256=iJTD31T6OyXPAhmhViwFXVehrzwsOjBDONA1SIVc_40,1068
|
|
8
|
-
rustat_python_api/kernels/__init__.py,sha256=
|
|
9
|
-
rustat_python_api/kernels/maha.py,sha256=
|
|
10
|
-
rustat_python_api-0.
|
|
11
|
-
rustat_python_api-0.
|
|
12
|
-
rustat_python_api-0.
|
|
13
|
-
rustat_python_api-0.
|
|
14
|
-
rustat_python_api-0.
|
|
8
|
+
rustat_python_api/kernels/__init__.py,sha256=eFJ-BMY8VcNZSjf3XjOnZf_nfOQ5t-7Lp57DPCHYOo0,124
|
|
9
|
+
rustat_python_api/kernels/maha.py,sha256=k2PqY6VghgER2j9QH8xGYq61JLfPaHjirLXb4aLnjQw,2591
|
|
10
|
+
rustat_python_api-0.7.1.dist-info/LICENSE,sha256=4Cohqg5p6Mq1xyrzdEX8AvFSA62GSVvapEOr2xK_tgY,57
|
|
11
|
+
rustat_python_api-0.7.1.dist-info/METADATA,sha256=Db46gm9pWb-1Zra3BrFFnUI8AU9aLJ4D93XQxnZc6PU,1808
|
|
12
|
+
rustat_python_api-0.7.1.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
|
|
13
|
+
rustat_python_api-0.7.1.dist-info/top_level.txt,sha256=VK0hmkKZE9YThxolUcoE6JtGI67NFeKJMBLuet8kI4w,18
|
|
14
|
+
rustat_python_api-0.7.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|