Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cuda morphological hausdorff #4078

Open
wants to merge 57 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
1add687
initial docs
jakubMitura14 Apr 4, 2022
bd17a2d
added first simple test
jakubMitura14 Apr 5, 2022
cbfa807
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 5, 2022
5ca2306
Merge branch 'dev' into CUDAmorphologicalHausdorff
jakubMitura14 Apr 5, 2022
3f0f47a
Added licenses and entry in init.py in metrics
jakubMitura14 Apr 6, 2022
1122194
Merge branch 'CUDAmorphologicalHausdorff' of https://github.com/jakub…
jakubMitura14 Apr 6, 2022
427e114
improved docs
jakubMitura14 Apr 6, 2022
7fb1821
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 6, 2022
4aea64c
single stream, signed commit
jakubMitura14 Apr 6, 2022
139f4de
Merge branch 'CUDAmorphologicalHausdorff' of https://github.com/jakub…
jakubMitura14 Apr 6, 2022
5d3f668
added indantation
jakubMitura14 Apr 6, 2022
87bcf33
updated imports
jakubMitura14 Apr 6, 2022
433c075
[MONAI] python code formatting
monai-bot Apr 6, 2022
378a874
numberToLookFor changed, comments smaller colums
jakubMitura14 Apr 6, 2022
c50faec
Merge branch 'CUDAmorphologicalHausdorff' of https://github.com/jakub…
jakubMitura14 Apr 6, 2022
cdaf589
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 6, 2022
5b6a09a
added more tests
jakubMitura14 Apr 8, 2022
261bc00
Merge branch 'CUDAmorphologicalHausdorff' of https://github.com/jakub…
jakubMitura14 Apr 8, 2022
206aebc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 8, 2022
034f45f
added skip_if_no_cuda
jakubMitura14 Apr 8, 2022
a0e02da
Merge branch 'CUDAmorphologicalHausdorff' of https://github.com/jakub…
jakubMitura14 Apr 8, 2022
9580d16
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 8, 2022
b035328
Merge branch 'dev' into CUDAmorphologicalHausdorff
jakubMitura14 Apr 9, 2022
11710a2
[MONAI] python code formatting
monai-bot Apr 9, 2022
21e8076
formatted as Lint suggested
jakubMitura14 Apr 9, 2022
6f3b5c4
Merge branch 'CUDAmorphologicalHausdorff' of https://github.com/jakub…
jakubMitura14 Apr 9, 2022
7acb3d5
no camel case
jakubMitura14 Apr 9, 2022
8747ca8
[MONAI] python code formatting
monai-bot Apr 10, 2022
bf20c7f
implemented _compute_tensor
jakubMitura14 Apr 10, 2022
839caec
Merge branch 'CUDAmorphologicalHausdorff' of https://github.com/jakub…
jakubMitura14 Apr 10, 2022
12ab6a8
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 10, 2022
0fd3c6e
[MONAI] python code formatting
monai-bot Apr 10, 2022
ac3532b
changed hausdorff_cpp into hausdorff
jakubMitura14 Apr 10, 2022
7b2952d
Merge branch 'CUDAmorphologicalHausdorff' of https://github.com/jakub…
jakubMitura14 Apr 10, 2022
12dc543
black linting
jakubMitura14 Apr 10, 2022
c1a2f8b
Merge branch 'dev' into CUDAmorphologicalHausdorff
wyli Apr 11, 2022
d8236f6
updated imports, reduced size of tests
jakubMitura14 Apr 12, 2022
10c3be6
Merge branch 'CUDAmorphologicalHausdorff' of https://github.com/jakub…
jakubMitura14 Apr 12, 2022
222460e
[MONAI] python code formatting
monai-bot Apr 12, 2022
7b3e6a8
filtered cuda version
jakubMitura14 Apr 13, 2022
97a6b5f
Merge branch 'CUDAmorphologicalHausdorff' of https://github.com/jakub…
jakubMitura14 Apr 13, 2022
5606491
simple tests to debug
jakubMitura14 Apr 13, 2022
53d75bb
updated tests
jakubMitura14 Apr 13, 2022
2ae038d
hopefully fixed tests
jakubMitura14 Apr 18, 2022
d816332
formatted cu
jakubMitura14 Apr 30, 2022
f28fc3c
Merge branch 'dev' into CUDAmorphologicalHausdorff
wyli Apr 30, 2022
f1eba75
[MONAI] python code formatting
monai-bot Apr 30, 2022
49e5a52
commented out full res list ; correction of naming
jakubMitura14 Apr 30, 2022
ec7cbef
Merge branch 'CUDAmorphologicalHausdorff' of https://github.com/jakub…
jakubMitura14 Apr 30, 2022
79b44d9
fixed imports and commented line
jakubMitura14 May 1, 2022
f6aa389
cleaning
jakubMitura14 May 1, 2022
02b7a80
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 1, 2022
1dc76d1
debugging
jakubMitura14 May 3, 2022
fd62b1a
Merge branch 'CUDAmorphologicalHausdorff' of https://github.com/jakub…
jakubMitura14 May 3, 2022
4f064ce
working with lint
jakubMitura14 May 3, 2022
cb288ed
added C++ header
jakubMitura14 May 4, 2022
b265c5e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] May 4, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions monai/_extensions/hausdorff/hausdorff_cpp.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include <torch/extension.h>

#include <vector>

// CUDA declarations


int getHausdorffDistance_CUDA(
torch::Tensor goldStandard,
torch::Tensor algoOutput
, const int xDim, const int yDim
, const int zDim,const float robustnessPercent);


at::Tensor getHausdorffDistance_CUDA_FullResList(at::Tensor goldStandard,
at::Tensor algoOutput
, int WIDTH, int HEIGHT, int DEPTH, float robustnessPercent);



std::tuple<int, double> benchmarkOlivieraCUDA(
torch::Tensor goldStandard,
torch::Tensor algoOutput
, const int xDim, const int yDim
, const int zDim);

// C++ interface

// NOTE: AT_ASSERT has become AT_CHECK on master after 0.4.
#define CHECK_CUDA(x) AT_ASSERTM(x.type().is_cuda(), #x " must be a CUDA tensor")
#define CHECK_CONTIGUOUS(x) AT_ASSERTM(x.is_contiguous(), #x " must be contiguous")
#define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x)


int getHausdorffDistance(
torch::Tensor goldStandard,
torch::Tensor algoOutput
, const int xDim, const int yDim, const int zDim
, const float robustnessPercent=1.0
) {

CHECK_INPUT(goldStandard);
CHECK_INPUT(algoOutput);


return getHausdorffDistance_CUDA(goldStandard, algoOutput, xDim, yDim, zDim, robustnessPercent);


}




at::Tensor getHausdorffDistance_FullResList(
torch::Tensor goldStandard,
torch::Tensor algoOutput
, const int xDim, const int yDim, const int zDim
, const float robustnessPercent = 1.0
) {

CHECK_INPUT(goldStandard);
CHECK_INPUT(algoOutput);


return getHausdorffDistance_CUDA_FullResList(goldStandard, algoOutput, xDim, yDim, zDim, robustnessPercent);


}




std::tuple<int, double> benchmarkOlivieraCUDAOnlyBool(
torch::Tensor goldStandard,
torch::Tensor algoOutput
, const int xDim, const int yDim
, const int zDim) {
return benchmarkOlivieraCUDA(goldStandard, algoOutput, xDim, yDim, zDim);


}


PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("getHausdorffDistance", &getHausdorffDistance, "Basic version of Hausdorff distance");
m.def("benchmarkOlivieraCUDA", &benchmarkOlivieraCUDA, "Algorithm by Oliviera - just for comparison sake - accept only boolean arrays ");
m.def("getHausdorffDistance_FullResList", &getHausdorffDistance_FullResList, " return additionally full result list indicating in which dilatation iterations results were recorded ");
}
Loading