Search in sources :

Example 6 with Multiply

use of org.apache.sysml.runtime.functionobjects.Multiply in project incubator-systemml by apache.

the class MatrixBlock method aggregateTernaryOperations.

public MatrixBlock aggregateTernaryOperations(MatrixBlock m1, MatrixBlock m2, MatrixBlock m3, MatrixBlock ret, AggregateTernaryOperator op, boolean inCP) {
    // check input dimensions and operators
    if (m1.rlen != m2.rlen || m1.clen != m2.clen || (m3 != null && (m2.rlen != m3.rlen || m2.clen != m3.clen)))
        throw new DMLRuntimeException("Invalid dimensions for aggregate ternary (" + m1.rlen + "x" + m1.clen + ", " + m2.rlen + "x" + m2.clen + ", " + m3.rlen + "x" + m3.clen + ").");
    if (!(op.aggOp.increOp.fn instanceof KahanPlus && op.binaryFn instanceof Multiply))
        throw new DMLRuntimeException("Unsupported operator for aggregate ternary operations.");
    // create output matrix block w/ corrections
    int rl = (op.indexFn instanceof ReduceRow) ? 2 : 1;
    int cl = (op.indexFn instanceof ReduceRow) ? m1.clen : 2;
    if (ret == null)
        ret = new MatrixBlock(rl, cl, false);
    else
        ret.reset(rl, cl, false);
    // execute ternary aggregate function
    if (op.getNumThreads() > 1)
        ret = LibMatrixAgg.aggregateTernary(m1, m2, m3, ret, op, op.getNumThreads());
    else
        ret = LibMatrixAgg.aggregateTernary(m1, m2, m3, ret, op);
    if (op.aggOp.correctionExists && inCP)
        ret.dropLastRowsOrColumns(op.aggOp.correctionLocation);
    return ret;
}
Also used : Multiply(org.apache.sysml.runtime.functionobjects.Multiply) MinusMultiply(org.apache.sysml.runtime.functionobjects.MinusMultiply) PlusMultiply(org.apache.sysml.runtime.functionobjects.PlusMultiply) KahanPlus(org.apache.sysml.runtime.functionobjects.KahanPlus) ReduceRow(org.apache.sysml.runtime.functionobjects.ReduceRow) DMLRuntimeException(org.apache.sysml.runtime.DMLRuntimeException)

Aggregations

Multiply (org.apache.sysml.runtime.functionobjects.Multiply)6 DMLRuntimeException (org.apache.sysml.runtime.DMLRuntimeException)5 KahanPlus (org.apache.sysml.runtime.functionobjects.KahanPlus)4 Plus (org.apache.sysml.runtime.functionobjects.Plus)3 ReduceRow (org.apache.sysml.runtime.functionobjects.ReduceRow)3 MatrixObject (org.apache.sysml.runtime.controlprogram.caching.MatrixObject)2 Builtin (org.apache.sysml.runtime.functionobjects.Builtin)2 CM (org.apache.sysml.runtime.functionobjects.CM)2 IndexFunction (org.apache.sysml.runtime.functionobjects.IndexFunction)2 KahanPlusSq (org.apache.sysml.runtime.functionobjects.KahanPlusSq)2 Mean (org.apache.sysml.runtime.functionobjects.Mean)2 Minus1Multiply (org.apache.sysml.runtime.functionobjects.Minus1Multiply)2 MinusMultiply (org.apache.sysml.runtime.functionobjects.MinusMultiply)2 PlusMultiply (org.apache.sysml.runtime.functionobjects.PlusMultiply)2 ReduceAll (org.apache.sysml.runtime.functionobjects.ReduceAll)2 ReduceCol (org.apache.sysml.runtime.functionobjects.ReduceCol)2 ReduceDiag (org.apache.sysml.runtime.functionobjects.ReduceDiag)2 RightScalarOperator (org.apache.sysml.runtime.matrix.operators.RightScalarOperator)2 Pointer (jcuda.Pointer)1 And (org.apache.sysml.runtime.functionobjects.And)1