mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-06-05 01:58:40 +02:00
Format CUDA cluster finder files
This commit is contained in:
@@ -27,19 +27,15 @@ void define_ClusterFinderCUDA(py::module &m, const std::string &typestr) {
|
||||
auto class_name = fmt::format("ClusterFinderCUDA_{}", typestr);
|
||||
|
||||
using ClusterType = Cluster<T, ClusterSizeX, ClusterSizeY, CoordType>;
|
||||
using CF = ClusterFinderCUDA<ClusterType, uint16_t, pd_type>;
|
||||
using CF = ClusterFinderCUDA<ClusterType, uint16_t, pd_type>;
|
||||
|
||||
py::class_<CF>(m, class_name.c_str())
|
||||
.def(py::init<Shape<2>, pd_type, size_t, int>(),
|
||||
py::arg("image_size"),
|
||||
py::arg("n_sigma") = 5.0,
|
||||
py::arg("capacity") = 1'000'000,
|
||||
py::arg("n_streams") = 1)
|
||||
.def(py::init<Shape<2>, pd_type, size_t, int>(), py::arg("image_size"),
|
||||
py::arg("n_sigma") = 5.0, py::arg("capacity") = 1'000'000,
|
||||
py::arg("n_streams") = 1)
|
||||
|
||||
.def_property(
|
||||
"nSigma",
|
||||
&CF::get_nSigma,
|
||||
&CF::set_nSigma,
|
||||
"nSigma", &CF::get_nSigma, &CF::set_nSigma,
|
||||
R"(Number of sigma above the pedestal to consider a photon during cluster finding.)")
|
||||
|
||||
.def("push_pedestal_frame",
|
||||
@@ -50,21 +46,19 @@ void define_ClusterFinderCUDA(py::module &m, const std::string &typestr) {
|
||||
|
||||
.def("clear_pedestal", &CF::clear_pedestal)
|
||||
|
||||
.def_property_readonly(
|
||||
"pedestal",
|
||||
[](CF &self) {
|
||||
auto pd = new NDArray<pd_type, 2>{};
|
||||
*pd = self.pedestal();
|
||||
return return_image_data(pd);
|
||||
})
|
||||
.def_property_readonly("pedestal",
|
||||
[](CF &self) {
|
||||
auto pd = new NDArray<pd_type, 2>{};
|
||||
*pd = self.pedestal();
|
||||
return return_image_data(pd);
|
||||
})
|
||||
|
||||
.def_property_readonly(
|
||||
"noise",
|
||||
[](CF &self) {
|
||||
auto arr = new NDArray<pd_type, 2>{};
|
||||
*arr = self.noise();
|
||||
return return_image_data(arr);
|
||||
})
|
||||
.def_property_readonly("noise",
|
||||
[](CF &self) {
|
||||
auto arr = new NDArray<pd_type, 2>{};
|
||||
*arr = self.noise();
|
||||
return return_image_data(arr);
|
||||
})
|
||||
|
||||
.def(
|
||||
"steal_clusters",
|
||||
@@ -86,7 +80,8 @@ void define_ClusterFinderCUDA(py::module &m, const std::string &typestr) {
|
||||
.def(
|
||||
"find_clusters_batched",
|
||||
[](CF &self, py::array_t<uint16_t> frames, uint64_t first_frame) {
|
||||
// frames is expected as a 3D numpy array (n_frames, nrows, ncols)
|
||||
// frames is expected as a 3D numpy array (n_frames, nrows,
|
||||
// ncols)
|
||||
auto view = make_view_3d(frames);
|
||||
return self.find_clusters_batched(view, first_frame);
|
||||
},
|
||||
|
||||
@@ -30,8 +30,7 @@ void define_ClusterVector(py::module &m, const std::string &typestr) {
|
||||
|
||||
py::class_<ClusterVector<
|
||||
Cluster<Type, ClusterSizeX, ClusterSizeY, CoordType>, void>>(
|
||||
m, class_name.c_str(),
|
||||
py::buffer_protocol(),
|
||||
m, class_name.c_str(), py::buffer_protocol(),
|
||||
py::module_local())
|
||||
|
||||
.def(py::init()) // TODO change!!!
|
||||
|
||||
+19
-19
@@ -6,8 +6,8 @@
|
||||
// back a usable ClusterVector without _aare needing to be imported first.
|
||||
|
||||
#include "bind_Cluster.hpp"
|
||||
#include "bind_ClusterVector.hpp"
|
||||
#include "bind_ClusterFinderCUDA.hpp"
|
||||
#include "bind_ClusterVector.hpp"
|
||||
|
||||
#include <pybind11/pybind11.h>
|
||||
|
||||
@@ -22,45 +22,45 @@ namespace py = pybind11;
|
||||
define_Cluster<T, N, M, U>(m, #N "x" #M #TYPE_CODE);
|
||||
|
||||
#define DEFINE_BINDINGS_CLUSTERFINDER_CUDA(T, N, M, U, TYPE_CODE) \
|
||||
aare::define_ClusterFinderCUDA<T, N, M, U>( \
|
||||
m, "Cluster" #N "x" #M #TYPE_CODE);
|
||||
aare::define_ClusterFinderCUDA<T, N, M, U>(m, "Cluster" #N \
|
||||
"x" #M #TYPE_CODE);
|
||||
|
||||
PYBIND11_MODULE(_aare_cuda, m) {
|
||||
|
||||
// Types first — finders reference them in their signatures.
|
||||
// SFINAE excludes 2x2 on ClusterFinderCUDA, so we skip it here too.
|
||||
DEFINE_CUDA_CLUSTER_TYPES(int, 3, 3, uint16_t, i);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(int, 3, 3, uint16_t, i);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(double, 3, 3, uint16_t, d);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(float, 3, 3, uint16_t, f);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(float, 3, 3, uint16_t, f);
|
||||
|
||||
DEFINE_CUDA_CLUSTER_TYPES(int, 5, 5, uint16_t, i);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(int, 5, 5, uint16_t, i);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(double, 5, 5, uint16_t, d);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(float, 5, 5, uint16_t, f);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(float, 5, 5, uint16_t, f);
|
||||
|
||||
DEFINE_CUDA_CLUSTER_TYPES(int, 7, 7, uint16_t, i);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(int, 7, 7, uint16_t, i);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(double, 7, 7, uint16_t, d);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(float, 7, 7, uint16_t, f);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(float, 7, 7, uint16_t, f);
|
||||
|
||||
DEFINE_CUDA_CLUSTER_TYPES(int, 9, 9, uint16_t, i);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(int, 9, 9, uint16_t, i);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(double, 9, 9, uint16_t, d);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(float, 9, 9, uint16_t, f);
|
||||
DEFINE_CUDA_CLUSTER_TYPES(float, 9, 9, uint16_t, f);
|
||||
|
||||
// Finders
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(int, 3, 3, uint16_t, i);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(int, 3, 3, uint16_t, i);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(double, 3, 3, uint16_t, d);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(float, 3, 3, uint16_t, f);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(float, 3, 3, uint16_t, f);
|
||||
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(int, 5, 5, uint16_t, i);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(int, 5, 5, uint16_t, i);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(double, 5, 5, uint16_t, d);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(float, 5, 5, uint16_t, f);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(float, 5, 5, uint16_t, f);
|
||||
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(int, 7, 7, uint16_t, i);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(int, 7, 7, uint16_t, i);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(double, 7, 7, uint16_t, d);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(float, 7, 7, uint16_t, f);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(float, 7, 7, uint16_t, f);
|
||||
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(int, 9, 9, uint16_t, i);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(int, 9, 9, uint16_t, i);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(double, 9, 9, uint16_t, d);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(float, 9, 9, uint16_t, f);
|
||||
DEFINE_BINDINGS_CLUSTERFINDER_CUDA(float, 9, 9, uint16_t, f);
|
||||
}
|
||||
|
||||
#undef DEFINE_CUDA_CLUSTER_TYPES
|
||||
|
||||
Reference in New Issue
Block a user