diff --git a/codegen/generate_wrappers.py b/codegen/generate_wrappers.py index d82b487667d592d0647d13008851f8b02dc2e7fe..e149093965a452e9ae15eb01bdc930ede6338e43 100644 --- a/codegen/generate_wrappers.py +++ b/codegen/generate_wrappers.py @@ -26,10 +26,13 @@ from pystencils_autodiff.framework_integration.printer import \ FrameworkIntegrationPrinter volume = pystencils.fields('volume: float32[3d]') -projection = pystencils.fields('projection: float32[2d]') +projection = pystencils.fields('projection: float32[3d]') projection_matrices = pystencils.fields('matrices: float32[3d]') inv_matrices = pystencils.fields('inv_matrices: float32[3d]') source_points = pystencils.fields('source_points: float32[1d]') +volume_slice = pystencils.fields('volume_slice: float32[2d]') +projections_1d = pystencils.fields('projections_1d: float32[2d]') +ray_vectors = pystencils.fields('ray_vectors: float32[2d]') FUNCTIONS = { 'Cone_Backprojection3D_Kernel_Launcher': CustomFunctionCall('Cone_Backprojection3D_Kernel_Launcher', @@ -45,7 +48,7 @@ FUNCTIONS = { TypedSymbol('volume_origin_x', create_type('float32'), const=True), TypedSymbol('volume_origin_y', create_type('float32'), const=True), TypedSymbol('volume_origin_z', create_type('float32'), const=True), - *[FieldShapeSymbol(['projection'], i) for i in range(1, -1, -1)], + *[FieldShapeSymbol(['projection'], i) for i in range(2, 0, -1)], TypedSymbol('projection_multiplier', create_type('float32'), const=True), fields_accessed=[volume, projection, projection_matrices], custom_signature=""" void Cone_Backprojection3D_Kernel_Launcher(const float *sinogram_ptr, float *out, const float *projection_matrices, const int number_of_projections, @@ -66,7 +69,7 @@ void Cone_Backprojection3D_Kernel_Launcher(const float *sinogram_ptr, float *out TypedSymbol('volume_spacing_x', create_type('float32'), const=True), TypedSymbol('volume_spacing_y', create_type('float32'), const=True), TypedSymbol('volume_spacing_z', create_type('float32'), const=True), - *[FieldShapeSymbol(['projection'], i) for i in range(1, -1, -1)], + *[FieldShapeSymbol(['projection'], i) for i in range(2, 0, -1)], TypedSymbol('step_size', create_type('float32'), const=True), fields_accessed=[volume, projection, inv_matrices, source_points], custom_signature=""" void Cone_Projection_Kernel_Launcher(const float* volume_ptr, float *out, const float *inv_AR_matrix, const float *src_points, @@ -86,7 +89,7 @@ void Cone_Projection_Kernel_Launcher(const float* volume_ptr, float *out, const TypedSymbol('volume_spacing_x', create_type('float32'), const=True), TypedSymbol('volume_spacing_y', create_type('float32'), const=True), TypedSymbol('volume_spacing_z', create_type('float32'), const=True), - *[FieldShapeSymbol(['projection'], i) for i in range(1, -1, -1)], + *[FieldShapeSymbol(['projection'], i) for i in range(2, 0, -1)], TypedSymbol('step_size', create_type('float32'), const=True), fields_accessed=[volume, projection, inv_matrices, source_points], custom_signature=""" void Cone_Projection_Kernel_Tex_Interp_Launcher( @@ -97,6 +100,49 @@ void Cone_Projection_Kernel_Tex_Interp_Launcher( const float volume_spacing_x, const float volume_spacing_y, const float volume_spacing_z, const int detector_width, const int detector_height, const float step_size);"""), # noqa +'Parallel_Projection2D_Kernel_Launcher': CustomFunctionCall('Parallel_Projection2D_Kernel_Launcher', + FieldPointerSymbol(volume_slice.name, volume_slice.dtype, const=True), + FieldPointerSymbol(projections_1d.name, projections_1d.dtype, const=False), + FieldPointerSymbol(ray_vectors.name, + ray_vectors.dtype, const=True), + FieldShapeSymbol([ray_vectors.name], 0), + *[FieldShapeSymbol(['volume_slice'], i) for i in range(1, -1, -1)], + TypedSymbol('volume_spacing_x', create_type('float32'), const=True), + TypedSymbol('volume_spacing_y', create_type('float32'), const=True), + TypedSymbol('volume_origin_x', create_type('float32'), const=True), + TypedSymbol('volume_origin_y', create_type('float32'), const=True), + FieldShapeSymbol([projections_1d.name], 1), + TypedSymbol('detector_spacing', create_type('float32'), const=True), + TypedSymbol('detector_origin', create_type('float32'), const=True), + fields_accessed=[volume_slice, projections_1d, ray_vectors], custom_signature=""" +void Parallel_Projection2D_Kernel_Launcher( + const float *volume_ptr, float *out, const float *ray_vectors, + const int number_of_projections, const int volume_width, + const int volume_height, const float volume_spacing_x, + const float volume_spacing_y, const float volume_origin_x, + const float volume_origin_y, const int detector_size, + const float detector_spacing, const float detector_origin); +"""), # noqa +'Parallel_Backprojection2D_Kernel_Launcher': CustomFunctionCall('Parallel_Backprojection2D_Kernel_Launcher', + FieldPointerSymbol(projections_1d.name, projections_1d.dtype, const=True), + FieldPointerSymbol(volume_slice.name, volume_slice.dtype, const=False), + FieldPointerSymbol(ray_vectors.name, + ray_vectors.dtype, const=True), + FieldShapeSymbol([ray_vectors.name], 0), + *[FieldShapeSymbol(['volume_slice'], i) for i in range(1, -1, -1)], + TypedSymbol('volume_spacing_x', create_type('float32'), const=True), + TypedSymbol('volume_spacing_y', create_type('float32'), const=True), + TypedSymbol('volume_origin_x', create_type('float32'), const=True), + TypedSymbol('volume_origin_y', create_type('float32'), const=True), + FieldShapeSymbol([projections_1d.name], 1), + TypedSymbol('detector_spacing', create_type('float32'), const=True), + TypedSymbol('detector_origin', create_type('float32'), const=True), + fields_accessed=[volume_slice, projections_1d, ray_vectors], custom_signature=""" +void Parallel_Backprojection2D_Kernel_Launcher(const float *sinogram_ptr, float *out, const float *ray_vectors, const int number_of_projections, + const int volume_width, const int volume_height, const float volume_spacing_x, const float volume_spacing_y, + const float volume_origin_x, const float volume_origin_y, + const int detector_size, const float detector_spacing, const float detector_origin); +"""), # noqa }