| 335 | |
| 336 | |
| 337 | std::tuple<py::array_t<int>, py::array_t<int>> nonuniform_quantize(py::array_t<int> seg_idx, |
| 338 | py::array_t<float> residual, py::array_t<int> key_point_map, |
| 339 | py::array_t<int> level_kp_num, py::array_t<float> level_acc, int ground_level) { |
| 340 | // input array |
| 341 | py::buffer_info si_buf = seg_idx.request(); |
| 342 | int *si_ptr = (int *) si_buf.ptr; |
| 343 | py::buffer_info ri_buf = residual.request(); |
| 344 | float *ri_ptr = (float *) ri_buf.ptr; |
| 345 | py::buffer_info kp_buf = key_point_map.request(); |
| 346 | int *kp_ptr = (int *) kp_buf.ptr; |
| 347 | py::buffer_info lkpn_buf = level_kp_num.request(); |
| 348 | int *lkpn_ptr = (int *) lkpn_buf.ptr; |
| 349 | py::buffer_info la_buf = level_acc.request(); |
| 350 | float *la_ptr = (float *) la_buf.ptr; |
| 351 | int h = si_buf.shape[0]; |
| 352 | int w = si_buf.shape[1]; |
| 353 | int level_num = la_buf.shape[0]; |
| 354 | |
| 355 | int cluster_num = 0; |
| 356 | for (int h_i = 0; h_i < h; h_i++) |
| 357 | for (int w_i = 0; w_i < w; w_i++) |
| 358 | if (si_ptr[h_i * w + w_i] > cluster_num) |
| 359 | cluster_num = si_ptr[h_i * w + w_i]; |
| 360 | cluster_num += 1; |
| 361 | |
| 362 | vector< vector<float> > quantized_residual; |
| 363 | vector<int> kp_num; |
| 364 | vector<int> p_num; |
| 365 | vector<int> salience_level; |
| 366 | vector<float> cluster_acc; |
| 367 | for (int i = 0; i < cluster_num; i++){ |
| 368 | vector<float> cur_qr; |
| 369 | quantized_residual.push_back(cur_qr); |
| 370 | kp_num.push_back(0); |
| 371 | p_num.push_back(0); |
| 372 | salience_level.push_back(0); |
| 373 | cluster_acc.push_back(0); |
| 374 | } |
| 375 | |
| 376 | int total_num = 0; |
| 377 | for (int h_i = 0; h_i < h; h_i++) { |
| 378 | for (int w_i = 0; w_i < w; w_i++){ |
| 379 | int idx = si_ptr[h_i * w + w_i]; |
| 380 | if (idx == 1) continue; |
| 381 | if (kp_ptr[h_i * w + w_i] > 0) |
| 382 | kp_num[idx] += 1; |
| 383 | p_num[idx] += 1; |
| 384 | quantized_residual[idx].push_back(ri_ptr[h_i * w + w_i]); |
| 385 | total_num += 1; |
| 386 | } |
| 387 | } |
| 388 | for (int i = 0; i < cluster_num; i++){ |
| 389 | if (i == 0) |
| 390 | salience_level[0] = ground_level; // ground points |
| 391 | else if (i == 1) |
| 392 | salience_level[1] = level_num - 1; // zero points; |
| 393 | else{ |
| 394 | if (p_num[i] < 30) |
nothing calls this directly
no outgoing calls
no test coverage detected