Search in sources :

Example 1 with DataOpTypes

use of org.apache.sysml.hops.Hop.DataOpTypes in project incubator-systemml by apache.

the class RewriteRemovePersistentReadWrite method rule_RemovePersistentDataOp.

private void rule_RemovePersistentDataOp(Hop hop) throws HopsException {
    //check mark processed
    if (hop.isVisited())
        return;
    //recursively process childs
    ArrayList<Hop> inputs = hop.getInput();
    for (int i = 0; i < inputs.size(); i++) rule_RemovePersistentDataOp(inputs.get(i));
    //remove cast if unnecessary
    if (hop instanceof DataOp) {
        DataOp dop = (DataOp) hop;
        DataOpTypes dotype = dop.getDataOpType();
        switch(dotype) {
            case PERSISTENTREAD:
                if (_inputs.contains(dop.getName())) {
                    dop.setDataOpType(DataOpTypes.TRANSIENTREAD);
                    if (hop.getDataType() == DataType.SCALAR) {
                        dop.removeInput("iofilename");
                    }
                    //disable unnecessary reblock of binary block w/ equal block sizes
                    if (dop.requiresReblock() && _inputsMeta.containsKey(dop.getName()) && _inputsMeta.get(dop.getName()) instanceof MatrixFormatMetaData) {
                        MatrixFormatMetaData meta = (MatrixFormatMetaData) _inputsMeta.get(dop.getName());
                        MatrixCharacteristics mc = meta.getMatrixCharacteristics();
                        boolean matchingBlksz = mc.getRowsPerBlock() == dop.getRowsInBlock() && mc.getColsPerBlock() == dop.getColsInBlock();
                        //binary matrix w/ matching dims and frames do not require reblock
                        if (meta.getInputInfo() == InputInfo.BinaryBlockInputInfo && (matchingBlksz || dop.getDataType() == DataType.FRAME)) {
                            dop.setRequiresReblock(false);
                        }
                    }
                } else
                    LOG.warn("Non-registered persistent read of variable '" + dop.getName() + "' (line " + dop.getBeginLine() + ").");
                break;
            case PERSISTENTWRITE:
                if (_outputs.contains(dop.getName())) {
                    dop.setDataOpType(DataOpTypes.TRANSIENTWRITE);
                    dop.setRowsInBlock(dop.getInput().get(0).getRowsInBlock());
                    dop.setColsInBlock(dop.getInput().get(0).getColsInBlock());
                    if (hop.getDataType() == DataType.SCALAR) {
                        dop.removeInput("iofilename");
                    }
                } else
                    LOG.warn("Non-registered persistent write of variable '" + dop.getName() + "' (line " + dop.getBeginLine() + ").");
                break;
            default:
        }
    }
    //mark processed
    hop.setVisited();
}
Also used : DataOpTypes(org.apache.sysml.hops.Hop.DataOpTypes) Hop(org.apache.sysml.hops.Hop) DataOp(org.apache.sysml.hops.DataOp) MatrixFormatMetaData(org.apache.sysml.runtime.matrix.MatrixFormatMetaData) MatrixCharacteristics(org.apache.sysml.runtime.matrix.MatrixCharacteristics)

Aggregations

DataOp (org.apache.sysml.hops.DataOp)1 Hop (org.apache.sysml.hops.Hop)1 DataOpTypes (org.apache.sysml.hops.Hop.DataOpTypes)1 MatrixCharacteristics (org.apache.sysml.runtime.matrix.MatrixCharacteristics)1 MatrixFormatMetaData (org.apache.sysml.runtime.matrix.MatrixFormatMetaData)1