use of org.apache.sysml.runtime.matrix.data.MatrixBlock in project incubator-systemml by apache.
the class CorrMatrixBlock method readHeaderAndPayload.
private void readHeaderAndPayload(DataInput dis) throws IOException {
boolean corrExists = (dis.readByte() != 0) ? true : false;
_value = new MatrixBlock();
_value.readFields(dis);
if (corrExists) {
_corr = new MatrixBlock();
_corr.readFields(dis);
}
}
use of org.apache.sysml.runtime.matrix.data.MatrixBlock in project incubator-systemml by apache.
the class RowMatrixBlock method readHeaderAndPayload.
private void readHeaderAndPayload(DataInput dis) throws IOException {
_len = dis.readInt();
_row = dis.readInt();
_value = new MatrixBlock();
_value.readFields(dis);
}
use of org.apache.sysml.runtime.matrix.data.MatrixBlock in project incubator-systemml by apache.
the class ExtractGroupNWeights method call.
@Override
public Iterator<Tuple2<MatrixIndexes, WeightedCell>> call(Tuple2<MatrixIndexes, Tuple2<Tuple2<MatrixBlock, MatrixBlock>, MatrixBlock>> arg) throws Exception {
MatrixBlock group = arg._2._1._1;
MatrixBlock target = arg._2._1._2;
MatrixBlock weight = arg._2._2;
// sanity check matching block dimensions
if (group.getNumRows() != target.getNumRows() || group.getNumRows() != target.getNumRows()) {
throw new Exception("The blocksize for group/target/weight blocks are mismatched: " + group.getNumRows() + ", " + target.getNumRows() + ", " + weight.getNumRows());
}
// output weighted cells
ArrayList<Tuple2<MatrixIndexes, WeightedCell>> groupValuePairs = new ArrayList<>();
for (int i = 0; i < group.getNumRows(); i++) {
WeightedCell weightedCell = new WeightedCell();
weightedCell.setValue(target.quickGetValue(i, 0));
weightedCell.setWeight(weight.quickGetValue(i, 0));
long groupVal = UtilFunctions.toLong(group.quickGetValue(i, 0));
if (groupVal < 1) {
throw new Exception("Expected group values to be greater than equal to 1 but found " + groupVal);
}
MatrixIndexes ix = new MatrixIndexes(groupVal, 1);
groupValuePairs.add(new Tuple2<>(ix, weightedCell));
}
return groupValuePairs.iterator();
}
use of org.apache.sysml.runtime.matrix.data.MatrixBlock in project incubator-systemml by apache.
the class GetMIMBFromRow method call.
@Override
public Tuple2<MatrixIndexes, MatrixBlock> call(Row row) throws Exception {
MatrixIndexes indx = (MatrixIndexes) row.apply(0);
MatrixBlock blk = (MatrixBlock) row.apply(1);
return new Tuple2<>(indx, blk);
}
use of org.apache.sysml.runtime.matrix.data.MatrixBlock in project incubator-systemml by apache.
the class ReorgMapFunction method call.
@Override
public Tuple2<MatrixIndexes, MatrixBlock> call(Tuple2<MatrixIndexes, MatrixBlock> arg0) throws Exception {
MatrixIndexes ixIn = arg0._1();
MatrixBlock blkIn = arg0._2();
// swap the matrix indexes
MatrixIndexes ixOut = new MatrixIndexes(ixIn);
_indexFnObject.execute(ixIn, ixOut);
// swap the matrix block data
MatrixBlock blkOut = (MatrixBlock) blkIn.reorgOperations(_reorgOp, new MatrixBlock(), -1, -1, -1);
// output new tuple
return new Tuple2<>(ixOut, blkOut);
}
Aggregations