diff --git a/.gitlab/ci/test.gitlab-ci.yml b/.gitlab/ci/test.gitlab-ci.yml index 1e67ce273abc7d6b02f9e3148264ff3f9ea1cf07..924fd995aff34016cd4fa792a550d3d06db0449c 100644 --- a/.gitlab/ci/test.gitlab-ci.yml +++ b/.gitlab/ci/test.gitlab-ci.yml @@ -37,6 +37,7 @@ test:windows_cpp: - Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1')) # Install dependencies - choco install cmake.install --installargs '"ADD_CMAKE_TO_PATH=System"' -Y + - choco install python -Y # Update PATH - $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + [System.Environment]::GetEnvironmentVariable("Path","User") script: diff --git a/include/aidge/operator/Add.hpp b/include/aidge/operator/Add.hpp index c96b2c571f412124ccdfb83dde685e111448a222..ff3d1888c3bc70b61a3d4da42908d40de2d1d73e 100644 --- a/include/aidge/operator/Add.hpp +++ b/include/aidge/operator/Add.hpp @@ -141,7 +141,7 @@ public: }; template <std::size_t NUM> -inline std::shared_ptr<Node> Add(const char* name = nullptr) { +inline std::shared_ptr<Node> Add(const std::string& name = "") { return std::make_shared<Node>(std::make_shared<Add_Op<NUM>>(), name); } } diff --git a/include/aidge/operator/FC.hpp b/include/aidge/operator/FC.hpp index 6e4c54a030c108c29c08a8f5dfdc24d084ccc91c..db92dc9c735416d250fa32e2f9010b21b8f808c0 100644 --- a/include/aidge/operator/FC.hpp +++ b/include/aidge/operator/FC.hpp @@ -139,7 +139,7 @@ public: inline IOIndex_t nbOutputs() const noexcept override final { return 1; } }; -inline std::shared_ptr<Node> FC(DimSize_t out_channels, bool noBias = false, const char* name = nullptr) { +inline std::shared_ptr<Node> FC(DimSize_t out_channels, bool noBias = false, const std::string& name = "") { // FIXME: properly handle default w&b initialization in every cases auto fc = std::make_shared<Node>(std::make_shared<FC_Op>(out_channels, noBias), name); addProducer(fc, 1, {out_channels, 1}, "w"); diff --git a/include/aidge/operator/LeakyReLU.hpp b/include/aidge/operator/LeakyReLU.hpp index 64587d51de784082da455eb64aa5bbe175773b5d..1dff2550a42245351afab5b8bb1a708a8d0d8c0b 100644 --- a/include/aidge/operator/LeakyReLU.hpp +++ b/include/aidge/operator/LeakyReLU.hpp @@ -117,7 +117,7 @@ public: inline IOIndex_t nbOutputs() const noexcept override final { return 1; } }; -inline std::shared_ptr<Node> LeakyReLU(float negativeSlope = 0.0f, const char* name = nullptr) { +inline std::shared_ptr<Node> LeakyReLU(float negativeSlope = 0.0f, const std::string& name = "") { // FIXME: properly handle default w&b initialization in every cases return std::make_shared<Node>(std::make_shared<LeakyReLU_Op>(negativeSlope), name); } diff --git a/include/aidge/operator/Matmul.hpp b/include/aidge/operator/Matmul.hpp index b44e8a9b9540e287ff35af1c9642c8202fd096d0..639b366912060b3e085510f312d94568e6b65f03 100644 --- a/include/aidge/operator/Matmul.hpp +++ b/include/aidge/operator/Matmul.hpp @@ -129,7 +129,7 @@ public: inline IOIndex_t nbOutputs() const noexcept override final { return 1; } }; -inline std::shared_ptr<Node> Matmul(DimSize_t out_channels, const char* name = nullptr) { +inline std::shared_ptr<Node> Matmul(DimSize_t out_channels, const std::string& name = "") { // FIXME: properly handle default w&b initialization in every cases auto matmul = std::make_shared<Node>(std::make_shared<Matmul_Op>(out_channels), name); addProducer(matmul, 1, {1, out_channels}, "w"); diff --git a/include/aidge/operator/Producer.hpp b/include/aidge/operator/Producer.hpp index 1f77400ce8a8ef727ea9e0a7d12477c6519ea2df..2a2f8c05355bed4b10a5711deaefc96eac1c3571 100644 --- a/include/aidge/operator/Producer.hpp +++ b/include/aidge/operator/Producer.hpp @@ -128,17 +128,17 @@ inline std::shared_ptr<Node> Producer(const std::shared_ptr<Tensor> tensor, cons } template <std::array<DimSize_t, 1>::size_type DIM> -void addProducer(std::shared_ptr<Node>& otherNode, const IOIndex_t inputIdx, const std::array<DimSize_t, DIM>& dims, const char* extension) { +void addProducer(std::shared_ptr<Node>& otherNode, const IOIndex_t inputIdx, const std::array<DimSize_t, DIM>& dims, const std::string& extension) { assert(inputIdx != gk_IODefaultIndex); static_assert(DIM<=MaxDim,"Too many tensor dimensions required by addProducer, not supported"); - const char* prodName = otherNode->name().empty() ? nullptr : (otherNode->name() + std::string("_") + std::string(extension)).c_str(); + const std::string prodName = (otherNode->name().empty()) ? "" : (otherNode->name() + std::string("_") + extension); auto prod = Producer(dims, prodName); prod->addChild(otherNode, 0, inputIdx); otherNode->getOperator()->associateInput(inputIdx, prod->getOperator()->getRawOutput(0)); } template <std::size_t DIM> -void addProducer(std::shared_ptr<Node>& otherNode, const IOIndex_t inputIdx, DimSize_t const (&dims)[DIM], const char* extension) { +void addProducer(std::shared_ptr<Node>& otherNode, const IOIndex_t inputIdx, DimSize_t const (&dims)[DIM], const std::string& extension) { addProducer(otherNode, inputIdx, to_array(dims), extension); } } // namespace Aidge diff --git a/include/aidge/operator/ReLU.hpp b/include/aidge/operator/ReLU.hpp index 3ea90462cf2b083a1a61ae39be06471093ec9f9f..141bd3ae12c7875a90d2549a24e5c141f3ff6aba 100644 --- a/include/aidge/operator/ReLU.hpp +++ b/include/aidge/operator/ReLU.hpp @@ -106,7 +106,7 @@ public: inline IOIndex_t nbOutputs() const noexcept override final { return 1; } }; -inline std::shared_ptr<Node> ReLU(const char* name = nullptr) { +inline std::shared_ptr<Node> ReLU(const std::string& name = "") { // FIXME: properly handle default w&b initialization in every cases return std::make_shared<Node>(std::make_shared<ReLU_Op>(), name); } diff --git a/include/aidge/operator/Softmax.hpp b/include/aidge/operator/Softmax.hpp index 93eb262f703ca7eb385641c77df7ae7e79c00b96..64e713b331bbbbf612ee5102ba0ea82fb108350e 100644 --- a/include/aidge/operator/Softmax.hpp +++ b/include/aidge/operator/Softmax.hpp @@ -106,7 +106,7 @@ public: inline IOIndex_t nbOutputs() const noexcept override final { return 1; } }; -inline std::shared_ptr<Node> Softmax(const char* name = nullptr) { +inline std::shared_ptr<Node> Softmax(const std::string& name = "") { // FIXME: properly handle default w&b initialization in every cases return std::make_shared<Node>(std::make_shared<Softmax_Op>(), name); } diff --git a/python_binding/operator/pybind_AvgPooling.cpp b/python_binding/operator/pybind_AvgPooling.cpp index 66dadba7244a199bd4ca8a0dd814f20a8049a62f..ecbb743d33cc5750bc60aeed8e5207dcec0c23dc 100644 --- a/python_binding/operator/pybind_AvgPooling.cpp +++ b/python_binding/operator/pybind_AvgPooling.cpp @@ -37,10 +37,10 @@ template <DimIdx_t DIM> void declare_AvgPoolingOp(py::module &m) { py::arg("stride_dims"), py::arg("padding_dims")); - m.def(("AvgPooling" + std::to_string(DIM) + "D").c_str(), [](std::vector<DimSize_t>& kernel_dims, - const char* name, - std::vector<DimSize_t> &stride_dims, - std::vector<DimSize_t> &padding_dims) { + m.def(("AvgPooling" + std::to_string(DIM) + "D").c_str(), [](const std::vector<DimSize_t>& kernel_dims, + const std::string& name, + const std::vector<DimSize_t> &stride_dims, + const std::vector<DimSize_t> &padding_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. if (kernel_dims.size() != DIM) { @@ -69,7 +69,7 @@ template <DimIdx_t DIM> void declare_AvgPoolingOp(py::module &m) { const DimSize_t (&padding_dims_array)[DIM<<1] = tmp_padding_dims_array; return AvgPooling<DIM>(to_array(kernel_dims_array), name, to_array(stride_dims_array), to_array(padding_dims_array)); }, py::arg("kernel_dims"), - py::arg("name") = nullptr, + py::arg("name") = "", py::arg("stride_dims") = std::vector<DimSize_t>(DIM,1), py::arg("padding_dims") = std::vector<DimSize_t>(DIM<<1,0)); diff --git a/python_binding/operator/pybind_Conv.cpp b/python_binding/operator/pybind_Conv.cpp index 3cf5d818f9b6e3bdfaf9a2d0b74ec0480beb6967..7e366305f287e958ea7500695c1f3285908017b1 100644 --- a/python_binding/operator/pybind_Conv.cpp +++ b/python_binding/operator/pybind_Conv.cpp @@ -44,11 +44,11 @@ template <DimIdx_t DIM> void declare_ConvOp(py::module &m) { m.def(("Conv" + std::to_string(DIM) + "D").c_str(), [](DimSize_t in_channels, DimSize_t out_channels, - std::vector<DimSize_t>& kernel_dims, - const char* name, - std::vector<DimSize_t> &stride_dims, - std::vector<DimSize_t> &padding_dims, - std::vector<DimSize_t> &dilation_dims) { + const std::vector<DimSize_t>& kernel_dims, + 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. if (kernel_dims.size() != DIM) { @@ -87,7 +87,7 @@ template <DimIdx_t DIM> void declare_ConvOp(py::module &m) { }, py::arg("in_channels"), py::arg("out_channels"), py::arg("kernel_dims"), - py::arg("name") = nullptr, + py::arg("name") = "", 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)); diff --git a/python_binding/operator/pybind_ConvDepthWise.cpp b/python_binding/operator/pybind_ConvDepthWise.cpp index b64409bdbb5f094e85cb094017a6fb837893a2db..8a81e7ba184536cbd535db24519495400bce6fdb 100644 --- a/python_binding/operator/pybind_ConvDepthWise.cpp +++ b/python_binding/operator/pybind_ConvDepthWise.cpp @@ -39,11 +39,11 @@ template <DimIdx_t DIM> void declare_ConvDepthWiseOp(py::module &m) { py::arg("padding_dims"), py::arg("dilation_dims")); - m.def(("ConvDepthWise" + std::to_string(DIM) + "D").c_str(), [](std::vector<DimSize_t>& kernel_dims, - const char* name, - std::vector<DimSize_t> &stride_dims, - std::vector<DimSize_t> &padding_dims, - std::vector<DimSize_t> &dilation_dims) { + m.def(("ConvDepthWise" + std::to_string(DIM) + "D").c_str(), [](const std::vector<DimSize_t>& kernel_dims, + 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. if (kernel_dims.size() != DIM) { @@ -80,7 +80,7 @@ template <DimIdx_t DIM> void declare_ConvDepthWiseOp(py::module &m) { const DimSize_t (&dilation_dims_array)[DIM] = tmp_dilation_dims_array; return ConvDepthWise<DIM>(to_array(kernel_dims_array), name, to_array(stride_dims_array), to_array(padding_dims_array), to_array(dilation_dims_array)); }, py::arg("kernel_dims"), - py::arg("name") = nullptr, + py::arg("name") = "", 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)); diff --git a/python_binding/operator/pybind_Producer.cpp b/python_binding/operator/pybind_Producer.cpp index 5757891a30c5b40dcfa5ff99b1f06e00376f475a..ea9880800059e8993996e67138f89419c165fc4f 100644 --- a/python_binding/operator/pybind_Producer.cpp +++ b/python_binding/operator/pybind_Producer.cpp @@ -25,7 +25,7 @@ namespace Aidge { template <DimIdx_t DIM> void declare_Producer(py::module &m) { // m.def(("Producer_" + std::to_string(DIM)+"D").c_str(), py::overload_cast<shared_ptr<Node>&>(&Producer<DIM>), py::arg("dims"), py::arg("name")); - m.def("Producer", static_cast<std::shared_ptr<Node>(*)(const std::array<DimSize_t, DIM>&, const char*)>(&Producer), py::arg("dims"), py::arg("name") = nullptr); + m.def("Producer", static_cast<std::shared_ptr<Node>(*)(const std::array<DimSize_t, DIM>&, const std::string&)>(&Producer), py::arg("dims"), py::arg("name") = ""); } @@ -36,7 +36,7 @@ void init_Producer(py::module &m) { "ProducerOp", py::multiple_inheritance()) .def("dims", &Producer_Op::dims); - m.def("Producer", static_cast<std::shared_ptr<Node>(*)(const std::shared_ptr<Tensor>, const char*)>(&Producer), py::arg("tensor"), py::arg("name") = nullptr); + m.def("Producer", static_cast<std::shared_ptr<Node>(*)(const std::shared_ptr<Tensor>, const std::string&)>(&Producer), py::arg("tensor"), py::arg("name") = ""); declare_Producer<1>(m); declare_Producer<2>(m); diff --git a/src/scheduler/Scheduler.cpp b/src/scheduler/Scheduler.cpp index fce46397ffd286a2ddbe254752b241578415e3d8..def7185f47f95aaddff95a975cc01e87bbcfb118 100644 --- a/src/scheduler/Scheduler.cpp +++ b/src/scheduler/Scheduler.cpp @@ -20,7 +20,7 @@ #include "aidge/graph/Node.hpp" #include "aidge/utils/Types.h" -void drawProgressBar(double progress, int barWidth, const char* additionalInfo = nullptr) { +void drawProgressBar(double progress, int barWidth, const std::string& additionalInfo = "") { putchar('['); int pos = static_cast<int>(barWidth * progress); for (int i = 0; i < barWidth; ++i) { @@ -29,7 +29,7 @@ void drawProgressBar(double progress, int barWidth, const char* additionalInfo = else putchar(' '); } - printf("] %d%% | %s\r", static_cast<int>(progress * 100), (additionalInfo ? additionalInfo : "")); + printf("] %d%% | %s\r", static_cast<int>(progress * 100), additionalInfo); fflush(stdout); } @@ -122,8 +122,7 @@ void Aidge::SequentialScheduler::forward(bool frowardDims, bool verbose) { else drawProgressBar(static_cast<float>(computationOver.size()) / static_cast<float>(computationNumber), 50, (std::string("running ") + runnable->type() + "_" + - std::to_string(reinterpret_cast<uintptr_t>(runnable.get()))) - .c_str()); + std::to_string(reinterpret_cast<uintptr_t>(runnable.get())))); const auto tStart = std::chrono::high_resolution_clock::now(); runnable->forward(); const auto tEnd = std::chrono::high_resolution_clock::now();