use of org.apache.sysml.hops.rewrite.ProgramRewriter in project incubator-systemml by apache.
the class DMLTranslator method rewriteHopsDAG.
public void rewriteHopsDAG(DMLProgram dmlp) throws ParseException, LanguageException, HopsException {
//apply hop rewrites (static rewrites)
ProgramRewriter rewriter = new ProgramRewriter(true, false);
rewriter.rewriteProgramHopDAGs(dmlp);
resetHopsDAGVisitStatus(dmlp);
//propagate size information from main into functions (but conservatively)
if (OptimizerUtils.ALLOW_INTER_PROCEDURAL_ANALYSIS) {
InterProceduralAnalysis ipa = new InterProceduralAnalysis();
ipa.analyzeProgram(dmlp);
resetHopsDAGVisitStatus(dmlp);
if (OptimizerUtils.ALLOW_IPA_SECOND_CHANCE) {
// SECOND CHANCE:
// Rerun static rewrites + IPA to allow for further improvements, such as making use
// of constant folding (static rewrite) after scalar -> literal replacement (IPA),
// and then further scalar -> literal replacement (IPA).
rewriter.rewriteProgramHopDAGs(dmlp);
resetHopsDAGVisitStatus(dmlp);
ipa.analyzeProgram(dmlp);
resetHopsDAGVisitStatus(dmlp);
}
}
//apply hop rewrites (dynamic rewrites, after IPA)
ProgramRewriter rewriter2 = new ProgramRewriter(false, true);
rewriter2.rewriteProgramHopDAGs(dmlp);
resetHopsDAGVisitStatus(dmlp);
// Compute memory estimates for all the hops. These estimates are used
// subsequently in various optimizations, e.g. CP vs. MR scheduling and parfor.
refreshMemEstimates(dmlp);
resetHopsDAGVisitStatus(dmlp);
}
Aggregations