This is an automated email from the ASF dual-hosted git repository.
mboehm7 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/systemds.git
The following commit(s) were added to refs/heads/main by this push:
new 2e1b16ae9b [MINOR] Improved code coverage basic operations, incl
cleanups
2e1b16ae9b is described below
commit 2e1b16ae9b1365e7ebb1e353e1360d15d9e3bf9a
Author: Matthias Boehm <[email protected]>
AuthorDate: Fri Aug 23 11:35:37 2024 +0200
[MINOR] Improved code coverage basic operations, incl cleanups
---
codecov.yml | 2 +
src/main/java/org/apache/sysds/common/Types.java | 45 ++++++++--------------
.../apache/sysds/hops/codegen/cplan/CNodeCell.java | 2 +-
.../sysds/test/component/misc/OpTypeTest.java | 32 +++++++++++++++
4 files changed, 52 insertions(+), 29 deletions(-)
diff --git a/codecov.yml b/codecov.yml
index 548796ea26..e74934e47a 100644
--- a/codecov.yml
+++ b/codecov.yml
@@ -32,3 +32,5 @@ coverage:
changes: no
precision: 2
range: "50...75"
+ ignore:
+ - "src/main/java/org/apache/sysds/protobuf"
diff --git a/src/main/java/org/apache/sysds/common/Types.java
b/src/main/java/org/apache/sysds/common/Types.java
index 26219feb59..4161f0c23d 100644
--- a/src/main/java/org/apache/sysds/common/Types.java
+++ b/src/main/java/org/apache/sysds/common/Types.java
@@ -20,7 +20,6 @@
package org.apache.sysds.common;
import java.util.Arrays;
-import java.util.HashMap;
import org.apache.sysds.runtime.DMLRuntimeException;
@@ -490,15 +489,17 @@ public interface Types {
* The AggOp contain identifying integer values that need to match with
their native counterparts for instance for spoof CUDA ops.
*/
public enum AggOp {
- SUM(0), SUM_SQ(1), MIN(2), MAX(3),
- PROD(4), SUM_PROD(5),
- TRACE(6), MEAN(7), VAR(8),
- MAXINDEX(9), MININDEX(10),
- COUNT_DISTINCT(11), ROW_COUNT_DISTINCT(12),
COL_COUNT_DISTINCT(13),
- COUNT_DISTINCT_APPROX(14),
- COUNT_DISTINCT_APPROX_ROW(15),
- COUNT_DISTINCT_APPROX_COL(16),
- UNIQUE(17);
+ SUM, SUM_SQ, MIN, MAX,
+ PROD, SUM_PROD,
+ TRACE, MEAN, VAR,
+ MAXINDEX, MININDEX,
+ COUNT_DISTINCT,
+ ROW_COUNT_DISTINCT, //TODO should be direction
+ COL_COUNT_DISTINCT,
+ COUNT_DISTINCT_APPROX,
+ COUNT_DISTINCT_APPROX_ROW, //TODO should be direction
+ COUNT_DISTINCT_APPROX_COL,
+ UNIQUE;
@Override
public String toString() {
@@ -510,26 +511,14 @@ public interface Types {
}
}
- private final int value;
- private final static HashMap<Integer, AggOp> map = new
HashMap<>();
-
- AggOp(int value) {
- this.value = value;
- }
-
- static {
- for (AggOp aggOp : AggOp.values()) {
- map.put(aggOp.value, aggOp);
+ public static AggOp valueOfByOpcode(String opcode) {
+ switch(opcode) {
+ case "+": return SUM;
+ case "sq+": return SUM_SQ;
+ case "*": return PROD;
+ default: return
valueOf(opcode.toUpperCase());
}
}
-
- public static AggOp valueOf(int aggOp) {
- return map.get(aggOp);
- }
-
- public int getValue() {
- return value;
- }
}
/** Operations that require 1 operand */
diff --git a/src/main/java/org/apache/sysds/hops/codegen/cplan/CNodeCell.java
b/src/main/java/org/apache/sysds/hops/codegen/cplan/CNodeCell.java
index f803000728..3d2c19ef4c 100644
--- a/src/main/java/org/apache/sysds/hops/codegen/cplan/CNodeCell.java
+++ b/src/main/java/org/apache/sysds/hops/codegen/cplan/CNodeCell.java
@@ -278,7 +278,7 @@ public class CNodeCell extends CNodeTpl
public int compile(GeneratorAPI api, String src) {
if(api == GeneratorAPI.CUDA)
return
compile_nvrtc(SpoofCompiler.native_contexts.get(api), _genVar, src,
_type.getValue(),
- _aggOp != null ? _aggOp.getValue() : 0,
_sparseSafe);
+ _aggOp != null ? _aggOp.ordinal() : 0,
_sparseSafe);
return -1;
}
diff --git a/src/test/java/org/apache/sysds/test/component/misc/OpTypeTest.java
b/src/test/java/org/apache/sysds/test/component/misc/OpTypeTest.java
index 581ff0d405..9ddbd7a302 100644
--- a/src/test/java/org/apache/sysds/test/component/misc/OpTypeTest.java
+++ b/src/test/java/org/apache/sysds/test/component/misc/OpTypeTest.java
@@ -19,6 +19,8 @@
package org.apache.sysds.test.component.misc;
+import org.apache.sysds.common.Types.AggOp;
+import org.apache.sysds.common.Types.FileFormat;
import org.apache.sysds.common.Types.OpOp1;
import org.apache.sysds.common.Types.OpOp2;
import org.apache.sysds.common.Types.OpOp3;
@@ -85,6 +87,16 @@ public class OpTypeTest {
}
}
+ @Test
+ public void testAggOp() {
+ AggOp[] ops = AggOp.values();
+ for(int i=0; i<ops.length; i++) {
+ Assert.assertEquals(i, ops[i].ordinal());
+ Assert.assertEquals(AggOp.valueOf(ops[i].name()),
ops[i]);
+
Assert.assertEquals(AggOp.valueOfByOpcode(ops[i].toString()), ops[i]);
+ }
+ }
+
@Test
public void testReOrgOp() {
ReOrgOp[] ops = ReOrgOp.values();
@@ -128,6 +140,26 @@ public class OpTypeTest {
for(int i=0; i<ops.length; i++) {
Assert.assertEquals(i, ops[i].ordinal());
Assert.assertEquals(OpOpData.valueOf(ops[i].name()),
ops[i]);
+ if( ops[i].isRead() || ops[i].isWrite() )
+ Assert.assertNotEquals(ops[i].isRead(),
ops[i].isWrite());
+ if( ops[i].isTransient() || ops[i].isPersistent() )
+ Assert.assertNotEquals(ops[i].isTransient(),
ops[i].isPersistent());
+ Assert.assertNotEquals(ops[i].name(),
ops[i].toString());
+ }
+ }
+
+ @Test
+ public void testFileFormats() {
+ FileFormat[] fmt = FileFormat.values();
+ for(int i=0; i<fmt.length; i++) {
+ Assert.assertEquals(i, fmt[i].ordinal());
+ Assert.assertEquals(fmt[i].isTextFormat(),
FileFormat.isTextFormat(fmt[i].name()));
+ Assert.assertEquals(fmt[i].isDelimitedFormat(),
FileFormat.isDelimitedFormat(fmt[i].name()));
+ if( fmt[i]==FileFormat.MM || fmt[i]==FileFormat.TEXT )
+ Assert.assertTrue(fmt[i].isIJV());
}
+ Assert.assertFalse(FileFormat.isTextFormat("f1"));
+ Assert.assertFalse(FileFormat.isDelimitedFormat("f2"));
+ try {FileFormat.safeValueOf("f3");
Assert.fail();}catch(Exception ex) {}
}
}