Repository: incubator-systemml Updated Branches: refs/heads/master b4dd2c1bf -> 28c92b93f
[SYSTEMML-1638] Fix codegen of double scalars in indexing expressions Our indexing runtime uses safe casts (accordingly to machine precision) to handling double scalars in indexing expressions. This patch fixes the code generation runtime to similarly provide indexing abstractions for for double scalars in such indexing expressions. Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/fd393e46 Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/fd393e46 Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/fd393e46 Branch: refs/heads/master Commit: fd393e460cedeb04be4cee3b57ecc1e14dc99884 Parents: b4dd2c1 Author: Matthias Boehm <[email protected]> Authored: Sun May 28 15:34:19 2017 -0700 Committer: Matthias Boehm <[email protected]> Committed: Sun May 28 15:34:19 2017 -0700 ---------------------------------------------------------------------- .../sysml/runtime/codegen/SpoofOperator.java | 23 ++++++++++++++++++++ 1 file changed, 23 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/fd393e46/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java ---------------------------------------------------------------------- diff --git a/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java b/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java index 1f3920f..d3bf410 100644 --- a/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java +++ b/src/main/java/org/apache/sysml/runtime/codegen/SpoofOperator.java @@ -29,6 +29,7 @@ import org.apache.sysml.runtime.compress.CompressedMatrixBlock; import org.apache.sysml.runtime.instructions.cp.ScalarObject; import org.apache.sysml.runtime.matrix.data.MatrixBlock; import org.apache.sysml.runtime.util.DataConverter; +import org.apache.sysml.runtime.util.UtilFunctions; public abstract class SpoofOperator implements Serializable { @@ -134,20 +135,42 @@ public abstract class SpoofOperator implements Serializable //abstraction for safely accessing sideways matrices without the need //to allocate empty matrices as dense, see prepInputMatrices + protected static double getValue(double[] data, double index) { + int iindex = UtilFunctions.toInt(index); + return getValue(data, iindex); + } + protected static double getValue(double[] data, int index) { return (data!=null) ? data[index] : 0; } + protected static double getValue(double[] data, int n, double rowIndex, double colIndex) { + int irowIndex = UtilFunctions.toInt(rowIndex); + int icolIndex = UtilFunctions.toInt(colIndex); + return getValue(data, n, irowIndex, icolIndex); + } + protected static double getValue(double[] data, int n, int rowIndex, int colIndex) { return (data!=null) ? data[rowIndex*n+colIndex] : 0; } + protected static double getValue(SideInput data, double rowIndex) { + int irowIndex = UtilFunctions.toInt(rowIndex); + return getValue(data, irowIndex); + } + protected static double getValue(SideInput data, int rowIndex) { //note: wrapper sideinput guaranteed to exist return (data.dBlock!=null) ? data.dBlock[rowIndex] : (data.mBlock!=null) ? data.mBlock.quickGetValue(rowIndex, 0) : 0; } + protected static double getValue(SideInput data, int n, double rowIndex, double colIndex) { + int irowIndex = UtilFunctions.toInt(rowIndex); + int icolIndex = UtilFunctions.toInt(colIndex); + return getValue(data, n, irowIndex, icolIndex); + } + protected static double getValue(SideInput data, int n, int rowIndex, int colIndex) { //note: wrapper sideinput guaranteed to exist return (data.dBlock!=null) ? data.dBlock[rowIndex*n+colIndex] :
