-
Notifications
You must be signed in to change notification settings - Fork 527
SYSTEMDS-3539 Implement delta encoding (Parts 1, 2, and 3) #2361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
b570380
SYSTEMDS-3539 Implement delta encoding (Parts 1, 2, and 3)
Hanhoun02 acc6849
[SYSTEMDS-3539] Fix DeltaDDC logic and clean up per review
Hanhoun02 e005659
[SYSTEMDS-3539] DeltaDDC Refinements
Hanhoun02 3888383
[SYSTEMDS-3539] DeltaDDC Refinements and Reviewer Fixes
Hanhoun02 8d8fcc3
[SYSTEMDS-3539] DeltaDDC Scalar Operations and Slicing Fixes
Hanhoun02 0d64bff
[SYSTEMDS-3539] Improve DeltaDDC Test Coverage for Codecov
Hanhoun02 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,7 @@ | |
| import org.apache.sysds.runtime.compress.CompressedMatrixBlock; | ||
| import org.apache.sysds.runtime.compress.DMLCompressionException; | ||
| import org.apache.sysds.runtime.compress.colgroup.ColGroupUtils.P; | ||
| import org.apache.sysds.runtime.compress.colgroup.dictionary.DeltaDictionary; | ||
| import org.apache.sysds.runtime.compress.colgroup.dictionary.Dictionary; | ||
| import org.apache.sysds.runtime.compress.colgroup.dictionary.DictionaryFactory; | ||
| import org.apache.sysds.runtime.compress.colgroup.dictionary.IDictionary; | ||
|
|
@@ -43,6 +44,9 @@ | |
| import org.apache.sysds.runtime.compress.colgroup.indexes.RangeIndex; | ||
| import org.apache.sysds.runtime.compress.colgroup.mapping.AMapToData; | ||
| import org.apache.sysds.runtime.compress.colgroup.mapping.MapToFactory; | ||
| import org.apache.sysds.runtime.compress.utils.ACount; | ||
| import org.apache.sysds.runtime.compress.utils.DblArray; | ||
| import org.apache.sysds.runtime.compress.utils.DblArrayCountHashMap; | ||
| import org.apache.sysds.runtime.compress.colgroup.offset.AOffsetIterator; | ||
| import org.apache.sysds.runtime.compress.colgroup.offset.OffsetFactory; | ||
| import org.apache.sysds.runtime.compress.colgroup.scheme.DDCScheme; | ||
|
|
@@ -77,7 +81,7 @@ public class ColGroupDDC extends APreAgg implements IMapToDataGroup { | |
|
|
||
| static final VectorSpecies<Double> SPECIES = DoubleVector.SPECIES_PREFERRED; | ||
|
|
||
| private ColGroupDDC(IColIndex colIndexes, IDictionary dict, AMapToData data, int[] cachedCounts) { | ||
| protected ColGroupDDC(IColIndex colIndexes, IDictionary dict, AMapToData data, int[] cachedCounts) { | ||
| super(colIndexes, dict, cachedCounts); | ||
| _data = data; | ||
|
|
||
|
|
@@ -1105,4 +1109,74 @@ protected boolean allowShallowIdentityRightMult() { | |
| return true; | ||
| } | ||
|
|
||
| public AColGroup convertToDeltaDDC() { | ||
| int numCols = _colIndexes.size(); | ||
| int numRows = _data.size(); | ||
|
|
||
| DblArrayCountHashMap map = new DblArrayCountHashMap(Math.max(numRows, 64)); | ||
| double[] rowDelta = new double[numCols]; | ||
| double[] prevRow = new double[numCols]; | ||
| DblArray dblArray = new DblArray(rowDelta); | ||
| int[] rowToDictId = new int[numRows]; | ||
|
|
||
| double[] dictVals = null; | ||
| try { | ||
| dictVals = _dict.getValues(); | ||
| } catch (Exception e) { | ||
| } | ||
|
|
||
| for(int i = 0; i < numRows; i++) { | ||
| int dictIdx = _data.getIndex(i); | ||
| if(dictVals != null) { | ||
| int off = dictIdx * numCols; | ||
| for(int j = 0; j < numCols; j++) { | ||
| double val = dictVals[off + j]; | ||
| if(i == 0) { | ||
| rowDelta[j] = val; | ||
| prevRow[j] = val; | ||
| } else { | ||
| rowDelta[j] = val - prevRow[j]; | ||
| prevRow[j] = val; | ||
| } | ||
| } | ||
| } else { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this case actually happen? Otherwise remove that null check |
||
| for(int j = 0; j < numCols; j++) { | ||
| double val = _dict.getValue(dictIdx, j, numCols); | ||
| if(i == 0) { | ||
| rowDelta[j] = val; | ||
| prevRow[j] = val; | ||
| } else { | ||
| rowDelta[j] = val - prevRow[j]; | ||
| prevRow[j] = val; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| rowToDictId[i] = map.increment(dblArray); | ||
| } | ||
|
|
||
| if(map.size() == 0) | ||
| return new ColGroupEmpty(_colIndexes); | ||
|
|
||
| ACount<DblArray>[] vals = map.extractValues(); | ||
| final int nVals = vals.length; | ||
| final double[] dictValues = new double[nVals * numCols]; | ||
| final int[] oldIdToNewId = new int[map.size()]; | ||
| int idx = 0; | ||
| for(int i = 0; i < nVals; i++) { | ||
| final ACount<DblArray> dac = vals[i]; | ||
| final double[] arrData = dac.key().getData(); | ||
| System.arraycopy(arrData, 0, dictValues, idx, numCols); | ||
| oldIdToNewId[dac.id] = i; | ||
| idx += numCols; | ||
| } | ||
|
|
||
| DeltaDictionary deltaDict = new DeltaDictionary(dictValues, numCols); | ||
| AMapToData newData = MapToFactory.create(numRows, nVals); | ||
| for(int i = 0; i < numRows; i++) { | ||
| newData.set(i, oldIdToNewId[rowToDictId[i]]); | ||
| } | ||
| return ColGroupDeltaDDC.create(_colIndexes, deltaDict, newData, null); | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this wrapped in a try ... catch? I don't think that there is a scenario where this would fail