Skip to content

Commit 1448a78

Browse files
author
Zhuoming Chen
committed
comments and docs
1 parent 79fe024 commit 1448a78

1 file changed

Lines changed: 24 additions & 18 deletions

File tree

vortex_torch/indexer/reduce.py

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ class Reduce(vOp):
1515
1616
.. math::
1717
18-
Y_{n,0,d} = \rho_{\,0 \le i < D_0}\, X_{n,i,d}\ \ (\text{dim}=1),
19-
\qquad
20-
Y_{n,d,0} = \rho_{\,0 \le j < D_1}\, X_{n,d,j}\ \ (\text{dim}=2).
18+
\begin{aligned}
19+
(\text{dim}=1):\quad & Y_{n,0,d} = \rho_{\,0 \le i < D_0}\, X_{n,i,d}, \\
20+
(\text{dim}=2):\quad & Y_{n,d,0} = \rho_{\,0 \le j < D_1}\, X_{n,d,j}.
21+
\end{aligned}
2122
2223
``dim=0`` collapses the packed leading axis to one row per
2324
``(batch, kv\_head)``.
@@ -108,9 +109,10 @@ class Max(Reduce):
108109
:Math:
109110
.. math::
110111
111-
Y_{n,0,d} = \max_{0 \le i < D_0} X_{n,i,d}\ \ (\text{dim}=1),
112-
\qquad
113-
Y_{n,d,0} = \max_{0 \le j < D_1} X_{n,d,j}\ \ (\text{dim}=2).
112+
\begin{aligned}
113+
(\text{dim}=1):\quad & Y_{n,0,d} = \max_{0 \le i < D_0} X_{n,i,d}, \\
114+
(\text{dim}=2):\quad & Y_{n,d,0} = \max_{0 \le j < D_1} X_{n,d,j}.
115+
\end{aligned}
114116
:__init__: ``Max(dim=1)`` — axis to reduce (``1`` → :math:`D_0`,
115117
``2`` → :math:`D_1`).
116118
:__call__: ``y = op(x, ctx=ctx)`` — ``[N, D_0, D_1]`` → ``[N, 1, D_1]``
@@ -128,9 +130,10 @@ class Min(Reduce):
128130
:Math:
129131
.. math::
130132
131-
Y_{n,0,d} = \min_{0 \le i < D_0} X_{n,i,d}\ \ (\text{dim}=1),
132-
\qquad
133-
Y_{n,d,0} = \min_{0 \le j < D_1} X_{n,d,j}\ \ (\text{dim}=2).
133+
\begin{aligned}
134+
(\text{dim}=1):\quad & Y_{n,0,d} = \min_{0 \le i < D_0} X_{n,i,d}, \\
135+
(\text{dim}=2):\quad & Y_{n,d,0} = \min_{0 \le j < D_1} X_{n,d,j}.
136+
\end{aligned}
134137
:__init__: ``Min(dim=1)`` — axis to reduce (``1`` → :math:`D_0`,
135138
``2`` → :math:`D_1`).
136139
:__call__: ``y = op(x, ctx=ctx)`` — ``[N, D_0, D_1]`` → ``[N, 1, D_1]``
@@ -148,9 +151,10 @@ class Mean(Reduce):
148151
:Math:
149152
.. math::
150153
151-
Y_{n,0,d} = \frac{1}{D_0}\sum_{i=0}^{D_0-1} X_{n,i,d}\ \ (\text{dim}=1),
152-
\qquad
153-
Y_{n,d,0} = \frac{1}{D_1}\sum_{j=0}^{D_1-1} X_{n,d,j}\ \ (\text{dim}=2).
154+
\begin{aligned}
155+
(\text{dim}=1):\quad & Y_{n,0,d} = \frac{1}{D_0}\sum_{i=0}^{D_0-1} X_{n,i,d}, \\
156+
(\text{dim}=2):\quad & Y_{n,d,0} = \frac{1}{D_1}\sum_{j=0}^{D_1-1} X_{n,d,j}.
157+
\end{aligned}
154158
:__init__: ``Mean(dim=1)`` — axis to reduce (``1`` → :math:`D_0`,
155159
``2`` → :math:`D_1`).
156160
:__call__: ``y = op(x, ctx=ctx)`` — ``[N, D_0, D_1]`` → ``[N, 1, D_1]``
@@ -168,9 +172,10 @@ class L2Norm(Reduce):
168172
:Math:
169173
.. math::
170174
171-
Y_{n,0,d} = \Big(\sum_{i=0}^{D_0-1} X_{n,i,d}^2\Big)^{1/2}\ \ (\text{dim}=1),
172-
\qquad
173-
Y_{n,d,0} = \Big(\sum_{j=0}^{D_1-1} X_{n,d,j}^2\Big)^{1/2}\ \ (\text{dim}=2).
175+
\begin{aligned}
176+
(\text{dim}=1):\quad & Y_{n,0,d} = \Big(\sum_{i=0}^{D_0-1} X_{n,i,d}^2\Big)^{1/2}, \\
177+
(\text{dim}=2):\quad & Y_{n,d,0} = \Big(\sum_{j=0}^{D_1-1} X_{n,d,j}^2\Big)^{1/2}.
178+
\end{aligned}
174179
:__init__: ``L2Norm(dim=1)`` — axis to reduce (``1`` → :math:`D_0`,
175180
``2`` → :math:`D_1`).
176181
:__call__: ``y = op(x, ctx=ctx)`` — ``[N, D_0, D_1]`` → ``[N, 1, D_1]``
@@ -188,9 +193,10 @@ class Sum(Reduce):
188193
:Math:
189194
.. math::
190195
191-
Y_{n,0,d} = \sum_{i=0}^{D_0-1} X_{n,i,d}\ \ (\text{dim}=1),
192-
\qquad
193-
Y_{n,d,0} = \sum_{j=0}^{D_1-1} X_{n,d,j}\ \ (\text{dim}=2).
196+
\begin{aligned}
197+
(\text{dim}=1):\quad & Y_{n,0,d} = \sum_{i=0}^{D_0-1} X_{n,i,d}, \\
198+
(\text{dim}=2):\quad & Y_{n,d,0} = \sum_{j=0}^{D_1-1} X_{n,d,j}.
199+
\end{aligned}
194200
:__init__: ``Sum(dim=1)`` — axis to reduce (``1`` → :math:`D_0`,
195201
``2`` → :math:`D_1`).
196202
:__call__: ``y = op(x, ctx=ctx)`` — ``[N, D_0, D_1]`` → ``[N, 1, D_1]``

0 commit comments

Comments
 (0)