Skip to content

Commit

Permalink
ENH: Add python wrapping for CudaCommon
Browse files Browse the repository at this point in the history
This wrapping differs from the one that used to be in RTK by the fact that
it only wraps the interface for floating type data and only for image
dimensions included in ${ITK_WRAP_IMAGE_DIMS} and vector components
included in ${ITK_WRAP_VECTOR_COMPONENTS}.
RTK will have to wrap itself everything else it needs.
  • Loading branch information
AlexyPellegrini committed Jun 1, 2022
1 parent 2999fc3 commit 095abb2
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 107 deletions.
6 changes: 1 addition & 5 deletions wrapping/itkCudaDataManager.wrap
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
if(RTK_USE_CUDA)

itk_wrap_simple_class("itk::CudaDataManager" POINTER)

endif()
itk_wrap_simple_class("itk::CudaDataManager" POINTER)
37 changes: 12 additions & 25 deletions wrapping/itkCudaImage.wrap
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
if(RTK_USE_CUDA)
itk_wrap_class("itk::CudaImage" POINTER_WITH_CONST_POINTER)

itk_wrap_class("itk::CudaImage" POINTER_WITH_CONST_POINTER)
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("F${d}" "float, ${d}")
endforeach()

foreach(component ${ITK_WRAP_VECTOR_COMPONENTS})
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("F${d}" "float, ${d}")
endforeach()

list(FIND ITK_WRAP_IMAGE_DIMS "4" _index)
if (${_index} EQUAL -1)
itk_wrap_template("F4" "${ITKT_F}, 4")
endif()

# Force VECTOR_COMPONENTS to "2;3;4;5"
# Force ITK_WRAP_IMAGE_DIMS to "2;3;4"
UNIQUE(imageDimensions "${ITK_WRAP_IMAGE_DIMS};2;3;4")
UNIQUE(vectorComponents "${ITK_WRAP_VECTOR_COMPONENTS};2;3;4;5")
foreach(component ${vectorComponents})
foreach(d ${imageDimensions})
foreach(vt ${WRAP_ITK_VECTOR_REAL})
itk_wrap_template("${ITKM_${vt}${component}}${d}" "${ITKT_${vt}${component}}, ${d}")
endforeach()
foreach(cvt ${WRAP_ITK_COV_VECTOR_REAL})
itk_wrap_template("${ITKM_${cvt}${component}}${d}" "${ITKT_${cvt}${component}}, ${d}")
endforeach()
foreach(vt ${WRAP_ITK_VECTOR_REAL})
itk_wrap_template("${ITKM_${vt}${component}}${d}" "${ITKT_${vt}${component}}, ${d}")
endforeach()
foreach(cvt ${WRAP_ITK_COV_VECTOR_REAL})
itk_wrap_template("${ITKM_${cvt}${component}}${d}" "${ITKT_${cvt}${component}}, ${d}")
endforeach()
endforeach()
endforeach()

itk_end_wrap_class()

endif()
itk_end_wrap_class()
39 changes: 10 additions & 29 deletions wrapping/itkCudaImageDataManager.wrap
Original file line number Diff line number Diff line change
@@ -1,35 +1,16 @@
if(RTK_USE_CUDA)
itk_wrap_include(itkCudaImage.h)

itk_wrap_include(itkCudaImage.h)
itk_wrap_class("itk::CudaImageDataManager" POINTER)

itk_wrap_class("itk::CudaImageDataManager" POINTER)
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_F}${d}" "itk::CudaImage<${ITKT_F}, ${d}>")
endforeach()

foreach(component ${ITK_WRAP_VECTOR_COMPONENTS})
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_F}${d}" "itk::CudaImage<${ITKT_F}, ${d}>")
itk_wrap_template("CI${ITKM_VF${component}}${d}" "itk::CudaImage<${ITKT_VF${component}}, ${d}>")
itk_wrap_template("CI${ITKM_CVF${component}}${d}" "itk::CudaImage<${ITKT_CVF${component}}, ${d}>")
endforeach()
endforeach()

list(FIND ITK_WRAP_IMAGE_DIMS "4" _index)
if(${_index} EQUAL -1)
itk_wrap_template("CI${ITKM_F}4" "itk::CudaImage<${ITKT_F}, 4>")
endif()

# Force VECTOR_COMPONENTS to "2;3;4;5"
UNIQUE(vectorComponents "${ITK_WRAP_VECTOR_COMPONENTS};2;3;4;5")
foreach(component ${vectorComponents})

foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_VF${component}}${d}" "itk::CudaImage<${ITKT_VF${component}}, ${d}>")
itk_wrap_template("CI${ITKM_CVF${component}}${d}" "itk::CudaImage<${ITKT_CVF${component}}, ${d}>")
endforeach()

list(FIND ITK_WRAP_IMAGE_DIMS "4" _index)
if(${_index} EQUAL -1)
itk_wrap_template("CI${ITKM_VF${component}}4" "itk::CudaImage<${ITKT_VF${component}}, 4>")
itk_wrap_template("CI${ITKM_CVF${component}}4" "itk::CudaImage<${ITKT_CVF${component}}, 4>")
endif()

endforeach()

itk_end_wrap_class()

endif()
itk_end_wrap_class()
27 changes: 10 additions & 17 deletions wrapping/itkCudaImageToImageFilter.wrap
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
if(RTK_USE_CUDA)
itk_wrap_class("itk::CudaImageToImageFilter" POINTER)

itk_wrap_class("itk::CudaImageToImageFilter" POINTER)
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_F}${d}CI${ITKM_F}${d}"
"itk::CudaImage<${ITKT_F}, ${d}>, itk::CudaImage<${ITKT_F}, ${d}>")
endforeach()

foreach(component ${ITK_WRAP_VECTOR_COMPONENTS})
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_F}${d}CI${ITKM_F}${d}"
"itk::CudaImage<${ITKT_F}, ${d}>, itk::CudaImage<${ITKT_F}, ${d}>")
itk_wrap_template("CI${ITKM_VF${component}}${d}CI${ITKM_VF${component}}${d}"
"itk::CudaImage<${ITKT_VF${component}}, ${d}>, itk::CudaImage<${ITKT_VF${component}}, ${d}>")
endforeach()
endforeach()

# Force VECTOR_COMPONENTS to "2;3;4;5"
UNIQUE(imageDimensions "${ITK_WRAP_IMAGE_DIMS};2;3;4")
UNIQUE(vectorComponents "${ITK_WRAP_VECTOR_COMPONENTS};2;3;4;5")
foreach(component ${vectorComponents})
foreach(d ${imageDimensions})
itk_wrap_template("CI${ITKM_VF${component}}${d}CI${ITKM_VF${component}}${d}"
"itk::CudaImage<${ITKT_VF${component}}, ${d}>, itk::CudaImage<${ITKT_VF${component}}, ${d}>")
endforeach()
endforeach()

itk_end_wrap_class()

endif()
itk_end_wrap_class()
51 changes: 21 additions & 30 deletions wrapping/itkCudaInPlaceImageFilter.wrap
Original file line number Diff line number Diff line change
@@ -1,40 +1,31 @@
if(RTK_USE_CUDA)
itk_wrap_class("itk::CudaInPlaceImageFilter" POINTER)

itk_wrap_class("itk::CudaInPlaceImageFilter" POINTER)
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_F}${d}CI${ITKM_F}${d}"
"itk::CudaImage<${ITKT_F}, ${d}>, itk::CudaImage<${ITKT_F}, ${d}>")
endforeach()

#itk_wrap_image_filter_combinations("${WRAP_ITK_REAL}" "${WRAP_ITK_REAL}")
foreach(component ${ITK_WRAP_VECTOR_COMPONENTS})
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_F}${d}CI${ITKM_F}${d}"
"itk::CudaImage<${ITKT_F}, ${d}>, itk::CudaImage<${ITKT_F}, ${d}>")
itk_wrap_template("CI${ITKM_V${ITKM_F}${component}}${d}CI${ITKM_V${ITKM_F}${component}}${d}"
"itk::CudaImage<itk::Vector<${ITKT_F},${component}>, ${d}>, itk::CudaImage<itk::Vector<${ITKT_F},${component}>, ${d}>")
endforeach()
endforeach()

# Force VECTOR_COMPONENTS to "2;3;4;5"
UNIQUE(vectorComponents "${ITK_WRAP_VECTOR_COMPONENTS};2;3;4;5")
foreach(component ${vectorComponents})
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_V${ITKM_F}${component}}${d}CI${ITKM_V${ITKM_F}${component}}${d}"
"itk::CudaImage<itk::Vector<${ITKT_F},${component}>, ${d}>, itk::CudaImage<itk::Vector<${ITKT_F},${component}>, ${d}>")
endforeach()
endforeach()
itk_end_wrap_class()

itk_end_wrap_class()
itk_wrap_class("itk::CudaImageToImageFilter" POINTER)

itk_wrap_class("itk::CudaImageToImageFilter" POINTER)
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_F}${d}CI${ITKM_F}${d}IPIFCI${ITKM_F}${d}" "itk::CudaImage<${ITKT_F}, ${d}>, itk::CudaImage<${ITKT_F}, ${d}>, itk::InPlaceImageFilter< itk::CudaImage<${ITKT_F}, ${d}> >")
endforeach()
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_F}${d}CI${ITKM_F}${d}IPIFCI${ITKM_F}${d}"
"itk::CudaImage<${ITKT_F}, ${d}>, itk::CudaImage<${ITKT_F}, ${d}>, itk::InPlaceImageFilter< itk::CudaImage<${ITKT_F}, ${d}> >")
endforeach()

# Force VECTOR_COMPONENTS to "2;3;4;5"
# Force ITK_WRAP_IMAGE_DIMS to "2;3;4"
UNIQUE(imageDimensions "${ITK_WRAP_IMAGE_DIMS};2;3;4")
UNIQUE(vectorComponents "${ITK_WRAP_VECTOR_COMPONENTS};2;3;4;5")
foreach(component ${vectorComponents})
foreach(d ${imageDimensions})
itk_wrap_template("CI${ITKM_VF${component}}${d}CI${ITKM_VF${component}}${d}IPIFCI${ITKM_VF${component}}${d}"
"itk::CudaImage<${ITKT_VF${component}}, ${d}>, itk::CudaImage<${ITKT_VF${component}}, ${d}>, itk::InPlaceImageFilter< itk::CudaImage<${ITKT_VF${component}}, ${d}> >")
endforeach()
foreach(component ${ITK_WRAP_VECTOR_COMPONENTS})
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_VF${component}}${d}CI${ITKM_VF${component}}${d}IPIFCI${ITKM_VF${component}}${d}"
"itk::CudaImage<${ITKT_VF${component}}, ${d}>, itk::CudaImage<${ITKT_VF${component}}, ${d}>, itk::InPlaceImageFilter< itk::CudaImage<${ITKT_VF${component}}, ${d}> >")
endforeach()
endforeach()

itk_end_wrap_class()

endif()
itk_end_wrap_class()
7 changes: 6 additions & 1 deletion wrapping/itkCudaSquareImageFilter.wrap
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
itk_wrap_class("itk::CudaSquareImageFilter" POINTER)
itk_wrap_image_filter("${WRAP_ITK_SCALAR}" 2)

foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_F}${d}CI${ITKM_F}${d}"
"itk::CudaImage<${ITKT_F}, ${d}>")
endforeach()

itk_end_wrap_class()

15 changes: 15 additions & 0 deletions wrapping/itkImageSourceCudaCommon.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
itk_wrap_include(itkCudaImage.h)

itk_wrap_class("itk::ImageSource" POINTER)

foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_F}${d}" "itk::CudaImage<${ITKT_F}, ${d}>")
endforeach()

foreach(component ${ITK_WRAP_VECTOR_COMPONENTS})
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_VF${component}}${d}" "itk::CudaImage<${ITKT_VF${component}}, ${d}>")
endforeach()
endforeach()

itk_end_wrap_class()
19 changes: 19 additions & 0 deletions wrapping/itkImageToImageFilterCudaCommon.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
itk_wrap_include(itkCudaImage.h)

itk_wrap_class("itk::ImageToImageFilter" POINTER)

foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_F}${d}CI${ITKM_F}${d}"
"itk::CudaImage<${ITKT_F}, ${d}>, itk::CudaImage<${ITKT_F}, ${d}>")
endforeach()

foreach(component ${ITK_WRAP_VECTOR_COMPONENTS})
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_VF${component}}${d}CI${ITKM_VF${component}}${d}"
"itk::CudaImage<${ITKT_VF${component}}, ${d}>, itk::CudaImage<${ITKT_VF${component}}, ${d}>")
endforeach()
endforeach()

itk_end_wrap_class()


18 changes: 18 additions & 0 deletions wrapping/itkInPlaceImageFilterCudaCommon.wrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
itk_wrap_include(itkCudaImage.h)

itk_wrap_class("itk::InPlaceImageFilter" POINTER)

foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_F}${d}" "itk::CudaImage<${ITKT_F}, ${d}>")
endforeach()

foreach(component ${ITK_WRAP_VECTOR_COMPONENTS})
foreach(d ${ITK_WRAP_IMAGE_DIMS})
itk_wrap_template("CI${ITKM_VF${component}}${d}" "itk::CudaImage<${ITKT_VF${component}}, ${d}>")
itk_wrap_template("CI${ITKM_VF${component}}${d}CI${ITKM_VF${component}}${d}"
"itk::CudaImage<${ITKT_VF${component}}, ${d}>, itk::CudaImage<${ITKT_VF${component}}, ${d}>")
endforeach()
endforeach()

itk_end_wrap_class()

0 comments on commit 095abb2

Please sign in to comment.