org.apache.sysds.hops.rewrite

## Class ProgramRewriter

- java.lang.Object
- - org.apache.sysds.hops.rewrite.ProgramRewriter

    public class ProgramRewriter
    extends Object

This program rewriter applies a variety of rule-based rewrites on all hop dags of the given program in one pass over the entire program.

### Constructor Summary

Constructors
Constructor and Description
`ProgramRewriter()`
`ProgramRewriter(ArrayList<HopRewriteRule> hRewrites, ArrayList<StatementBlockRewriteRule> sbRewrites)` Construct a program rewriter for the given rewrite sets which are passed from outside.
`ProgramRewriter(boolean staticRewrites, boolean dynamicRewrites)`
`ProgramRewriter(HopRewriteRule... rewrites)` Construct a program rewriter for a given rewrite which is passed from outside.
`ProgramRewriter(StatementBlockRewriteRule... rewrites)` Construct a program rewriter for a given rewrite which is passed from outside.

### Method Summary

All Methods Instance Methods Concrete Methods
`void` `removeHopRewrite(Class<? extends HopRewriteRule> clazz)`
`void` `removeStatementBlockRewrite(Class<? extends StatementBlockRewriteRule> clazz)`
`ArrayList<Hop>` `rewriteHopDAG(ArrayList<Hop> roots, ProgramRewriteStatus state)`
`Hop` `rewriteHopDAG(Hop root, ProgramRewriteStatus state)`
`void` `rewriteHopDAGsFunction(FunctionStatementBlock fsb, boolean splitDags)`
`void` `rewriteHopDAGsFunction(FunctionStatementBlock fsb, ProgramRewriteStatus state, boolean splitDags)`
`ProgramRewriteStatus` `rewriteProgramHopDAGs(DMLProgram dmlp)`
`ProgramRewriteStatus` `rewriteProgramHopDAGs(DMLProgram dmlp, boolean splitDags)`
`ProgramRewriteStatus` `rewriteProgramHopDAGs(DMLProgram dmlp, boolean splitDags, ProgramRewriteStatus state)`
`ArrayList<StatementBlock>` `rRewriteStatementBlock(StatementBlock sb, ProgramRewriteStatus status, boolean splitDags)`
`void` `rRewriteStatementBlockHopDAGs(StatementBlock current, ProgramRewriteStatus state)`
`ArrayList<StatementBlock>` `rRewriteStatementBlocks(ArrayList<StatementBlock> sbs, ProgramRewriteStatus status, boolean splitDags)`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### ProgramRewriter

    public ProgramRewriter()

#### ProgramRewriter

    public ProgramRewriter(boolean staticRewrites,
                           boolean dynamicRewrites)

#### ProgramRewriter

    public ProgramRewriter(HopRewriteRule... rewrites)

Construct a program rewriter for a given rewrite which is passed from outside.

Parameters:
  `rewrites` - the HOP rewrite rules

#### ProgramRewriter

    public ProgramRewriter(StatementBlockRewriteRule... rewrites)

Construct a program rewriter for a given rewrite which is passed from outside.

Parameters:
  `rewrites` - the statement block rewrite rules

#### ProgramRewriter

    public ProgramRewriter(ArrayList<HopRewriteRule> hRewrites,
                           ArrayList<StatementBlockRewriteRule> sbRewrites)

Construct a program rewriter for the given rewrite sets which are passed from outside.

Parameters:
  `hRewrites` - HOP rewrite rules
  `sbRewrites` - statement block rewrite rules

### Method Detail

#### removeHopRewrite

    public void removeHopRewrite(Class<? extends HopRewriteRule> clazz)

#### removeStatementBlockRewrite

    public void removeStatementBlockRewrite(Class<? extends StatementBlockRewriteRule> clazz)

#### rewriteProgramHopDAGs

    public ProgramRewriteStatus rewriteProgramHopDAGs(DMLProgram dmlp)

#### rewriteProgramHopDAGs

    public ProgramRewriteStatus rewriteProgramHopDAGs(DMLProgram dmlp,
                                                      boolean splitDags)

#### rewriteProgramHopDAGs

    public ProgramRewriteStatus rewriteProgramHopDAGs(DMLProgram dmlp,
                                                      boolean splitDags,
                                                      ProgramRewriteStatus state)

#### rewriteHopDAGsFunction

    public void rewriteHopDAGsFunction(FunctionStatementBlock fsb,
                                       boolean splitDags)

#### rewriteHopDAGsFunction

    public void rewriteHopDAGsFunction(FunctionStatementBlock fsb,
                                       ProgramRewriteStatus state,
                                       boolean splitDags)

#### rRewriteStatementBlockHopDAGs

    public void rRewriteStatementBlockHopDAGs(StatementBlock current,
                                              ProgramRewriteStatus state)

#### rewriteHopDAG

    public ArrayList<Hop> rewriteHopDAG(ArrayList<Hop> roots,
                                        ProgramRewriteStatus state)

#### rewriteHopDAG

    public Hop rewriteHopDAG(Hop root,
                             ProgramRewriteStatus state)

#### rRewriteStatementBlocks

    public ArrayList<StatementBlock> rRewriteStatementBlocks(ArrayList<StatementBlock> sbs,
                                                             ProgramRewriteStatus status,
                                                             boolean splitDags)

#### rRewriteStatementBlock

    public ArrayList<StatementBlock> rRewriteStatementBlock(StatementBlock sb,
                                                            ProgramRewriteStatus status,
                                                            boolean splitDags)