Skip to content

Commit 8d06d36

Browse files
committed
improve some index notation doc strings
1 parent f5698fc commit 8d06d36

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/indexnotation/contractiontrees.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22
processcontractions(ex, treebuilder, treesorter, costcheck)
33
44
Process the contractions in `ex` using the given `treebuilder` and `treesorter` functions.
5-
This is done by first extracting a network representation from the expression, then
6-
building and sorting the contraction trees with a given `treebuilder` and `treesorter`
7-
function, and finally inserting the contraction trees back into the expression. When the
8-
`costcheck` function is provided, the cost of each contraction is computed and comp
5+
This is done by first extracting a network representation from the expression, then building
6+
and sorting the contraction trees with a given `treebuilder` and `treesorter` function, and
7+
finally inserting the contraction trees back into the expression. When the `costcheck`
8+
argument equals `:warn` or `:cache` (as opposed to `:nothing`), the optimal contraction
9+
order is computed at runtime using the actual values of [`tensorcost`](@ref) and this
10+
optimal order is compared to the contraction order that was determined at compile time. If
11+
the compile time order deviated from the optimal order, a warning will be printed (in case
12+
of `costcheck == :warn`) or this particular contraction will be recorded in
13+
`TensorOperations.costcache` (in case of `costcheck == :cache`). Both the warning or the
14+
recorded cache entry contain a `order` suggestion that can be passed to the `@tensor` macro
15+
in order to encode the optimal contraction order at compile time..
916
"""
1017
function processcontractions(ex, treebuilder, treesorter, costcheck)
1118
if isexpr(ex, :block)

src/indexnotation/parser.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ end
4343
verifytensorexpr(ex)
4444
4545
Check that `ex` is a valid tensor expression and throw an `ArgumentError` if not.
46-
Valid tensor expressions are characterized by one of the following properties:
46+
Valid tensor expressions satisfy one of the following (recursive) rules):
4747
- The expression is a scalar expression or a tensor expression.
4848
- The expression is an assignment or a definition, and the left hand side and right hand side are valid tensor expressions or scalars.
4949
- The expression is a block, and all subexpressions are valid tensor expressions or scalars.
50+
51+
See also [`istensorexpr`](@ref) and [`isscalarexpr`](@ref).
5052
"""
5153
function verifytensorexpr(ex)
5254
if isexpr(ex, :block)
@@ -73,7 +75,8 @@ end
7375
"""
7476
tensorify(ex)
7577
76-
Parse `ex` into a series of tensor operations' building blocks.
78+
Main parsing step to transform a tensor expression `ex` into a series of function calls associated
79+
with the primitive building blocks (tensor operations and allocations).
7780
"""
7881
function tensorify(ex::Expr)
7982
if isexpr(ex, :macrocall) && ex.args[1] == Symbol("@notensor")

src/indexnotation/postprocessors.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
22
_flatten(ex)
33
4-
Flatten nested structure of an expression, returning a flat line of expressions.
4+
Flatten nested structure of an expression, returning an unnested `Expr(:block, …)`.
55
"""
66
function _flatten(ex)
77
if isa(ex, Expr) # prewalk

0 commit comments

Comments
 (0)