@Override protected void setupLocal() { _syn0 = MemoryManager.malloc4f(_wordVecSize * _vocabWordCount); _words = new BufferedString[_vocabWordCount]; }
Col(String s, int rows, boolean isClass, int binLimit, boolean isFloat) { _name = s; _isFloat = isFloat; _isClass = isClass; _colBinLimit = binLimit; _isByte = false; _raw = MemoryManager.malloc4f(rows); _ignored = false; }
DenseRowMatrix(int rows, int cols) { this(MemoryManager.malloc4f(cols*rows), rows, cols); } DenseRowMatrix(float[] v, int rows, int cols) { _data = v; _rows = rows; _cols = cols; }
DenseVector(int len) { _data = MemoryManager.malloc4f(len); } DenseVector(float[] v) { _data = v; }
DenseColMatrix(int rows, int cols) { this(MemoryManager.malloc4f(cols*rows), rows, cols); } DenseColMatrix(float[] v, int rows, int cols) { _data = v; _rows = rows; _cols = cols; }
public float[] getA4f( ) { _arys++; int len = getInt(); if( len == -1 ) return null; float[] buf = MemoryManager.malloc4f(len); int sofar = 0; while( sofar < buf.length ) { FloatBuffer as = _bb.asFloatBuffer(); int more = Math.min(as.remaining(), len - sofar); as.get(buf, sofar, more); sofar += more; _bb.position(_bb.position() + as.position()*4); if( sofar < len ) getSp(Math.min(_bb.capacity()-3, (len-sofar)*4)); } return buf; } public long[] getA8( ) {
treeprops._rightChildren = MemoryManager.malloc4(sharedTreeSubgraph.nodesArray.size()); treeprops._descriptions = new String[sharedTreeSubgraph.nodesArray.size()]; treeprops._thresholds = MemoryManager.malloc4f(sharedTreeSubgraph.nodesArray.size()); treeprops._features = new String[sharedTreeSubgraph.nodesArray.size()]; treeprops._nas = new String[sharedTreeSubgraph.nodesArray.size()]; treeprops._predictions = MemoryManager.malloc4f(sharedTreeSubgraph.nodesArray.size());
int maxBinSize = (n > _colBinLimit) ? (n / _colBinLimit + Math.min(rem,1)) : 1; _binned2raw = MemoryManager.malloc4f(Math.min(n, _colBinLimit)); // if n is smaller than bin limit no need to compact int smax = 0, cntCurBin = 1; i = 0;
SparseVector(final DenseVector dv) { _size = dv.size(); // first count non-zeros for (int i=0; i<dv._data.length; ++i) { if (dv.get(i) != 0.0f) { _nnz++; } } // only allocate what's needed _indices = MemoryManager.malloc4(_nnz); _values = MemoryManager.malloc4f(_nnz); // fill values int idx = 0; for (int i=0; i<dv._data.length; ++i) { if (dv.get(i) != 0.0f) { _indices[idx] = i; _values[idx] = dv.get(i); idx++; } } assert(idx == nnz()); }
@Override public void map(Chunk [] chunks){ _res = new GLMValidation(null,_model.glm,_model.rank(_lambda)); final int nrows = chunks[0]._len; double [] row = MemoryManager.malloc8d(_model._names.length); float [] preds = MemoryManager.malloc4f(_model.glm.family == Family.binomial?3:1); OUTER: for(int i = 0; i < nrows; ++i){ if(chunks[chunks.length-1].isNA0(i))continue; for(int j = 0; j < chunks.length-1; ++j){ if(chunks[j].isNA0(i))continue OUTER; row[j] = chunks[j].at0(i); } _model.score0(row, preds); double response = chunks[chunks.length-1].at0(i); _res.add(response, _model.glm.family == Family.binomial?preds[2]:preds[0]); } } @Override public void reduce(GLMValidationTask gval){_res.add(gval._res);}
@Override public void map(Chunk [] chunks){ _xvals = new GLMValidation[_xmodels.length]; for(int i = 0; i < _xmodels.length; ++i) _xvals[i] = new GLMValidation(null,_xmodels[i].glm,_xmodels[i].rank(),_thresholds); final int nrows = chunks[0]._len; long start = chunks[0]._start; double [] row = MemoryManager.malloc8d(_xmodels[0]._names.length); float [] preds = MemoryManager.malloc4f(_xmodels[0].glm.family == Family.binomial?3:1); OUTER: for(int i = 0; i < nrows; ++i){ if(chunks[chunks.length-1].isNA0(i))continue; for(int j = 0; j < chunks.length-1; ++j){ if(chunks[j].isNA0(i))continue OUTER; row[j] = chunks[j].at0(i); } ++_nobs; final int mid = (int)((i + start) % _xmodels.length); final GLMModel model = _xmodels[mid]; final GLMValidation val = _xvals[mid]; model.score0(row, preds); double response = chunks[chunks.length-1].at80(i); val.add(response, model.glm.family == Family.binomial?preds[2]:preds[0]); } } @Override public void reduce(GLMXValidationTask gval){
@Override protected void setupLocal() { _syn0 = MemoryManager.malloc4f(_wordVecSize * _vocabWordCount); _words = new BufferedString[_vocabWordCount]; }
private static void enlargeTables(float[][] data, int[][] rowIndex, int cols, int currentRow, int currentCol) { while (data[currentRow].length < currentCol + cols) { if(data[currentRow].length == ARRAY_MAX) { currentCol = 0; cols -= (data[currentRow].length - currentCol); currentRow++; data[currentRow] = malloc4f(ALLOCATED_ARRAY_LEN); rowIndex[currentRow] = malloc4(ALLOCATED_ARRAY_LEN); } else { int newLen = (int) Math.min((long) data[currentRow].length << 1L, (long) ARRAY_MAX); data[currentRow] = Arrays.copyOf(data[currentRow], newLen); rowIndex[currentRow] = Arrays.copyOf(rowIndex[currentRow], newLen); } } }
treeprops._rightChildren = MemoryManager.malloc4(sharedTreeSubgraph.nodesArray.size()); treeprops._descriptions = new String[sharedTreeSubgraph.nodesArray.size()]; treeprops._thresholds = MemoryManager.malloc4f(sharedTreeSubgraph.nodesArray.size()); treeprops._features = new String[sharedTreeSubgraph.nodesArray.size()]; treeprops._nas = new String[sharedTreeSubgraph.nodesArray.size()]; treeprops._predictions = MemoryManager.malloc4f(sharedTreeSubgraph.nodesArray.size());