sebwrede commented on a change in pull request #1175:
URL: https://github.com/apache/systemds/pull/1175#discussion_r568066337
##########
File path:
src/main/java/org/apache/sysds/runtime/instructions/fed/QuaternaryWCeMMFEDInstruction.java
##########
@@ -59,17 +60,17 @@ public void processInstruction(ExecutionContext ec)
MatrixObject U = ec.getMatrixObject(input2);
MatrixObject V = ec.getMatrixObject(input3);
ScalarObject eps = null;
-
+
if(qop.hasFourInputs()) {
eps = (_input4.getDataType() == DataType.SCALAR) ?
ec.getScalarInput(_input4) :
new
DoubleObject(ec.getMatrixInput(_input4.getName()).quickGetValue(0, 0));
}
- if(!(X.isFederated() && !U.isFederated() && !V.isFederated()))
+ if(!(X.isFederated(FType.ROW) && !U.isFederated() &&
!V.isFederated()))
Review comment:
Could we convert this to a positive case instead? Something more like:
`if (X.isFederated(FType.ROW) && !U.isFederated() && !V.isFederated()){
//process instruction
}
else {
//throw exception
}`
I think this would be easier to read and leave the method open for new cases
in the future, for instance to support col federation.
This comment also applies to QuaternaryWSLossFEDInstruction and
QuaternaryWSigmoidFEDInstruction.
##########
File path:
src/test/java/org/apache/sysds/test/functions/federated/algorithms/FederatedPNMFTest.java
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sysds.test.functions.federated.algorithms;
+
+import org.apache.sysds.common.Types.ExecMode;
+import org.apache.sysds.runtime.matrix.data.MatrixValue.CellIndex;
+import org.apache.sysds.runtime.meta.MatrixCharacteristics;
+import org.apache.sysds.runtime.util.HDFSTool;
+import org.apache.sysds.test.AutomatedTestBase;
+import org.apache.sysds.test.TestConfiguration;
+import org.apache.sysds.test.TestUtils;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+
+@RunWith(value = Parameterized.class)
[email protected]
+public class FederatedPNMFTest extends AutomatedTestBase
+{
+ private final static String TEST_NAME = "FederatedPNMFTest";
+ private final static String TEST_DIR = "functions/federated/";
+ private final static String TEST_CLASS_DIR = TEST_DIR +
FederatedPNMFTest.class.getSimpleName() + "/";
+
+ private final static String OUTPUT_NAME = "Z";
+ private final static double TOLERANCE = 0.2;
+ private final static int blocksize = 1024;
+
+ @Parameterized.Parameter()
+ public int rows;
+ @Parameterized.Parameter(1)
+ public int cols;
+ @Parameterized.Parameter(2)
+ public int rank;
+ @Parameterized.Parameter(3)
+ public int max_iter;
+ @Parameterized.Parameter(4)
+ public double sparsity;
+
+ @Override
+ public void setUp() {
+ addTestConfiguration(TEST_NAME, new
TestConfiguration(TEST_CLASS_DIR, TEST_NAME, new String[]{OUTPUT_NAME}));
+ }
+
+ @Parameterized.Parameters
+ public static Collection<Object[]> data() {
+ // rows must be even
+ return Arrays.asList(new Object[][] {
+ // {rows, cols, rank, max_iter, sparsity}
+ {1000, 750, 420, 10, 1}
+ });
+ }
+
+ @BeforeClass
+ public static void init() {
+ TestUtils.clearDirectory(TEST_DATA_DIR + TEST_CLASS_DIR);
+ }
+
+ @Test
+ public void federatedPNMFSingleNode() {
+ federatedPNMF(TEST_NAME, ExecMode.SINGLE_NODE);
Review comment:
You don't need to pass TEST_NAME as a parameter.
##########
File path:
src/test/java/org/apache/sysds/test/functions/federated/algorithms/FederatedPNMFTest.java
##########
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.sysds.test.functions.federated.algorithms;
+
+import org.apache.sysds.common.Types.ExecMode;
+import org.apache.sysds.runtime.matrix.data.MatrixValue.CellIndex;
+import org.apache.sysds.runtime.meta.MatrixCharacteristics;
+import org.apache.sysds.runtime.util.HDFSTool;
+import org.apache.sysds.test.AutomatedTestBase;
+import org.apache.sysds.test.TestConfiguration;
+import org.apache.sysds.test.TestUtils;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+
+@RunWith(value = Parameterized.class)
[email protected]
+public class FederatedPNMFTest extends AutomatedTestBase
+{
+ private final static String TEST_NAME = "FederatedPNMFTest";
+ private final static String TEST_DIR = "functions/federated/";
+ private final static String TEST_CLASS_DIR = TEST_DIR +
FederatedPNMFTest.class.getSimpleName() + "/";
+
+ private final static String OUTPUT_NAME = "Z";
+ private final static double TOLERANCE = 0.2;
+ private final static int blocksize = 1024;
+
+ @Parameterized.Parameter()
+ public int rows;
+ @Parameterized.Parameter(1)
+ public int cols;
+ @Parameterized.Parameter(2)
+ public int rank;
+ @Parameterized.Parameter(3)
+ public int max_iter;
+ @Parameterized.Parameter(4)
+ public double sparsity;
Review comment:
Where is the sparsity parameter used?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]