Resource counting

As explained before, EinExprs are symbolic expressions representing Einstein summation equations (i.e. tensor summation, permutation, contraction, ...) so no tensor operation is actually performed on them. Many times, information about the execution cost is needed to optimize the contraction path. In general, this is a hard task but thanks to Einsteam summation notation only representing linear algebra operations, and these operations are easy to estimate, we can count the resource requirements of any contraction path.

Currently there are 3 resource counters:

EinExprs.flopsFunction
flops(path::EinExpr)

Count the number of mathematical operations will be performed by the contraction of the root of the path tree.

EinExprs.removedsizeFunction
removedsize(path::EinExpr)

Count the amount of memory that will be freed after performing the contraction of the root of the path tree.

EinExprs.removedrankFunction
removedrank(path::EinExpr)

Count the rank reduction after performing the contraction of the root of the path tree.

Tip

These methods only count the resources spent of the contraction on the root of the tree. In order to count the resources of the whole tree, use mapreduce with Branches:

mapreduce(flops, +, Branches(path))