Repository: systemml Updated Branches: refs/heads/master 6f2c885e8 -> e2875cae4
[SYSTEMML-2309] Fix length over lists w/ unknown dims initial compile This patch fixes the runtime instruction for length operations over lists with unknown size during initial compilation. Initially known sizes lead to constant propagation and replacement which has hidden the existing issue of the runtime instruction. Project: http://git-wip-us.apache.org/repos/asf/systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/4e458688 Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/4e458688 Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/4e458688 Branch: refs/heads/master Commit: 4e4586881a8086b40f99c184d8875931e8836a76 Parents: 6f2c885 Author: Matthias Boehm <mboe...@gmail.com> Authored: Thu May 10 13:47:06 2018 -0700 Committer: Matthias Boehm <mboe...@gmail.com> Committed: Thu May 10 13:47:06 2018 -0700 ---------------------------------------------------------------------- .../cp/AggregateUnaryCPInstruction.java | 60 +++++++++++--------- 1 file changed, 33 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/4e458688/src/main/java/org/apache/sysml/runtime/instructions/cp/AggregateUnaryCPInstruction.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/instructions/cp/AggregateUnaryCPInstruction.java b/src/main/java/org/apache/sysml/runtime/instructions/cp/AggregateUnaryCPInstruction.java index c9d9dc7..ed95f7d 100644 --- a/src/main/java/org/apache/sysml/runtime/instructions/cp/AggregateUnaryCPInstruction.java +++ b/src/main/java/org/apache/sysml/runtime/instructions/cp/AggregateUnaryCPInstruction.java @@ -87,34 +87,40 @@ public class AggregateUnaryCPInstruction extends UnaryCPInstruction throw new DMLRuntimeException("Variable '"+input1.getName()+"' does not exist."); //get meta data information - MatrixCharacteristics mc = ec.getMatrixCharacteristics(input1.getName()); - long rval = getSizeMetaData(_type, mc); - - //check for valid output, and acquire read if necessary - //(Use case: In case of forced exec type singlenode, there are no reblocks. For csv - //we however, support unspecified input sizes, which requires a read to obtain the - //required meta data) - //Note: check on matrix characteristics to cover incorrect length (-1*-1 -> 1) - if( !mc.dimsKnown() ) //invalid nrow/ncol/length - { - if( DMLScript.rtplatform == RUNTIME_PLATFORM.SINGLE_NODE - || (input1.getDataType() == DataType.FRAME && OptimizerUtils.isHadoopExecutionMode()) ) + long rval = -1; + if (input1.getDataType() == DataType.LIST && _type == AUType.LENGTH ) { + rval = ((ListObject)ec.getVariable(input1.getName())).getLength(); + } + else if( input1.getDataType().isMatrix() || input1.getDataType().isFrame() ) { + MatrixCharacteristics mc = ec.getMatrixCharacteristics(input1.getName()); + rval = getSizeMetaData(_type, mc); + + //check for valid output, and acquire read if necessary + //(Use case: In case of forced exec type singlenode, there are no reblocks. For csv + //we however, support unspecified input sizes, which requires a read to obtain the + //required meta data) + //Note: check on matrix characteristics to cover incorrect length (-1*-1 -> 1) + if( !mc.dimsKnown() ) //invalid nrow/ncol/length { - if( OptimizerUtils.isHadoopExecutionMode() ) - LOG.warn("Reading csv input frame of unkown size into memory for '"+opcode+"'."); - - //read the input matrix/frame and explicitly refresh meta data - CacheableData<?> obj = ec.getCacheableData(input1.getName()); - obj.acquireRead(); - obj.refreshMetaData(); - obj.release(); - - //update meta data information - mc = ec.getMatrixCharacteristics(input1.getName()); - rval = getSizeMetaData(_type, mc); - } - else { - throw new DMLRuntimeException("Invalid meta data returned by '"+opcode+"': "+rval + ":" + instString); + if( DMLScript.rtplatform == RUNTIME_PLATFORM.SINGLE_NODE + || (input1.getDataType() == DataType.FRAME && OptimizerUtils.isHadoopExecutionMode()) ) + { + if( OptimizerUtils.isHadoopExecutionMode() ) + LOG.warn("Reading csv input frame of unkown size into memory for '"+opcode+"'."); + + //read the input matrix/frame and explicitly refresh meta data + CacheableData<?> obj = ec.getCacheableData(input1.getName()); + obj.acquireRead(); + obj.refreshMetaData(); + obj.release(); + + //update meta data information + mc = ec.getMatrixCharacteristics(input1.getName()); + rval = getSizeMetaData(_type, mc); + } + else { + throw new DMLRuntimeException("Invalid meta data returned by '"+opcode+"': "+rval + ":" + instString); + } } }