Package org.apache.sysds.hops.rewrite
Class RewriteElementwiseMultChainOptimization
java.lang.Object
org.apache.sysds.hops.rewrite.HopRewriteRule
org.apache.sysds.hops.rewrite.RewriteElementwiseMultChainOptimization
Prerequisite: RewriteCommonSubexpressionElimination must run before this rule.
Rewrite a chain of element-wise multiply hops that contain identical elements.
For example `(B * A) * B` is rewritten to `A * (B^2)` (or `(B^2) * A`), where `^` is element-wise power.
The order of the multiplicands depends on their data types, dimensions (matrix or vector), and sparsity.
Does not rewrite in the presence of foreign parents in the middle of the e-wise multiply chain,
since foreign parents may rely on the individual results.
Does not perform rewrites on an element-wise multiply if its dimensions are unknown.
The new order of element-wise multiply chains is as follows:
(((unknown * object * frame) * ([least-nnz-matrix * matrix] * most-nnz-matrix))
* ([least-nnz-row-vector * row-vector] * most-nnz-row-vector))
* ([[scalars * least-nnz-col-vector] * col-vector] * most-nnz-col-vector)
Identical elements are replaced with powers.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionrewriteHopDAG(Hop root, ProgramRewriteStatus state) Handle a predicate hop DAG with exactly one root.rewriteHopDAGs(ArrayList<Hop> roots, ProgramRewriteStatus state) Handle a generic (last-level) hop DAG with multiple roots.
-
Constructor Details
-
RewriteElementwiseMultChainOptimization
public RewriteElementwiseMultChainOptimization()
-
-
Method Details
-
rewriteHopDAGs
Description copied from class:HopRewriteRuleHandle a generic (last-level) hop DAG with multiple roots.- Specified by:
rewriteHopDAGsin classHopRewriteRule- Parameters:
roots- high-level operator rootsstate- program rewrite status- Returns:
- list of high-level operators
-
rewriteHopDAG
Description copied from class:HopRewriteRuleHandle a predicate hop DAG with exactly one root.- Specified by:
rewriteHopDAGin classHopRewriteRule- Parameters:
root- high-level operator rootstate- program rewrite status- Returns:
- high-level operator
-