namespace internal¶
// structs template <typename DT> struct dataTypeConverter template <> struct maxMinValue <double> template <> struct maxMinValue <float> template <typename DT> struct maxMinValue // unions template <typename DT> union conv template <> union conv <float> template <> union conv <double> // global variables const int NUMS
computingDistance¶
#include "xf_data_analytics/clustering/kmeansPredict.hpp"
template < typename DT, int Dim, int Kcluster, int uramDepth, int KU, int DV > void computingDistance ( hls::stream <ap_uint <sizeof (DT)*8>> sampleStrm [DV], hls::stream <bool>& endSampleStrm, ap_uint <sizeof (DT)*8*DV> centers [KU][uramDepth], const int dims, const int kcluster, hls::stream <DT> distStrm [KU], hls::stream <bool>& eDistStrm )
computingDistance calculates distance of each sample and all centers.
Parameters:
DT | data type, supporting float and double |
Dim | the maximum number of dimensions,dynamic number of dimension should be not greater than the maximum. |
Kcluster | the maximum number of cluster,dynamic number of cluster should be not greater than the maximum. |
uramDepth | the depth of uram where centers are stored. uramDepth should be not less than ceiling(Kcluster/KU)
|
KU | unroll factor of Kcluster, KU centers are took part in calculating distances concurrently with one sample. After Kcluster/KU+1 times at most, ouput the minimum distance of a sample and Kcluster centers. |
DV | unroll factor of Dim, DV elements in a center are took part in calculating distances concurrently with one sample. |
sampleStrm | input sample streams |
endSampleStrm | the end flag of sample stream |
centers | an array stored centers |
dims | the number of dimensions |
kcluster | the number of clusters |
distStrm | distance streams |
eDistStrm | the end flag of distance stream |
minDist¶
#include "xf_data_analytics/clustering/kmeansPredict.hpp"
template < typename DT, int Dim, int Kcluster, int KU > void minDist ( hls::stream <DT> distStrm [KU], hls::stream <bool>& eDistStrm, const int kcluster, hls::stream <ap_uint <32>>& tagStrm, hls::stream <bool>& eTagStrm )
minDist calculates the cluster index according to the minimum distance of each sample and all centers.
Parameters:
DT | data type, supporting float and double |
Dim | the maximum number of dimensions,dynamic number of dimension should be not greater than the maximum. |
Kcluster | the maximum number of cluster,dynamic number of cluster should be not greater than the maximum. |
uramDepth | the depth of uram where centers are stored. uramDepth should be not less than ceiling(Kcluster/KU)
|
KU | unroll factor of Kcluster, KU centers are took part in calculating distances concurrently with one sample. After Kcluster/KU+1 times at most, ouput the minimum distance of a sample and Kcluster centers. |
DV | unroll factor of Dim, DV elements in a center are took part in calculating distances concurrently with one sample. |
distStrm | distance streams |
eDistStrm | the end flag of distance stream |
kcluster | the number of clusters |
tagStrm | tag stream, label a cluster ID for each sample |
eTagStrm | end flag of tag stream |
closestCenter¶
#include "xf_data_analytics/clustering/kmeansPredict.hpp"
template < typename DT, int Dim, int Kcluster, int uramDepth, int KU, int DV > void closestCenter ( hls::stream <ap_uint <sizeof (DT)*8>> sampleStrm [DV], hls::stream <bool>& endSampleStrm, ap_uint <sizeof (DT)*8*DV> centers [KU][uramDepth], const int dims, const int kcluster, hls::stream <ap_uint <32>>& tagStrm, hls::stream <bool>& eTagStrm )
closetCenters computes the cluster index according to the minimum distance of each sample and all centers.
Parameters:
DT | data type, supporting float and double |
Dim | the maximum number of dimensions,dynamic number of dimension should be not greater than the maximum. |
Kcluster | the maximum number of cluster,dynamic number of cluster should be not greater than the maximum. |
uramDepth | the depth of uram where centers are stored. uramDepth should be not less than ceiling(Kcluster/KU)
|
KU | unroll factor of Kcluster, KU centers are took part in calculating distances concurrently with one sample. After Kcluster/KU+1 times at most, ouput the minimum distance of a sample and Kcluster centers. |
DV | unroll factor of Dim, DV elements in a center are took part in calculating distances concurrently with one sample. |
sampleStrm | input sample streams |
endSampleStrm | the end flag of sample stream |
centers | an array stored centers |
dims | the number of dimensions |
kcluster | the number of clusters |
tagStrm | tag stream, label a cluster ID for each sample |
endTagStrm | end flag of tag stream |
kMeansPredictImp¶
#include "xf_data_analytics/clustering/kmeansPredict.hpp"
template < typename DT, int Dim, int Kcluster, int uramDepth, int KU, int DV > void kMeansPredictImp ( hls::stream <ap_uint <sizeof (DT)*8>> sampleStrm [DV], hls::stream <bool>& endSampleStrm, ap_uint <sizeof (DT)*8*DV> centers [KU][uramDepth], const int dims, const int kcluster, hls::stream <ap_uint <32>>& tagStrm, hls::stream <bool>& endTagStrm )
kMeansPredict predicts cluster index for each sample.
Parameters:
DT | data type, supporting float and double |
Dim | the maximum number of dimensions,dynamic number of dimension should be not greater than the maximum. |
Kcluster | the maximum number of cluster,dynamic number of cluster should be not greater than the maximum. |
uramDepth | the depth of uram where centers are stored. uramDepth should be not less than ceiling(Kcluster/KU)
|
KU | unroll factor of Kcluster, KU centers are took part in calculating distances concurrently with one sample. After Kcluster/KU+1 times at most, ouput the minimum distance of a sample and Kcluster centers. |
DV | unroll factor of Dim, DV elements in a center are took part in calculating distances concurrently with one sample. |
sampleStrm | input sample streams, a sample needs ceiling(dims/DV) times to read. |
endSampleStrm | the end flag of sample stream. |
centers | an array stored centers, user should partition dim=1 in its defination. |
dims | the number of dimensions. |
kcluster | the number of clusters. |
tagStrm | tag stream, label a cluster ID for each sample. |
endTagStrm | end flag of tag stream. |