use of org.apache.sysml.hops.Hop.ReOrgOp in project systemml by apache.
the class RewriteAlgebraicSimplificationStatic method removeUnnecessaryReorgOperation.
/**
* Pattners: t(t(X)) -> X, rev(rev(X)) -> X
*
* @param parent parent high-level operator
* @param hi high-level operator
* @param pos position
* @return high-level operator
*/
private static Hop removeUnnecessaryReorgOperation(Hop parent, Hop hi, int pos) {
ReOrgOp[] lookup = new ReOrgOp[] { ReOrgOp.TRANSPOSE, ReOrgOp.REV };
if (// first reorg
hi instanceof ReorgOp && HopRewriteUtils.isValidOp(((ReorgOp) hi).getOp(), lookup)) {
ReOrgOp firstOp = ((ReorgOp) hi).getOp();
Hop hi2 = hi.getInput().get(0);
if (// second reorg w/ same type
hi2 instanceof ReorgOp && ((ReorgOp) hi2).getOp() == firstOp) {
Hop hi3 = hi2.getInput().get(0);
// remove unnecessary chain of t(t())
HopRewriteUtils.replaceChildReference(parent, hi, hi3, pos);
HopRewriteUtils.cleanupUnreferenced(hi, hi2);
hi = hi3;
LOG.debug("Applied removeUnecessaryReorgOperation.");
}
}
return hi;
}
use of org.apache.sysml.hops.Hop.ReOrgOp in project incubator-systemml by apache.
the class RewriteAlgebraicSimplificationStatic method removeUnnecessaryReorgOperation.
/**
* Pattners: t(t(X)) -> X, rev(rev(X)) -> X
*
* @param parent parent high-level operator
* @param hi high-level operator
* @param pos position
* @return high-level operator
*/
private static Hop removeUnnecessaryReorgOperation(Hop parent, Hop hi, int pos) {
ReOrgOp[] lookup = new ReOrgOp[] { ReOrgOp.TRANSPOSE, ReOrgOp.REV };
if (// first reorg
hi instanceof ReorgOp && HopRewriteUtils.isValidOp(((ReorgOp) hi).getOp(), lookup)) {
ReOrgOp firstOp = ((ReorgOp) hi).getOp();
Hop hi2 = hi.getInput().get(0);
if (// second reorg w/ same type
hi2 instanceof ReorgOp && ((ReorgOp) hi2).getOp() == firstOp) {
Hop hi3 = hi2.getInput().get(0);
// remove unnecessary chain of t(t())
HopRewriteUtils.replaceChildReference(parent, hi, hi3, pos);
HopRewriteUtils.cleanupUnreferenced(hi, hi2);
hi = hi3;
LOG.debug("Applied removeUnecessaryReorgOperation.");
}
}
return hi;
}