diff --git a/monai/csrc/resample/pushpull.h b/monai/csrc/resample/pushpull.h index b056bb77c2..b9c36b18d8 100644 --- a/monai/csrc/resample/pushpull.h +++ b/monai/csrc/resample/pushpull.h @@ -22,25 +22,25 @@ limitations under the License. #define MONAI_PUSHPULL_DECLARE(space) \ namespace space { \ - template \ + template \ std::deque pushpull( \ const SourceType& source, \ const at::Tensor& grid, \ - BoundType bound, \ - InterpolationType interpolation, \ + monai::BoundVectorRef bound, \ + monai::InterpolationVectorRef interpolation, \ bool extrapolate, \ bool do_pull, \ bool do_push, \ bool do_count, \ bool do_grad, \ bool do_sgrad); \ - template \ + template \ std::deque pushpull( \ const SourceType& source, \ const at::Tensor& grid, \ const at::Tensor& target, \ - BoundType bound, \ - InterpolationType interpolation, \ + monai::BoundVectorRef bound, \ + monai::InterpolationVectorRef interpolation, \ bool extrapolate, \ bool do_pull, \ bool do_push, \ diff --git a/monai/csrc/resample/pushpull_cpu.cpp b/monai/csrc/resample/pushpull_cpu.cpp index c638958a47..463782571d 100644 --- a/monai/csrc/resample/pushpull_cpu.cpp +++ b/monai/csrc/resample/pushpull_cpu.cpp @@ -35,7 +35,7 @@ limitations under the License. // . [DONE] spatial gradient mode (without multiplication with output gradient) // . [DONE] second order gradients (backward pass for spatial gradients) // . performance tests -// . input bound/inter are always vectors -> clean unused constructors +// . [DONE] input bound/inter are always vectors -> clean unused constructors #include #include @@ -2187,39 +2187,43 @@ MONAI_NAMESPACE_DEVICE { // cpu // FUNCTIONAL FORM WITH DISPATCH // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -#define PUSHPULL_INSTANTIATE3(BoundType0, InterpolationType0, SourceType0) \ - template std::deque pushpull( \ - const SourceType0&, \ - const Tensor&, \ - const Tensor&, \ - BoundType0, \ - InterpolationType0, \ - bool, \ - bool, \ - bool, \ - bool, \ - bool, \ - bool); \ - template std::deque pushpull( \ - const SourceType0&, const Tensor&, BoundType0, InterpolationType0, bool, bool, bool, bool, bool, bool) -#define PUSHPULL_INSTANTIATE2(BoundType0, InterpolationType0) \ - PUSHPULL_INSTANTIATE3(BoundType0, InterpolationType0, IntArrayRef); \ - PUSHPULL_INSTANTIATE3(BoundType0, InterpolationType0, Tensor) -#define PUSHPULL_INSTANTIATE1(BoundType0) \ - PUSHPULL_INSTANTIATE2(BoundType0, InterpolationType); \ - PUSHPULL_INSTANTIATE2(BoundType0, InterpolationVectorRef) -#define PUSHPULL_INSTANTIATE \ - PUSHPULL_INSTANTIATE1(BoundType); \ - PUSHPULL_INSTANTIATE1(BoundVectorRef) +#define PUSHPULL_INSTANTIATE_SOURCE(SourceType) \ + template std::deque pushpull( \ + const SourceType&, \ + const Tensor&, \ + const Tensor&, \ + BoundVectorRef, \ + InterpolationVectorRef, \ + bool, \ + bool, \ + bool, \ + bool, \ + bool, \ + bool); \ + template std::deque pushpull( \ + const SourceType&, \ + const Tensor&, \ + BoundVectorRef, \ + InterpolationVectorRef, \ + bool, \ + bool, \ + bool, \ + bool, \ + bool, \ + bool) + +#define PUSHPULL_INSTANTIATE \ + PUSHPULL_INSTANTIATE_SOURCE(IntArrayRef); \ + PUSHPULL_INSTANTIATE_SOURCE(Tensor) // Two arguments (source, grid) - // > `bound` and `interpolation` can be single arguments or vectors. - template + // > bound and interpolation are strictly VectorRef. + template MONAI_HOST std::deque pushpull( const SourceType& source, const Tensor& grid, - BoundType bound, - InterpolationType interpolation, + BoundVectorRef bound, + InterpolationVectorRef interpolation, bool extrapolate, bool do_pull, bool do_push, @@ -2238,15 +2242,14 @@ MONAI_NAMESPACE_DEVICE { // cpu } // Three arguments (source, grid, target) - // > `bound` and `interpolation` can be single arguments or vectors. - // > `source` can be a tensor or a vector of dimensions. - template + // > bound and interpolation are strictly VectorRef. + template MONAI_HOST std::deque pushpull( const SourceType& source, const Tensor& grid, const Tensor& target, - BoundType bound, - InterpolationType interpolation, + BoundVectorRef bound, + InterpolationVectorRef interpolation, bool extrapolate, bool do_pull, bool do_push, diff --git a/monai/csrc/resample/pushpull_cuda.cu b/monai/csrc/resample/pushpull_cuda.cu index 461962cb80..c254e18d73 100644 --- a/monai/csrc/resample/pushpull_cuda.cu +++ b/monai/csrc/resample/pushpull_cuda.cu @@ -35,7 +35,7 @@ limitations under the License. // . [DONE] spatial gradient mode (without multiplication with output gradient) // . [DONE] second order gradients (backward pass for spatial gradients) // . performance tests -// . input bound/inter are always vectors -> clean unused constructors +// . [DONE] input bound/inter are always vectors -> clean unused constructors #include #include @@ -2149,39 +2149,43 @@ MONAI_NAMESPACE_DEVICE { // cuda // FUNCTIONAL FORM WITH DISPATCH // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -#define PUSHPULL_INSTANTIATE3(BoundType0, InterpolationType0, SourceType0) \ - template std::deque pushpull( \ - const SourceType0&, \ - const Tensor&, \ - const Tensor&, \ - BoundType0, \ - InterpolationType0, \ - bool, \ - bool, \ - bool, \ - bool, \ - bool, \ - bool); \ - template std::deque pushpull( \ - const SourceType0&, const Tensor&, BoundType0, InterpolationType0, bool, bool, bool, bool, bool, bool) -#define PUSHPULL_INSTANTIATE2(BoundType0, InterpolationType0) \ - PUSHPULL_INSTANTIATE3(BoundType0, InterpolationType0, IntArrayRef); \ - PUSHPULL_INSTANTIATE3(BoundType0, InterpolationType0, Tensor) -#define PUSHPULL_INSTANTIATE1(BoundType0) \ - PUSHPULL_INSTANTIATE2(BoundType0, InterpolationType); \ - PUSHPULL_INSTANTIATE2(BoundType0, InterpolationVectorRef) -#define PUSHPULL_INSTANTIATE \ - PUSHPULL_INSTANTIATE1(BoundType); \ - PUSHPULL_INSTANTIATE1(BoundVectorRef) +#define PUSHPULL_INSTANTIATE_SOURCE(SourceType) \ + template std::deque pushpull( \ + const SourceType&, \ + const Tensor&, \ + const Tensor&, \ + BoundVectorRef, \ + InterpolationVectorRef, \ + bool, \ + bool, \ + bool, \ + bool, \ + bool, \ + bool); \ + template std::deque pushpull( \ + const SourceType&, \ + const Tensor&, \ + BoundVectorRef, \ + InterpolationVectorRef, \ + bool, \ + bool, \ + bool, \ + bool, \ + bool, \ + bool) + +#define PUSHPULL_INSTANTIATE \ + PUSHPULL_INSTANTIATE_SOURCE(IntArrayRef); \ + PUSHPULL_INSTANTIATE_SOURCE(Tensor) // Two arguments (source, grid) - // > `bound` and `interpolation` can be single arguments or vectors. - template + // > bound and interpolation are strictly VectorRef. + template MONAI_HOST std::deque pushpull( const SourceType& source, const Tensor& grid, - BoundType bound, - InterpolationType interpolation, + BoundVectorRef bound, + InterpolationVectorRef interpolation, bool extrapolate, bool do_pull, bool do_push, @@ -2206,15 +2210,14 @@ MONAI_NAMESPACE_DEVICE { // cuda } // Three arguments (source, grid, target) - // > `bound` and `interpolation` can be single arguments or vectors. - // > `source` can be a tensor or a vector of dimensions. - template + // > bound and interpolation are strictly VectorRef. + template MONAI_HOST std::deque pushpull( const SourceType& source, const Tensor& grid, const Tensor& target, - BoundType bound, - InterpolationType interpolation, + BoundVectorRef bound, + InterpolationVectorRef interpolation, bool extrapolate, bool do_pull, bool do_push,