Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torch-spline-conv
Commits
f8ca386a
"docs/vscode:/vscode.git/clone" did not exist on "2e83cbbb6de84be7241218c8f5ea914ceb68c149"
Commit
f8ca386a
authored
Mar 11, 2018
by
rusty1s
Browse files
added basis tests
parent
44a2d7eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
7 deletions
+48
-7
test/basis.json
test/basis.json
+43
-4
test/test_basis.py
test/test_basis.py
+3
-1
torch_spline_conv/src/generic/cpu.c
torch_spline_conv/src/generic/cpu.c
+2
-2
No files found.
test/basis.json
View file @
f8ca386a
[
[
{
{
"name"
:
"Linear and open B-splines"
,
"degree"
:
1
,
"degree"
:
1
,
"pseudo"
:
[
0
,
0.
12
5
,
0.25
,
0.5
,
0.75
,
0.
87
5
,
1
],
"pseudo"
:
[
0
,
0.
0
5
,
0.25
,
0.5
,
0.75
,
0.
9
5
,
1
],
"kernel_size"
:
[
5
],
"kernel_size"
:
[
5
],
"is_open_spline"
:
[
1
],
"is_open_spline"
:
[
1
],
"expected_basis"
:
[[
1
,
0
],
[
0.
5
,
0.
5
],
[
1
,
0
],
[
1
,
0
],
[
1
,
0
],
[
0.
5
,
0.
5
],
[
1
,
0
]],
"expected_basis"
:
[[
1
,
0
],
[
0.
8
,
0.
2
],
[
1
,
0
],
[
1
,
0
],
[
1
,
0
],
[
0.
2
,
0.
8
],
[
1
,
0
]],
"expected_index"
:
[[
0
,
1
],
[
0
,
1
],
[
1
,
2
],
[
2
,
3
],
[
3
,
4
],
[
3
,
4
],
[
4
,
0
]]
"expected_index"
:
[[
0
,
1
],
[
0
,
1
],
[
1
,
2
],
[
2
,
3
],
[
3
,
4
],
[
3
,
4
],
[
4
,
0
]]
},
},
{
{
"name"
:
"Linear and closed B-splines"
,
"degree"
:
1
,
"degree"
:
1
,
"pseudo"
:
[
0
,
0.
12
5
,
0.25
,
0.5
,
0.75
,
0.
87
5
,
1
],
"pseudo"
:
[
0
,
0.
0
5
,
0.25
,
0.5
,
0.75
,
0.
9
5
,
1
],
"kernel_size"
:
[
4
],
"kernel_size"
:
[
4
],
"is_open_spline"
:
[
0
],
"is_open_spline"
:
[
0
],
"expected_basis"
:
[[
1
,
0
],
[
0.
5
,
0.
5
],
[
1
,
0
],
[
1
,
0
],
[
1
,
0
],
[
0.
5
,
0.
5
],
[
1
,
0
]],
"expected_basis"
:
[[
1
,
0
],
[
0.
8
,
0.
2
],
[
1
,
0
],
[
1
,
0
],
[
1
,
0
],
[
0.
2
,
0.
8
],
[
1
,
0
]],
"expected_index"
:
[[
0
,
1
],
[
0
,
1
],
[
1
,
2
],
[
2
,
3
],
[
3
,
0
],
[
3
,
0
],
[
0
,
1
]]
"expected_index"
:
[[
0
,
1
],
[
0
,
1
],
[
1
,
2
],
[
2
,
3
],
[
3
,
0
],
[
3
,
0
],
[
0
,
1
]]
},
},
{
{
"name"
:
"Quadratic and open B-splines"
,
"degree"
:
2
,
"pseudo"
:
[
0
,
0.05
,
0.25
,
0.5
,
0.75
,
0.95
,
1
],
"kernel_size"
:
[
6
],
"is_open_spline"
:
[
1
],
"expected_basis"
:
[[
0.5
,
0.5
,
0
],
[
0.32
,
0.66
,
0.02
],
[
0.5
,
0.5
,
0
],
[
0.5
,
0.5
,
0
],
[
0.5
,
0.5
,
0
],
[
0.02
,
0.66
,
0.32
],
[
0.5
,
0.5
,
0
]],
"expected_index"
:
[[
0
,
1
,
2
],
[
0
,
1
,
2
],
[
1
,
2
,
3
],
[
2
,
3
,
4
],
[
3
,
4
,
5
],
[
3
,
4
,
5
],
[
4
,
5
,
0
]]
},
{
"name"
:
"Quadratic and closed B-splines"
,
"degree"
:
2
,
"pseudo"
:
[
0
,
0.05
,
0.25
,
0.5
,
0.75
,
0.95
,
1
],
"kernel_size"
:
[
4
],
"is_open_spline"
:
[
0
],
"expected_basis"
:
[[
0.5
,
0.5
,
0
],
[
0.32
,
0.66
,
0.02
],
[
0.5
,
0.5
,
0
],
[
0.5
,
0.5
,
0
],
[
0.5
,
0.5
,
0
],
[
0.02
,
0.66
,
0.32
],
[
0.5
,
0.5
,
0
]],
"expected_index"
:
[[
0
,
1
,
2
],
[
0
,
1
,
2
],
[
1
,
2
,
3
],
[
2
,
3
,
0
],
[
3
,
0
,
1
],
[
3
,
0
,
1
],
[
0
,
1
,
2
]]
},
{
"name"
:
"Cubic and open B-splines"
,
"degree"
:
3
,
"pseudo"
:
[
0
,
0.05
,
0.25
,
0.5
,
0.75
,
0.95
,
1
],
"kernel_size"
:
[
7
],
"is_open_spline"
:
[
1
],
"expected_basis"
:
[[
0.16667
,
0.6667
,
0.1667
,
0
],
[
0.0853
,
0.6307
,
0.2827
,
0.00133
],
[
0.1667
,
0.6667
,
0.1667
,
0
],
[
0.1667
,
0.6667
,
0.1667
,
0
],
[
0.1667
,
0.6667
,
0.1667
,
0
],
[
0.00133
,
0.2827
,
0.6307
,
0.0853
],
[
0.1667
,
0.6667
,
0.1667
,
0
]],
"expected_index"
:
[[
0
,
1
,
2
,
3
],
[
0
,
1
,
2
,
3
],
[
1
,
2
,
3
,
4
],
[
2
,
3
,
4
,
5
],
[
3
,
4
,
5
,
6
],
[
3
,
4
,
5
,
6
],
[
4
,
5
,
6
,
0
]]
},
{
"name"
:
"Cubic and closed B-splines"
,
"degree"
:
3
,
"pseudo"
:
[
0
,
0.05
,
0.25
,
0.5
,
0.75
,
0.95
,
1
],
"kernel_size"
:
[
4
],
"is_open_spline"
:
[
0
],
"expected_basis"
:
[[
0.16667
,
0.6667
,
0.1667
,
0
],
[
0.0853
,
0.6307
,
0.2827
,
0.00133
],
[
0.1667
,
0.6667
,
0.1667
,
0
],
[
0.1667
,
0.6667
,
0.1667
,
0
],
[
0.1667
,
0.6667
,
0.1667
,
0
],
[
0.00133
,
0.2827
,
0.6307
,
0.0853
],
[
0.1667
,
0.6667
,
0.1667
,
0
]],
"expected_index"
:
[[
0
,
1
,
2
,
3
],
[
0
,
1
,
2
,
3
],
[
1
,
2
,
3
,
0
],
[
2
,
3
,
0
,
1
],
[
3
,
0
,
1
,
2
],
[
3
,
0
,
1
,
2
],
[
0
,
1
,
2
,
3
]]
},
{
"name"
:
"Two-dimensional pseudo-coordinates"
,
"degree"
:
1
,
"degree"
:
1
,
"pseudo"
:
[[
0.125
,
0.5
],
[
0.5
,
0.5
],
[
0.75
,
0.125
]],
"pseudo"
:
[[
0.125
,
0.5
],
[
0.5
,
0.5
],
[
0.75
,
0.125
]],
"kernel_size"
:
[
5
,
5
],
"kernel_size"
:
[
5
,
5
],
...
...
test/test_basis.py
View file @
f8ca386a
...
@@ -24,5 +24,7 @@ def test_spline_basis_cpu(tensor, i):
...
@@ -24,5 +24,7 @@ def test_spline_basis_cpu(tensor, i):
expected_index
=
torch
.
ByteTensor
(
data
[
i
][
'expected_index'
])
expected_index
=
torch
.
ByteTensor
(
data
[
i
][
'expected_index'
])
basis
,
index
=
spline_basis
(
degree
,
pseudo
,
kernel_size
,
is_open_spline
,
K
)
basis
,
index
=
spline_basis
(
degree
,
pseudo
,
kernel_size
,
is_open_spline
,
K
)
assert
basis
.
tolist
()
==
expected_basis
.
tolist
()
basis
=
[
pytest
.
approx
(
x
,
0.01
)
for
x
in
basis
.
view
(
-
1
).
tolist
()]
assert
basis
==
expected_basis
.
view
(
-
1
).
tolist
()
assert
index
.
tolist
()
==
expected_index
.
tolist
()
assert
index
.
tolist
()
==
expected_index
.
tolist
()
torch_spline_conv/src/generic/cpu.c
View file @
f8ca386a
...
@@ -15,9 +15,9 @@
...
@@ -15,9 +15,9 @@
for (d = 0; d < D; d++) { \
for (d = 0; d < D; d++) { \
offset /= kernel_size_data[d]; \
offset /= kernel_size_data[d]; \
k_mod = k % (M + 1); \
k_mod = k % (M + 1); \
k /=
(
M + 1
)
; \
k /= M + 1; \
value = *(pseudo_data + d * pseudo_stride) * (kernel_size_data[d] - M * is_open_spline_data[d]); \
value = *(pseudo_data + d * pseudo_stride) * (kernel_size_data[d] - M * is_open_spline_data[d]); \
i += (((
(
int64_t) value
)
+ k_mod) % kernel_size_data[d]) * offset; \
i += (((int64_t) value + k_mod) % kernel_size_data[d]) * offset; \
value -= floor(value); \
value -= floor(value); \
CODE \
CODE \
b *= value; \
b *= value; \
...
...
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