kev-inn commented on a change in pull request #966: URL: https://github.com/apache/systemml/pull/966#discussion_r443470295
########## File path: src/main/java/org/apache/sysds/runtime/instructions/fed/MultiReturnParameterizedBuiltinFEDInstruction.java ########## @@ -0,0 +1,215 @@ +/* + * 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.runtime.instructions.fed; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.Future; + +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; +import org.apache.sysds.common.Types; +import org.apache.sysds.runtime.DMLRuntimeException; +import org.apache.sysds.runtime.controlprogram.caching.FrameObject; +import org.apache.sysds.runtime.controlprogram.caching.MatrixObject; +import org.apache.sysds.runtime.controlprogram.context.ExecutionContext; +import org.apache.sysds.runtime.controlprogram.federated.FederatedData; +import org.apache.sysds.runtime.controlprogram.federated.FederatedRange; +import org.apache.sysds.runtime.controlprogram.federated.FederatedRequest; +import org.apache.sysds.runtime.controlprogram.federated.FederatedResponse; +import org.apache.sysds.runtime.instructions.InstructionUtils; +import org.apache.sysds.runtime.instructions.cp.CPOperand; +import org.apache.sysds.runtime.matrix.data.FrameBlock; +import org.apache.sysds.runtime.matrix.operators.Operator; +import org.apache.sysds.runtime.transform.encode.EncoderRecode; + +public class MultiReturnParameterizedBuiltinFEDInstruction extends ComputationFEDInstruction { + protected final ArrayList<CPOperand> _outputs; + + private MultiReturnParameterizedBuiltinFEDInstruction(Operator op, CPOperand input1, CPOperand input2, + ArrayList<CPOperand> outputs, String opcode, String istr) { + super(FEDType.MultiReturnParameterizedBuiltin, op, input1, input2, outputs.get(0), opcode, istr); + _outputs = outputs; + } + + public CPOperand getOutput(int i) { + return _outputs.get(i); + } + + public static MultiReturnParameterizedBuiltinFEDInstruction parseInstruction(String str) { + String[] parts = InstructionUtils.getInstructionPartsWithValueType(str); + ArrayList<CPOperand> outputs = new ArrayList<>(); + String opcode = parts[0]; + + if(opcode.equalsIgnoreCase("transformencode")) { + // one input and two outputs + CPOperand in1 = new CPOperand(parts[1]); + CPOperand in2 = new CPOperand(parts[2]); + outputs.add(new CPOperand(parts[3], Types.ValueType.FP64, Types.DataType.MATRIX)); + outputs.add(new CPOperand(parts[4], Types.ValueType.STRING, Types.DataType.FRAME)); Review comment: I guess the reason we currently don't have it, is due to us using the enum to figure out which cast we are going to do, which is independent of it's federation status. If we plan on creating new classes for `FederatedMatrice`s, then I do believe a new type makes perfect sense, but even if we don't, and instead keep it in `MatrixObject`, I believe it still would be beneficial to have actual types for them. As you said, the code would get simpler (checks are easier) and we can use it to decide on operations (the current replacement should anyway be removed rather sooner than later). So I agree with your opinion on the matter. ---------------------------------------------------------------- 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: us...@infra.apache.org