Skip to content

Commit

Permalink
ENH: Add support for vector types in cuda array interface
Browse files Browse the repository at this point in the history
  • Loading branch information
LucasGandel committed Sep 5, 2024
1 parent bab6908 commit ddf2c11
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 11 additions & 1 deletion wrapping/CudaImage.i.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@

_itksize = self.GetBufferedRegion().GetSize()
_dim = len(_itksize)
_shape = tuple(int(_itksize[idx]) for idx in range(_dim))
_shape = [int(_itksize[idx]) for idx in range(_dim)]

if self.GetNumberOfComponentsPerPixel() > 1:
_shape = [self.GetNumberOfComponentsPerPixel(), ] + _shape

# Reverse array to force C-order indexing. This is the reverse of how
# indices are specified in ITK, i.e. k,j,i versus i,j,k. However
# C-order indexing is expected by most algorithms in NumPy / SciPy.
_shape.reverse()
_shape = tuple(_shape)

return {
'shape': _shape,
'data': (int(self.GetCudaDataManager().GetGPUBufferPointer()), False),
Expand Down
6 changes: 5 additions & 1 deletion wrapping/itkCudaImage.wrap
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ itk_wrap_class("itk::CudaImage" POINTER_WITH_CONST_POINTER)
foreach(c ${ITK_WRAP_VECTOR_COMPONENTS})
foreach(d ${ITK_WRAP_IMAGE_DIMS})
foreach(vt ${vector_types})
itk_wrap_template("${ITKM_${vt}${c}}${d}" "${ITKT_${vt}${c}}, ${d}")
itk_wrap_template("${ITKM_${vt}${c}}${d}" "${ITKT_${vt}${c}}, ${d}")
set(CudaImageTypes ${ITKM_${vt}${c}}${d})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CudaImage.i.in ${CMAKE_CURRENT_BINARY_DIR}/CudaImage.i.temp @ONLY)
file(READ ${CMAKE_CURRENT_BINARY_DIR}/CudaImage.i.temp CudaImageInterfaceTemp)
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/CudaImage.i ${CudaImageInterfaceTemp})
endforeach()
endforeach()
endforeach()
Expand Down

0 comments on commit ddf2c11

Please sign in to comment.