Instructions to use Zipeng365/WISP with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Scikit-learn
How to use Zipeng365/WISP with Scikit-learn:
from huggingface_hub import hf_hub_download import joblib model = joblib.load( hf_hub_download("Zipeng365/WISP", "sklearn_model.joblib") ) # only load pickle files from sources you trust # read more about it here https://skops.readthedocs.io/en/stable/persistence.html - Notebooks
- Google Colab
- Kaggle
Download src/wisp_fast/shapelet_tiles.h from Zipeng365/WISP: direct link, hf CLI and curl.
- Browser
- Download file 3 kB
-
https://huggingface.co/Zipeng365/WISP/resolve/main/src/wisp_fast/shapelet_tiles.h
- Command line
-
hf download hf://Zipeng365/WISP/src/wisp_fast/shapelet_tiles.h
-
curl -L -o shapelet_tiles.h https://huggingface.co/Zipeng365/WISP/resolve/main/src/wisp_fast/shapelet_tiles.h
3 kB
| /* Compare eight consecutive candidate start positions of the same shapelet. | |
| Each lane retains NumPy's internal 8-way double reduction and its second | |
| centering pass in std. Strict chronological comparisons preserve first ties. */ | |
| typedef __m512d PositionTile; | |
| static SHAPE512 inline PositionTile tile_sum(const PositionTile *x, int len) { | |
| if(len<8) { | |
| PositionTile s=_mm512_set1_pd(-0.); | |
| for(int j=0;j<len;++j)s+=x[j]; | |
| return s; | |
| } | |
| PositionTile a=x[0],b=x[1],c=x[2],d=x[3],e=x[4],f=x[5],g=x[6],h=x[7]; | |
| int j=8; | |
| for(;j+8<=len;j+=8) { | |
| a+=x[j]; b+=x[j+1]; c+=x[j+2]; d+=x[j+3]; | |
| e+=x[j+4]; f+=x[j+5]; g+=x[j+6]; h+=x[j+7]; | |
| } | |
| PositionTile s=((a+b)+(c+d))+((e+f)+(g+h)); | |
| for(;j<len;++j)s+=x[j]; | |
| return s; | |
| } | |
| static SHAPE512 void shapelet_row(const double *x,const double *weights,double *dst, | |
| Py_ssize_t stop,int len,int dilation,int stride,Py_ssize_t k) { | |
| const __m512i offsets=_mm512_set_epi64(7LL*stride,6LL*stride,5LL*stride,4LL*stride, | |
| 3LL*stride,2LL*stride,stride,0); | |
| const PositionTile one=_mm512_set1_pd(1.), floor=_mm512_set1_pd(1e-6); | |
| PositionTile z[64],sq[64]; | |
| for(Py_ssize_t a=0;a<stop;a+=8LL*stride) { | |
| int lanes=(int)((stop-1-a)/stride+1); | |
| if(lanes>8)lanes=8; | |
| __mmask8 active=(__mmask8)((1U<<lanes)-1); | |
| for(int j=0;j<len;++j) { | |
| const double *base=x+a+(Py_ssize_t)j*dilation; | |
| z[j]=(stride==1)?_mm512_maskz_loadu_pd(active,base): | |
| _mm512_mask_i64gather_pd(_mm512_setzero_pd(),active,offsets,base,8); | |
| } | |
| PositionTile mu=tile_sum(z,len)/(double)len; | |
| for(int j=0;j<len;++j)z[j]-=mu; | |
| PositionTile centered_mean=tile_sum(z,len)/(double)len; | |
| for(int j=0;j<len;++j){PositionTile delta=z[j]-centered_mean;sq[j]=delta*delta;} | |
| PositionTile sd=_mm512_sqrt_pd(tile_sum(sq,len)/(double)len); | |
| sd=_mm512_mask_mov_pd(sd,_mm512_cmp_pd_mask(sd,floor,_CMP_LT_OQ),one); | |
| for(int j=0;j<len;++j)z[j]/=sd; | |
| for(Py_ssize_t h=0;h<k;++h) { | |
| for(int j=0;j<len;++j){PositionTile delta=z[j]-weights[h*len+j];sq[j]=delta*delta;} | |
| PositionTile value=_mm512_sqrt_pd(tile_sum(sq,len)/(double)len); | |
| unsigned improved=active & _mm512_cmp_pd_mask(value,_mm512_set1_pd(dst[2*h]),_CMP_LT_OQ); | |
| if(improved) { | |
| double scores[8];_mm512_storeu_pd(scores,value); | |
| while(improved) { | |
| int j=__builtin_ctz(improved); improved&=improved-1; | |
| if(scores[j]<dst[2*h]) { | |
| dst[2*h]=scores[j];dst[2*h+1]=(double)(a+(Py_ssize_t)j*stride)/(stop>1?stop-1:1); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |