Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<reportFormat>plain</reportFormat>
<skipTests>${maven.test.skip}</skipTests>
<parallel>${test-parallel}</parallel>
<threadCount>${test-threadCount}</threadCount>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/org/apache/sysds/common/Builtins.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ public enum Builtins {
DECISIONTREEPREDICT("decisionTreePredict", true),
DECOMPRESS("decompress", false),
DEDUP("dedup", true),
DP_LAPLACE("dp_laplace", false),
DP_GAUSSIAN("dp_gaussian", false),
DEEPWALK("deepWalk", true),
DET("det", false),
DETECTSCHEMA("detectSchema", false),
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/apache/sysds/common/InstructionType.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public enum InstructionType {
MMChain,
Union,
EINSUM,
DPBuiltin,

//SP Types
MAPMM,
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/org/apache/sysds/common/Opcodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ public enum Opcodes {
LIST("list", InstructionType.BuiltinNary),
EINSUM("einsum", InstructionType.BuiltinNary),

//DP built-in functions
DP_LAPLACE("dp_laplace", InstructionType.DPBuiltin),
DP_GAUSSIAN("dp_gaussian", InstructionType.DPBuiltin),

//Parametrized builtin functions
AUTODIFF("autoDiff", InstructionType.ParameterizedBuiltin),
CONTAINS("contains", InstructionType.ParameterizedBuiltin),
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/org/apache/sysds/common/Types.java
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,8 @@ public static ReOrgOp valueOfByOpcode(String opcode) {

/** Parameterized operations that require named variable arguments */
public enum ParamBuiltinOp {
AUTODIFF, CDF, CONTAINS, INVALID, INVCDF, GROUPEDAGG, RMEMPTY, REPLACE, REXPAND,
AUTODIFF, CDF, CONTAINS, DP_LAPLACE, DP_GAUSSIAN, INVALID, INVCDF,
GROUPEDAGG, RMEMPTY, REPLACE, REXPAND,
LOWER_TRI, UPPER_TRI,
TRANSFORMAPPLY, TRANSFORMDECODE, TRANSFORMCOLMAP, TRANSFORMMETA,
TOKENIZE, TOSTRING, LIST, PARAMSERV
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/org/apache/sysds/hops/ParameterizedBuiltinOp.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public Lop constructLops()
}
case CONTAINS:
case CDF:
case INVCDF:
case INVCDF:
case REPLACE:
case LOWER_TRI:
case UPPER_TRI:
Expand All @@ -194,7 +194,9 @@ public Lop constructLops()
case TOSTRING:
case PARAMSERV:
case LIST:
case AUTODIFF:{
case AUTODIFF:
case DP_LAPLACE:
case DP_GAUSSIAN:{
ParameterizedBuiltin pbilop = new ParameterizedBuiltin(
inputlops, _op, getDataType(), getValueType(), et);
if( isMultiThreadedOpType() )
Expand Down Expand Up @@ -688,7 +690,11 @@ else if( _op == ParamBuiltinOp.TRANSFORMAPPLY ) {
return new MatrixCharacteristics(dc.getRows(), dc.getCols(), -1, dc.getLength());
}
}

else if( _op == ParamBuiltinOp.DP_LAPLACE || _op == ParamBuiltinOp.DP_GAUSSIAN ) {
if( dc.dimsKnown() )
ret = new MatrixCharacteristics(dc.getRows(), dc.getCols(), -1, dc.getLength());
}

return ret;
}
@Override
Expand Down Expand Up @@ -758,7 +764,8 @@ && getTargetHop().areDimsBelowThreshold() ) {
if (_op == ParamBuiltinOp.TRANSFORMCOLMAP || _op == ParamBuiltinOp.TRANSFORMMETA
|| _op == ParamBuiltinOp.TOSTRING || _op == ParamBuiltinOp.LIST
|| _op == ParamBuiltinOp.CDF || _op == ParamBuiltinOp.INVCDF
|| _op == ParamBuiltinOp.PARAMSERV) {
|| _op == ParamBuiltinOp.PARAMSERV
|| _op == ParamBuiltinOp.DP_LAPLACE || _op == ParamBuiltinOp.DP_GAUSSIAN) {
_etype = ExecType.CP;
}

Expand Down
14 changes: 13 additions & 1 deletion src/main/java/org/apache/sysds/lops/ParameterizedBuiltin.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,19 @@ public String getInstructions(String output)
compileGenericParamMap(sb, _inputParams);
break;
}

case DP_LAPLACE: {
sb.append(Opcodes.DP_LAPLACE);
sb.append(OPERAND_DELIMITOR);
compileGenericParamMap(sb, _inputParams);
break;
}
case DP_GAUSSIAN: {
sb.append(Opcodes.DP_GAUSSIAN);
sb.append(OPERAND_DELIMITOR);
compileGenericParamMap(sb, _inputParams);
break;
}

default:
throw new LopsException(this.printErrorLocation() + "In ParameterizedBuiltin Lop, Unknown operation: " + _operation);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2005,6 +2005,31 @@ else if(this.getOpCode() == Builtins.MAX_POOL || this.getOpCode() == Builtins.AV
}
else
raiseValidateError("Local instruction not allowed in dml script");
case DP_LAPLACE: {
checkNumParameters(3);
checkMatrixParam(getFirstExpr());
checkScalarParam(getSecondExpr());
checkScalarParam(getThirdExpr());
output.setDataType(DataType.MATRIX);
output.setValueType(ValueType.FP64);
output.setDimensions(
getFirstExpr().getOutput().getDim1(),
getFirstExpr().getOutput().getDim2());
break;
}
case DP_GAUSSIAN: {
checkNumParameters(4);
checkMatrixParam(getFirstExpr());
checkScalarParam(getSecondExpr());
checkScalarParam(getThirdExpr());
checkScalarParam(getFourthExpr());
output.setDataType(DataType.MATRIX);
output.setValueType(ValueType.FP64);
output.setDimensions(
getFirstExpr().getOutput().getDim1(),
getFirstExpr().getOutput().getDim2());
break;
}
case COMPRESS:
case DECOMPRESS:
if(OptimizerUtils.ALLOW_SCRIPT_LEVEL_COMPRESS_COMMAND){
Expand Down
23 changes: 23 additions & 0 deletions src/main/java/org/apache/sysds/parser/DMLTranslator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2310,6 +2310,10 @@ private Hop processBuiltinFunctionExpression(BuiltinFunctionExpression source, D
if (source.getThirdExpr() != null) {
expr3 = processExpression(source.getThirdExpr(), null, hops);
}
Hop expr4 = null;
if (source.getFourthExpr() != null) {
expr4 = processExpression(source.getFourthExpr(), null, hops);
}

Hop currBuiltinOp = null;
target = (target == null) ? createTarget(source) : target;
Expand Down Expand Up @@ -2589,6 +2593,25 @@ else if ( sop.equalsIgnoreCase(Opcodes.NOTEQUAL.toString()) )
case DECOMPRESS:
currBuiltinOp = new UnaryOp(target.getName(), target.getDataType(), ValueType.FP64, OpOp1.DECOMPRESS, expr);
break;
case DP_LAPLACE: {
LinkedHashMap<String, Hop> dpLaplaceParams = new LinkedHashMap<>();
dpLaplaceParams.put("target", expr);
dpLaplaceParams.put("sensitivity", expr2);
dpLaplaceParams.put("epsilon", expr3);
currBuiltinOp = new ParameterizedBuiltinOp(target.getName(), DataType.MATRIX,
ValueType.FP64, ParamBuiltinOp.DP_LAPLACE, dpLaplaceParams);
break;
}
case DP_GAUSSIAN: {
LinkedHashMap<String, Hop> dpGaussianParams = new LinkedHashMap<>();
dpGaussianParams.put("target", expr);
dpGaussianParams.put("sensitivity", expr2);
dpGaussianParams.put("epsilon", expr3);
dpGaussianParams.put("delta", expr4);
currBuiltinOp = new ParameterizedBuiltinOp(target.getName(), DataType.MATRIX,
ValueType.FP64, ParamBuiltinOp.DP_GAUSSIAN, dpGaussianParams);
break;
}
case QUANTIZE_COMPRESS:
currBuiltinOp = new BinaryOp(target.getName(), target.getDataType(), target.getValueType(), OpOp2.valueOf(source.getOpCode().name()), expr, expr2);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
import org.apache.sysds.runtime.meta.MetaData;
import org.apache.sysds.runtime.meta.MetaDataFormat;
import org.apache.sysds.runtime.util.HDFSTool;
import org.apache.sysds.runtime.privacy.dp.DPBudgetAccountant;
import org.apache.sysds.utils.Statistics;

import java.util.ArrayList;
Expand Down Expand Up @@ -90,6 +91,8 @@ public class ExecutionContext {

protected SEALClient _seal_client;

private DPBudgetAccountant _dpBudgetAccountant = null;

//parfor temporary functions (created by eval)
protected Set<String> _fnNames;

Expand Down Expand Up @@ -144,6 +147,12 @@ public void setLineage(Lineage lineage) {
_lineage = lineage;
}

public DPBudgetAccountant getDPBudgetAccountant() {
if (_dpBudgetAccountant == null)
_dpBudgetAccountant = new DPBudgetAccountant(1.0, 1e-5);
return _dpBudgetAccountant;
}

public boolean isAutoCreateVars() {
return _autoCreateVars;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import org.apache.sysds.runtime.instructions.cp.UnaryCPInstruction;
import org.apache.sysds.runtime.instructions.cp.VariableCPInstruction;
import org.apache.sysds.runtime.instructions.cp.UnionCPInstruction;
import org.apache.sysds.runtime.instructions.cp.DPBuiltinCPInstruction;
import org.apache.sysds.runtime.instructions.cp.EinsumCPInstruction;
import org.apache.sysds.runtime.instructions.cpfile.MatrixIndexingCPFileInstruction;

Expand Down Expand Up @@ -226,7 +227,10 @@ public static CPInstruction parseSingleInstruction ( InstructionType cptype, Str

case EINSUM:
return EinsumCPInstruction.parseInstruction(str);


case DPBuiltin:
return DPBuiltinCPInstruction.parseInstruction(str);

default:
throw new DMLRuntimeException("Invalid CP Instruction Type: " + cptype );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ public enum CPType {
EvictLineageCache, EINSUM,
NoOp,
Union,
QuantizeCompression
QuantizeCompression,
DPBuiltin
}

protected final CPType _cptype;
Expand Down
Loading