From 7bb394054dce714bca7e5aeffefc3219a4950333 Mon Sep 17 00:00:00 2001
From: Jerome Hue <jerome.hue@cea.fr>
Date: Tue, 25 Feb 2025 10:32:38 +0100
Subject: [PATCH] Add python binding for spikegen rate function

---
 python_binding/data/pybind_Spikegen.cpp | 26 +++++++++++++++++++++++++
 python_binding/pybind_core.cpp          |  3 +++
 2 files changed, 29 insertions(+)
 create mode 100644 python_binding/data/pybind_Spikegen.cpp

diff --git a/python_binding/data/pybind_Spikegen.cpp b/python_binding/data/pybind_Spikegen.cpp
new file mode 100644
index 000000000..de4636bb2
--- /dev/null
+++ b/python_binding/data/pybind_Spikegen.cpp
@@ -0,0 +1,26 @@
+/********************************************************************************
+ * Copyright (c) 2025 CEA-List
+ *
+ * This program and the accompanying materials are made available under
+ * the terms of the Eclipse Public License 2.0 which is available at
+ * http://www.eclipse.org/legal/epl-2.0.
+ *
+ * SPDX-License-Identifier: EPL-2.0
+ *
+ ********************************************************************************/
+
+#include <pybind11/pybind11.h>
+
+#include "aidge/data/Spikegen.hpp"
+#include "aidge/data/Tensor.hpp"
+
+namespace py = pybind11;
+namespace Aidge {
+
+void init_Spikegen(py::module &m) {
+    m.def("spikegen_rate", &spikegenRate,
+          py::arg("tensor"), py::arg("numSteps"),
+          "Performs spike rate encoding on a Tensor");
+}
+
+} // namespace Aidge
diff --git a/python_binding/pybind_core.cpp b/python_binding/pybind_core.cpp
index ef1111b39..e9e246ad1 100644
--- a/python_binding/pybind_core.cpp
+++ b/python_binding/pybind_core.cpp
@@ -32,8 +32,10 @@ void init_OperatorImpl(py::module&);
 void init_Log(py::module&);
 void init_Operator(py::module&);
 void init_OperatorTensor(py::module&);
+void init_Spikegen(py::module&);
 void init_StaticAnalysis(py::module&);
 
+
 void init_Abs(py::module&);
 void init_Add(py::module&);
 void init_And(py::module&);
@@ -122,6 +124,7 @@ void init_Aidge(py::module& m) {
     init_Tensor(m);
     init_TensorImpl(m);
     init_Attributes(m);
+    init_Spikegen(m);
 
     init_Node(m);
     init_GraphView(m);
-- 
GitLab