From ccb957427c74c9f226ffce68cc86a3f0de1b5992 Mon Sep 17 00:00:00 2001
From: Vincent TEMPLIER <vincent.templier@cea.fr>
Date: Wed, 26 Jul 2023 07:54:02 +0000
Subject: [PATCH] Change ref_cpp reference to cpu in Core library

---
 aidge/_Core/include/data/Tensor.hpp              | 16 ++++++++--------
 .../_Core/python_binding/data/pybind_Tensor.cpp  |  4 ++--
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/aidge/_Core/include/data/Tensor.hpp b/aidge/_Core/include/data/Tensor.hpp
index d6e8f303..1aaaff60 100644
--- a/aidge/_Core/include/data/Tensor.hpp
+++ b/aidge/_Core/include/data/Tensor.hpp
@@ -139,7 +139,7 @@ class Tensor : public Data,
         : Data(Type),
           mDims({SIZE_0}),
           mDataType(NativeType<T>::type),
-          mImpl(Registrar<Tensor>::create({"ref_cpp", NativeType<T>::type})(*this)),
+          mImpl(Registrar<Tensor>::create({"cpu", NativeType<T>::type})(*this)),
           mSize(SIZE_0),
           mSizeM1(SIZE_0) {
         mImpl->copy(&arr.data[0], SIZE_0);
@@ -149,7 +149,7 @@ class Tensor : public Data,
     constexpr Tensor &operator=(Array1D<T, SIZE_0> &&arr) {
         resize({SIZE_0});
         if (!mImpl) {
-            mImpl = Registrar<Tensor>::create({"ref_cpp", NativeType<T>::type})(*this);
+            mImpl = Registrar<Tensor>::create({"cpu", NativeType<T>::type})(*this);
         }
         mImpl->copy(&arr.data[0], SIZE_0);
         return *this;
@@ -159,7 +159,7 @@ class Tensor : public Data,
         : Data(Type),
           mDims({SIZE_0, SIZE_1}),
           mDataType(NativeType<T>::type),
-          mImpl(Registrar<Tensor>::create({"ref_cpp", NativeType<T>::type})(*this)),
+          mImpl(Registrar<Tensor>::create({"cpu", NativeType<T>::type})(*this)),
           mSize(SIZE_0 * SIZE_1),
           mSizeM1(SIZE_1) {
         mImpl->copy(&arr.data[0][0], SIZE_0 * SIZE_1);
@@ -169,7 +169,7 @@ class Tensor : public Data,
     constexpr Tensor &operator=(Array2D<T, SIZE_0, SIZE_1> &&arr) {
         resize({SIZE_0, SIZE_1});
         if (!mImpl) {
-            mImpl = Registrar<Tensor>::create({"ref_cpp", NativeType<T>::type})(*this);
+            mImpl = Registrar<Tensor>::create({"cpu", NativeType<T>::type})(*this);
         }
         mImpl->copy(&arr.data[0][0], SIZE_0 * SIZE_1);
         return *this;
@@ -179,7 +179,7 @@ class Tensor : public Data,
         : Data(Type),
           mDims({SIZE_0, SIZE_1, SIZE_2}),
           mDataType(NativeType<T>::type),
-          mImpl(Registrar<Tensor>::create({"ref_cpp", NativeType<T>::type})(*this)),
+          mImpl(Registrar<Tensor>::create({"cpu", NativeType<T>::type})(*this)),
           mSize(SIZE_0 * SIZE_1 * SIZE_2),
           mSizeM1(SIZE_1 * SIZE_2) {
         mImpl->copy(&arr.data[0][0][0], SIZE_0 * SIZE_1 * SIZE_2);
@@ -189,7 +189,7 @@ class Tensor : public Data,
     constexpr Tensor &operator=(Array3D<T, SIZE_0, SIZE_1, SIZE_2> &&arr) {
         resize({SIZE_0, SIZE_1, SIZE_2});
         if (!mImpl) {
-            mImpl = Registrar<Tensor>::create({"ref_cpp", NativeType<T>::type})(*this);
+            mImpl = Registrar<Tensor>::create({"cpu", NativeType<T>::type})(*this);
         }
         mImpl->copy(&arr.data[0][0][0], SIZE_0 * SIZE_1 * SIZE_2);
         return *this;
@@ -199,7 +199,7 @@ class Tensor : public Data,
         : Data(Type),
           mDims({SIZE_0, SIZE_1, SIZE_2, SIZE_3}),
           mDataType(NativeType<T>::type),
-          mImpl(Registrar<Tensor>::create({"ref_cpp", NativeType<T>::type})(*this)),
+          mImpl(Registrar<Tensor>::create({"cpu", NativeType<T>::type})(*this)),
           mSize(SIZE_0 * SIZE_1 * SIZE_2 * SIZE_3),
           mSizeM1(SIZE_1 * SIZE_2 * SIZE_3) {
         mImpl->copy(&arr.data[0][0][0][0], SIZE_0 * SIZE_1 * SIZE_2 * SIZE_3);
@@ -209,7 +209,7 @@ class Tensor : public Data,
     constexpr Tensor &operator=(Array4D<T, SIZE_0, SIZE_1, SIZE_2, SIZE_3> &&arr) {
         resize({SIZE_0, SIZE_1, SIZE_2, SIZE_3});
         if (!mImpl) {
-            mImpl = Registrar<Tensor>::create({"ref_cpp", NativeType<T>::type})(*this);
+            mImpl = Registrar<Tensor>::create({"cpu", NativeType<T>::type})(*this);
         }
         mImpl->copy(&arr.data[0][0][0][0], SIZE_0 * SIZE_1 * SIZE_2 * SIZE_3);
         return *this;
diff --git a/aidge/_Core/python_binding/data/pybind_Tensor.cpp b/aidge/_Core/python_binding/data/pybind_Tensor.cpp
index 7342b225..9b8a228c 100644
--- a/aidge/_Core/python_binding/data/pybind_Tensor.cpp
+++ b/aidge/_Core/python_binding/data/pybind_Tensor.cpp
@@ -39,8 +39,8 @@ void addCtor(py::class_<Tensor,
         newTensor->resize(dims);
         // TODO : Find a better way to choose backend
         std::set<std::string> availableBackends = Tensor::getAvailableBackends();
-        if (availableBackends.find("ref_cpp") != availableBackends.end()){
-            newTensor->setBackend("ref_cpp");
+        if (availableBackends.find("cpu") != availableBackends.end()){
+            newTensor->setBackend("cpu");
             newTensor->getImpl()->setRawPtr(static_cast<T*>(info.ptr));
         }else{
             printf("Warning : Could not use aidge_ref_cpp backend, verify you have `import aidge_ref_cpp`\n");
-- 
GitLab