org.apache.sysml.lops.ParameterizedBuiltin Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of systemml Show documentation
Show all versions of systemml Show documentation
Declarative Machine Learning
/*
* 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.sysml.lops;
import java.util.HashMap;
import java.util.Map.Entry;
import org.apache.sysml.hops.HopsException;
import org.apache.sysml.lops.LopProperties.ExecLocation;
import org.apache.sysml.lops.LopProperties.ExecType;
import org.apache.sysml.lops.compile.JobType;
import org.apache.sysml.parser.Expression.DataType;
import org.apache.sysml.parser.Expression.ValueType;
import org.apache.sysml.parser.ParameterizedBuiltinFunctionExpression;
/**
* Defines a LOP for functions.
*
*/
public class ParameterizedBuiltin extends Lop
{
public enum OperationTypes {
CDF, INVCDF, RMEMPTY, REPLACE, REXPAND,
TRANSFORM, TRANSFORMAPPLY, TRANSFORMDECODE, TRANSFORMMETA,
TOSTRING
};
private OperationTypes _operation;
private HashMap _inputParams;
private boolean _bRmEmptyBC;
public ParameterizedBuiltin(HashMap paramLops, OperationTypes op, DataType dt, ValueType vt, ExecType et)
throws HopsException
{
super(Lop.Type.ParameterizedBuiltin, dt, vt);
_operation = op;
for (Lop lop : paramLops.values()) {
this.addInput(lop);
lop.addOutput(this);
}
_inputParams = paramLops;
boolean breaksAlignment = false;
boolean aligner = false;
boolean definesMRJob = false;
ExecLocation eloc = null;
if( _operation == OperationTypes.REPLACE && et==ExecType.MR )
{
eloc = ExecLocation.MapOrReduce;
lps.addCompatibility(JobType.GMR);
lps.addCompatibility(JobType.DATAGEN);
lps.addCompatibility(JobType.REBLOCK);
}
else if( _operation == OperationTypes.RMEMPTY && et==ExecType.MR )
{
eloc = ExecLocation.Reduce;
lps.addCompatibility(JobType.GMR);
lps.addCompatibility(JobType.DATAGEN);
lps.addCompatibility(JobType.REBLOCK);
breaksAlignment=true;
}
else if( _operation == OperationTypes.REXPAND && et==ExecType.MR )
{
eloc = ExecLocation.MapOrReduce;
lps.addCompatibility(JobType.GMR);
lps.addCompatibility(JobType.DATAGEN);
lps.addCompatibility(JobType.REBLOCK);
breaksAlignment=true;
}
else if ( _operation == OperationTypes.TRANSFORM && et == ExecType.MR ) {
definesMRJob = true;
eloc = ExecLocation.MapAndReduce;
lps.addCompatibility(JobType.TRANSFORM);
}
else //executed in CP / CP_FILE / SPARK
{
eloc = ExecLocation.ControlProgram;
lps.addCompatibility(JobType.INVALID);
}
lps.setProperties(inputs, et, eloc, breaksAlignment, aligner, definesMRJob);
}
public ParameterizedBuiltin(HashMap paramLops, OperationTypes op, DataType dt, ValueType vt, ExecType et, boolean bRmEmptyBC)
throws HopsException
{
this(paramLops, op, dt, vt, et);
_bRmEmptyBC = bRmEmptyBC;
}
public OperationTypes getOp() {
return _operation;
}
public int getInputIndex(String name) {
Lop n = _inputParams.get(name);
for(int i=0; i-->