Skip to content
This repository was archived by the owner on Apr 28, 2023. It is now read-only.

Commit 922ff5b

Browse files
authored
Merge pull request #36 from facebookresearch/regen-docs
Regenerate docs with fixes
2 parents d4dbe7e + 3a2be69 commit 922ff5b

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

docs/source/introduction.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ Let's start with a simple example is a matrix vector product:
2323

2424
.. code::
2525
26-
def mv(float(R,C) A, float(C) x) -> (o) {
27-
o(i) += A(i,j) * x(j)
26+
def mv(float(R,C) A, float(C) B) -> (o) {
27+
o(i) += A(i,j) * B(j)
2828
}
2929
30-
:code:`A` and :code:`x` are input tensors. :code:`o` is an output tensor.
31-
The statement :code:`o(i) += A(i,j)*x(j)` introduces two index variables :code:`i` and :code:`j`.
32-
Their range is inferred by their use indexing :code:`A` and :code:`x`. :code:`i = [0,R)`, :code:`j = [0,C)`.
30+
:code:`A` and :code:`B` are input tensors. :code:`o` is an output tensor.
31+
The statement :code:`o(i) += A(i,j) * B(j)` introduces two index variables :code:`i` and :code:`j`.
32+
Their range is inferred by their use indexing :code:`A` and :code:`B`. :code:`i = [0,R)`, :code:`j = [0,C)`.
3333
Because :code:`j` only appears on the right side,
3434
stores into :code:`o` will reduce over :code:`j` with the reduction specified for the loop.
3535
Reductions can occur across multiple variables, but they all share the same kind of associative reduction (e.g. :code:`+=`)
@@ -40,7 +40,7 @@ to maintain invariant (3). :code:`mv` computes the same thing as this C++ loop:
4040
for(int i = 0; i < R; i++) {
4141
o(i) = 0.0f;
4242
for(int j = 0; j < C; j++) {
43-
o(i) += A(i,j) * x(j);
43+
o(i) += A(i,j) * B(j);
4444
}
4545
}
4646
@@ -56,8 +56,8 @@ Simple matrix-vector
5656

5757
.. code::
5858
59-
def mv(float(R,C) A, float(C) x) -> (o) {
60-
o(i) += A(i,j) * x(j)
59+
def mv(float(R,C) A, float(C) B) -> (o) {
60+
o(i) += A(i,j) * B(j)
6161
}
6262
6363
Simple matrix-multiply

docs/source/semantics.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,21 @@ Each index variable has an associated range :code:`[b,e)` over which it operates
3232
That range is inferred by its use, as described below.
3333
Index variables go out of scope after the statement, allowing the reuse of short variable names like :code:`i`.
3434

35-
Implied Reductions
36-
------------------
35+
Implied Reductions and operators
36+
--------------------------------
3737

3838
If an index variable appears on the right but not on the left of a statement,
3939
it is a reduction index for the statement.
4040
If a statement has one or more reduction variables then it must specify a :code:`reduction`
4141
operator such as :code:`+` or :code:`max`.
4242
There is only one reduction operator for the entire statement because
4343
combinations like :code:`max/+` on different dimensions have different mathematical meanings depending on loop order.
44-
All reduction operators are considered to be associative and commutative to
45-
allow for arbitrary order of evaluation.
46-
Reduction operators may be suffixed with :code:`!` to indicate that the tensor to which values are accumulated should first be initialized with the identity of the reduction operator (e.g., zero for :code:`+`).
47-
Otherwise, values are accumulated directly to the output or temporary tensor passed to the kernel.
44+
All reduction operators are considered to be associative and commutative to allow for arbitrary order of evaluation.
45+
46+
Reduction operators may be suffixed with :code:`!` (for example :code:`+=!`) to indicate that the
47+
tensor to which values are accumulated should first be initialized with the identity of the reduction
48+
operator (e.g., :code:`0` for :code:`+`). Otherwise, values are accumulated directly to the output or
49+
temporary tensor passed to the kernel.
4850

4951
Size Expressions
5052
----------------

0 commit comments

Comments
 (0)