Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
kdtree
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cython-plus
kdtree
Commits
cb21e78e
Commit
cb21e78e
authored
Nov 23, 2021
by
Julien Jerphanion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Notes from Tue 23 Nov 12:17:31 CET 2021 meeting
parent
5d84296d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
13 deletions
+28
-13
Makefile
Makefile
+1
-0
kdtree.pyx
kdtree.pyx
+27
-13
No files found.
Makefile
View file @
cb21e78e
SHELL
=
/bin/bash
PROJECT
=
kdtree
# This can be change to use venv directly
VENV_PATH
=
`
conda info
--base
`
/envs/
${PROJECT}
PIP_EXECUTABLE
=
${VENV_PATH}
/bin/pip
PYTHON_EXECUTABLE
=
${VENV_PATH}
/bin/python
...
...
kdtree.pyx
View file @
cb21e78e
...
...
@@ -518,12 +518,13 @@ cdef cypclass Node activable:
cdef
cypclass
QueryActor
activable
:
D_t
*
query_points
D_t
*
query_points
_ptr
D_t
*
data_ptr
I_t
*
node_bounds_ptr
NodeData_t
*
node_data_ptr
I_t
*
indices_ptr
NeighborsHeaps
heaps
I_t
idx_worker
I_t
idx_start
I_t
idx_end
...
...
@@ -533,7 +534,7 @@ cdef cypclass QueryActor activable:
__init__
(
self
,
D_t
*
query_points
,
D_t
*
query_points
_ptr
,
D_t
*
data_ptr
,
I_t
*
node_bounds_ptr
,
NodeData_t
*
node_data_ptr
,
...
...
@@ -544,9 +545,9 @@ cdef cypclass QueryActor activable:
I_t
idx_end
,
I_t
n_features
,
I_t
n_nodes
,
I_t
node_bounds_ptr_offset
,
I_t
node_bounds_ptr_offset
):
self
.
query_points
=
query_points
self
.
query_points
_ptr
=
query_points_ptr
self
.
data_ptr
=
data_ptr
self
.
node_bounds_ptr
=
node_bounds_ptr
self
.
node_data_ptr
=
node_data_ptr
...
...
@@ -565,10 +566,21 @@ cdef cypclass QueryActor activable:
D_t
*
query_point
D_t
reduced_dist_LB
# [[1 2 3],
# [4 5 6],
# [7 8 9]]
# F-ordered: [1 4 7 2 5 8 3 6 9]
for
idx_pt
in
range
(
idx_start
,
idx_end
):
query_point
=
self
.
query_points
+
idx_pt
*
self
.
n_features
reduced_dist_LB
=
self
.
min_rdist
(
0
,
query_point
)
self
.
_query_single_depthfirst
(
0
,
idx_pt
,
reduced_dist_LB
)
# We use C-ordering
query_point
=
self
.
query_points_ptr
+
idx_pt
*
self
.
n_features
reduced_dist_LB
=
self
.
min_rdist
(
idx_node
=
0
,
pt
=
query_point
)
self
.
_query_single_depthfirst
(
idx_node
=
0
,
idx_pt
=
idx_pt
,
reduced_dist_LB
=
reduced_dist_LB
,
)
D_t
min_rdist
(
self
,
I_t
idx_node
,
...
...
@@ -580,6 +592,7 @@ cdef cypclass QueryActor activable:
I_t
j
for
j
in
range
(
self
.
n_features
):
# We use C-ordering
node_min_j
=
deref
(
self
.
node_bounds_ptr
+
idx_node
+
j
*
self
.
n_nodes
)
node_max_j
=
deref
(
self
.
node_bounds_ptr
+
idx_node
+
j
*
self
.
n_nodes
+
self
.
node_bounds_ptr_offset
)
...
...
@@ -606,7 +619,7 @@ cdef cypclass QueryActor activable:
cdef
D_t
sq_dist
,
reduced_dist_LB_1
,
reduced_dist_LB_2
cdef
I_t
i
,
idx_left_node
,
idx_right_node
cdef
D_t
*
query_point
=
query_points
+
idx_pt
*
self
.
n_features
cdef
D_t
*
query_point
_ptr
=
query_points_ptr
+
idx_pt
*
self
.
n_features
#------------------------------------------------------------
# Case 1: query point is outside node radius:
...
...
@@ -621,7 +634,7 @@ cdef cypclass QueryActor activable:
elif
node_info
.
is_leaf
:
for
i
in
range
(
node_info
.
idx_start
,
node_info
.
idx_end
):
sq_dist
=
sqeuclidean_dist
(
x1
=
query_point
,
x1
=
query_point
_ptr
,
x2
=
self
.
data_ptr
+
self
.
indices_ptr
[
i
]
*
self
.
n_features
,
k
=
self
.
n_features
,
)
...
...
@@ -633,8 +646,8 @@ cdef cypclass QueryActor activable:
else
:
idx_left_node
=
2
*
idx_node
+
1
idx_right_node
=
idx_left_node
+
1
reduced_dist_LB_1
=
self
.
min_rdist
(
idx_left_node
,
query_point
)
reduced_dist_LB_2
=
self
.
min_rdist
(
idx_right_node
,
query_point
)
reduced_dist_LB_1
=
self
.
min_rdist
(
idx_left_node
,
query_point
_ptr
)
reduced_dist_LB_2
=
self
.
min_rdist
(
idx_right_node
,
query_point
_ptr
)
# recursively query subnodes
if
reduced_dist_LB_1
<=
reduced_dist_LB_2
:
...
...
@@ -765,7 +778,7 @@ cdef cypclass KDTree:
I_t
n_query
=
query_points
.
shape
[
0
]
I_t
n_features
=
query_points
.
shape
[
1
]
I_t
n_neighbors
=
knn_indices
.
shape
[
1
]
D_t
*
_query_points
=
<
D_t
*>
query_points
.
data
D_t
*
query_points_ptr
=
<
D_t
*>
query_points
.
data
D_t
rdist_lower_bound
I_t
n_workers
=
omp_get_max_threads
()
I_t
n_points_worker
=
<
I_t
>
ceil
(
n_query
/
n_workers
)
...
...
@@ -783,7 +796,8 @@ cdef cypclass KDTree:
for
idx_worker
in
range
(
n_workers
):
query_actor
=
consume
QueryActor
(
query_points
,
query_points_ptr
,
self
.
_data_ptr
,
self
.
_node_bounds_ptr
,
self
.
_node_data_ptr
,
self
.
_indices_ptr
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment