MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / init

Method init

dependency/densecrf3d/src/permutohedral_couts.cpp:141–363  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140#ifdef SSE_PERMUTOHEDRAL
141void Permutohedral::init ( const MatrixXf & feature )
142{
143 std::cout<<"INSIDE first permutohedral.init \n";
144 // Compute the lattice coordinates for each feature [there is going to be a lot of magic here
145 N_ = feature.cols();
146 d_ = feature.rows();
147 HashTable hash_table( d_, N_/**(d_+1)*/ );
148
149 const int blocksize = sizeof(__m128) / sizeof(float);
150 const __m128 invdplus1 = _mm_set1_ps( 1.0f / (d_+1) );
151 const __m128 dplus1 = _mm_set1_ps( d_+1 );
152 const __m128 Zero = _mm_set1_ps( 0 );
153 const __m128 One = _mm_set1_ps( 1 );
154
155 // Allocate the class memory
156 offset_.resize( (d_+1)*(N_+16) );
157 std::fill( offset_.begin(), offset_.end(), 0 );
158 barycentric_.resize( (d_+1)*(N_+16) );
159 std::fill( barycentric_.begin(), barycentric_.end(), 0 );
160 rank_.resize( (d_+1)*(N_+16) );
161
162 // Allocate the local memory
163 __m128 * scale_factor = (__m128*) _mm_malloc( (d_ )*sizeof(__m128) , 16 );
164 __m128 * f = (__m128*) _mm_malloc( (d_ )*sizeof(__m128) , 16 );
165 __m128 * elevated = (__m128*) _mm_malloc( (d_+1)*sizeof(__m128) , 16 );
166 __m128 * rem0 = (__m128*) _mm_malloc( (d_+1)*sizeof(__m128) , 16 );
167 __m128 * rank = (__m128*) _mm_malloc( (d_+1)*sizeof(__m128), 16 );
168 float * barycentric = new float[(d_+2)*blocksize];
169 short * canonical = new short[(d_+1)*(d_+1)];
170 short * key = new short[d_+1];
171
172 // Compute the canonical simplex
173 for( int i=0; i<=d_; i++ ){
174 for( int j=0; j<=d_-i; j++ )
175 canonical[i*(d_+1)+j] = i;
176 for( int j=d_-i+1; j<=d_; j++ )
177 canonical[i*(d_+1)+j] = i - (d_+1);
178 }
179
180 // Expected standard deviation of our filter (p.6 in [Adams etal 2010])
181 float inv_std_dev = sqrt(2.0 / 3.0)*(d_+1);
182 // Compute the diagonal part of E (p.5 in [Adams etal 2010])
183 for( int i=0; i<d_; i++ )
184 scale_factor[i] = _mm_set1_ps( 1.0 / sqrt( (i+2)*(i+1) ) * inv_std_dev );
185
186 // Setup the SSE rounding
187#ifndef __SSE4_1__
188 const unsigned int old_rounding = _mm_getcsr();
189 _mm_setcsr( (old_rounding&~_MM_ROUND_MASK) | _MM_ROUND_NEAREST );
190#endif
191
192 // Compute the simplex each feature lies in
193 for( int k=0; k<N_; k+=blocksize ){
194 std::cout<<"Outer for iteration started...\n";
195 // Load the feature from memory
196 float * ff = (float*)f;
197 for( int j=0; j<d_; j++ )
198 for( int i=0; i<blocksize; i++ ) {

Callers

nothing calls this directly

Calls 10

fillFunction · 0.50
sqrtFunction · 0.50
colsMethod · 0.45
rowsMethod · 0.45
resizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
findMethod · 0.45
sizeMethod · 0.45
getKeyMethod · 0.45

Tested by

no test coverage detected