use of org.apache.sysml.runtime.matrix.data.CM_N_COVCell in project incubator-systemml by apache.
the class CMCOVMRMapper method close.
@Override
public void close() throws IOException {
if (cachedCollector != null) {
for (byte tag : cmTags) {
CM_N_COVCell cmValue = (CM_N_COVCell) cmNcovCache.getFirst(tag).getValue();
cachedCollector.collect(new TaggedFirstSecondIndexes(1, tag, 1), cmValue);
}
for (byte tag : covTags) {
CM_N_COVCell comValue = (CM_N_COVCell) cmNcovCache.getFirst(tag).getValue();
cachedCollector.collect(new TaggedFirstSecondIndexes(1, tag, 1), comValue);
}
}
}
use of org.apache.sysml.runtime.matrix.data.CM_N_COVCell in project systemml by apache.
the class CMCOVMRMapper method close.
@Override
public void close() throws IOException {
if (cachedCollector != null) {
for (byte tag : cmTags) {
CM_N_COVCell cmValue = (CM_N_COVCell) cmNcovCache.getFirst(tag).getValue();
cachedCollector.collect(new TaggedFirstSecondIndexes(1, tag, 1), cmValue);
}
for (byte tag : covTags) {
CM_N_COVCell comValue = (CM_N_COVCell) cmNcovCache.getFirst(tag).getValue();
cachedCollector.collect(new TaggedFirstSecondIndexes(1, tag, 1), comValue);
}
}
}
use of org.apache.sysml.runtime.matrix.data.CM_N_COVCell in project systemml by apache.
the class CMCOVMRReducer method reduce.
@Override
public void reduce(TaggedFirstSecondIndexes index, Iterator<MatrixValue> values, OutputCollector<MatrixIndexes, MatrixValue> out, Reporter report) throws IOException {
commonSetup(report);
cmNcovCell.setCM_N_COVObject(0, 0, 0);
ValueFunction fn = cmFn.get(index.getTag());
if (covTags.contains(index.getTag()))
fn = covFn;
while (values.hasNext()) {
CM_N_COVCell cell = (CM_N_COVCell) values.next();
try {
fn.execute(cmNcovCell.getCM_N_COVObject(), cell.getCM_N_COVObject());
} catch (DMLRuntimeException e) {
throw new IOException(e);
}
}
// add 0 values back in
/* long totaln=rlens.get(index.getTag())*clens.get(index.getTag());
long zerosToAdd=totaln-(long)(cmNcovCell.getCM_N_COVObject().w);
for(long i=0; i<zerosToAdd; i++)
{
try {
fn.execute(cmNcovCell.getCM_N_COVObject(), zeroObj);
} catch (DMLRuntimeException e) {
throw new IOException(e);
}
}*/
long totaln = rlens.get(index.getTag()) * clens.get(index.getTag());
long zerosToAdd = totaln - (long) (cmNcovCell.getCM_N_COVObject().w);
if (zerosToAdd > 0) {
zeroObj.w = zerosToAdd;
try {
fn.execute(cmNcovCell.getCM_N_COVObject(), zeroObj);
} catch (DMLRuntimeException e) {
throw new IOException(e);
}
}
for (CM_N_COVInstruction in : cmNcovInstructions) {
if (in.input == index.getTag()) {
try {
outCell.setValue(cmNcovCell.getCM_N_COVObject().getRequiredResult(in.getOperator()));
} catch (DMLRuntimeException e) {
throw new IOException(e);
}
ArrayList<Integer> outputIndexes = outputIndexesMapping.get(in.output);
for (int i : outputIndexes) {
collectOutput_N_Increase_Counter(outIndex, outCell, i, report);
}
}
}
}
use of org.apache.sysml.runtime.matrix.data.CM_N_COVCell in project incubator-systemml by apache.
the class CMCOVMRMapper method specialOperationsForActualMap.
@Override
protected void specialOperationsForActualMap(int index, OutputCollector<Writable, Writable> out, Reporter reporter) throws IOException {
// apply all instructions
processMapperInstructionsForMatrix(index);
for (byte tag : cmTags) {
CM lcmFn = cmFn.get(tag);
IndexedMatrixValue input = cachedValues.getFirst(tag);
if (input == null)
continue;
WeightedPair inputPair = (WeightedPair) input.getValue();
CM_N_COVCell cmValue = (CM_N_COVCell) cmNcovCache.getFirst(tag).getValue();
try {
lcmFn.execute(cmValue.getCM_N_COVObject(), inputPair.getValue(), inputPair.getWeight());
} catch (DMLRuntimeException e) {
throw new IOException(e);
}
}
for (byte tag : covTags) {
IndexedMatrixValue input = cachedValues.getFirst(tag);
if (input == null)
continue;
WeightedPair inputPair = (WeightedPair) input.getValue();
CM_N_COVCell comValue = (CM_N_COVCell) cmNcovCache.getFirst(tag).getValue();
try {
covFn.execute(comValue.getCM_N_COVObject(), inputPair.getValue(), inputPair.getOtherValue(), inputPair.getWeight());
} catch (DMLRuntimeException e) {
throw new IOException(e);
}
}
}
use of org.apache.sysml.runtime.matrix.data.CM_N_COVCell in project incubator-systemml by apache.
the class CMCOVMRReducer method reduce.
@Override
public void reduce(TaggedFirstSecondIndexes index, Iterator<MatrixValue> values, OutputCollector<MatrixIndexes, MatrixValue> out, Reporter report) throws IOException {
commonSetup(report);
cmNcovCell.setCM_N_COVObject(0, 0, 0);
ValueFunction fn = cmFn.get(index.getTag());
if (covTags.contains(index.getTag()))
fn = covFn;
while (values.hasNext()) {
CM_N_COVCell cell = (CM_N_COVCell) values.next();
try {
fn.execute(cmNcovCell.getCM_N_COVObject(), cell.getCM_N_COVObject());
} catch (DMLRuntimeException e) {
throw new IOException(e);
}
}
// add 0 values back in
/* long totaln=rlens.get(index.getTag())*clens.get(index.getTag());
long zerosToAdd=totaln-(long)(cmNcovCell.getCM_N_COVObject().w);
for(long i=0; i<zerosToAdd; i++)
{
try {
fn.execute(cmNcovCell.getCM_N_COVObject(), zeroObj);
} catch (DMLRuntimeException e) {
throw new IOException(e);
}
}*/
long totaln = rlens.get(index.getTag()) * clens.get(index.getTag());
long zerosToAdd = totaln - (long) (cmNcovCell.getCM_N_COVObject().w);
if (zerosToAdd > 0) {
zeroObj.w = zerosToAdd;
try {
fn.execute(cmNcovCell.getCM_N_COVObject(), zeroObj);
} catch (DMLRuntimeException e) {
throw new IOException(e);
}
}
for (CM_N_COVInstruction in : cmNcovInstructions) {
if (in.input == index.getTag()) {
try {
outCell.setValue(cmNcovCell.getCM_N_COVObject().getRequiredResult(in.getOperator()));
} catch (DMLRuntimeException e) {
throw new IOException(e);
}
ArrayList<Integer> outputIndexes = outputIndexesMapping.get(in.output);
for (int i : outputIndexes) {
collectOutput_N_Increase_Counter(outIndex, outCell, i, report);
}
}
}
}
Aggregations