From 610ef01a85e363c19d6bc72124478a3d62fa0f26 Mon Sep 17 00:00:00 2001 From: cmoineau <cyril.moineau@cea.fr> Date: Wed, 4 Oct 2023 12:29:56 +0000 Subject: [PATCH] [OperatorImpl] Add pybind/stl include. --- CMakeLists.txt | 10 +++++----- python_binding/backend/pybind_OperatorImpl.cpp | 2 ++ python_binding/operator/pybind_Conv.cpp | 12 ++++++------ 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40d8837f4..f8dbe375e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,7 @@ file(READ "${CMAKE_SOURCE_DIR}/project_name.txt" project) message(STATUS "Project name: ${project}") message(STATUS "Project version: ${version}") -# Note : project name is {project} and python module name is also {project} +# Note : project name is {project} and python module name is also {project} set(module_name _${project}) # target name @@ -57,7 +57,7 @@ if (PYBIND) # Handles Python + pybind11 headers dependencies target_link_libraries(${module_name} - PUBLIC + PUBLIC pybind11::pybind11 PRIVATE Python::Python @@ -101,8 +101,8 @@ install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) install(EXPORT ${project}-targets FILE "${project}-targets.cmake" DESTINATION ${INSTALL_CONFIGDIR} -# COMPONENT ${module_name} -) +# COMPONENT ${module_name} +) #Create a ConfigVersion.cmake file include(CMakePackageConfigHelpers) @@ -136,4 +136,4 @@ export(EXPORT ${project}-targets if(TEST) enable_testing() add_subdirectory(unit_tests) -endif() \ No newline at end of file +endif() diff --git a/python_binding/backend/pybind_OperatorImpl.cpp b/python_binding/backend/pybind_OperatorImpl.cpp index 3a104f162..8eb9e2649 100644 --- a/python_binding/backend/pybind_OperatorImpl.cpp +++ b/python_binding/backend/pybind_OperatorImpl.cpp @@ -10,6 +10,8 @@ ********************************************************************************/ #include <pybind11/pybind11.h> +#include <pybind11/stl.h> + #include "aidge/backend/OperatorImpl.hpp" namespace py = pybind11; diff --git a/python_binding/operator/pybind_Conv.cpp b/python_binding/operator/pybind_Conv.cpp index 0c09917d7..6807520c5 100644 --- a/python_binding/operator/pybind_Conv.cpp +++ b/python_binding/operator/pybind_Conv.cpp @@ -11,7 +11,7 @@ #include <pybind11/pybind11.h> #include <pybind11/stl.h> - +#include <iostream> #include <string> #include <vector> #include <array> @@ -40,16 +40,16 @@ template <DimIdx_t DIM> void declare_ConvOp(py::module &m) { py::arg("stride_dims"), py::arg("padding_dims"), py::arg("dilation_dims")); - + m.def(("Conv" + std::to_string(DIM) + "D").c_str(), [](DimSize_t in_channels, DimSize_t out_channels, const std::vector<DimSize_t>& kernel_dims, - const std::string& name, + const std::string& name, const std::vector<DimSize_t> &stride_dims, const std::vector<DimSize_t> &padding_dims, const std::vector<DimSize_t> &dilation_dims) { // Lambda function wrapper because PyBind fails to convert const array. - // So we use a vector that we convert in this function to a const DimeSize_t [DIM] array. + // So we use a vector that we convert in this function to a const DimeSize_t [DIM] array. if (kernel_dims.size() != DIM) { throw std::runtime_error("kernel_dims size [" + std::to_string(kernel_dims.size()) + "] does not match DIM [" + std::to_string(DIM) +"]"); } @@ -90,7 +90,7 @@ template <DimIdx_t DIM> void declare_ConvOp(py::module &m) { py::arg("stride_dims") = std::vector<DimSize_t>(DIM,1), py::arg("padding_dims") = std::vector<DimSize_t>(DIM<<1,0), py::arg("dilation_dims") = std::vector<DimSize_t>(DIM,1)); - + } @@ -98,7 +98,7 @@ void init_Conv(py::module &m) { declare_ConvOp<1>(m); declare_ConvOp<2>(m); declare_ConvOp<3>(m); - + // FIXME: // m.def("Conv1D", static_cast<NodeAPI(*)(const char*, int, int, int const // (&)[1])>(&Conv)); -- GitLab