Skip to content
Snippets Groups Projects
Commit b4286319 authored by Cyril Moineau's avatar Cyril Moineau
Browse files

Fix numpy -> tensor with latest tensorImpl changes (copyFromHost instead of...

Fix numpy -> tensor with latest tensorImpl changes (copyFromHost instead of setRawPtr) + Use of std::int32_t instead of in and std::int64_t instead of long to fit Data.hpp convention.
parent cb229c42
No related branches found
No related tags found
1 merge request!67dev
Pipeline #36797 passed
...@@ -42,7 +42,7 @@ void addCtor(py::class_<Tensor, ...@@ -42,7 +42,7 @@ void addCtor(py::class_<Tensor,
std::set<std::string> availableBackends = Tensor::getAvailableBackends(); std::set<std::string> availableBackends = Tensor::getAvailableBackends();
if (availableBackends.find("cpu") != availableBackends.end()){ if (availableBackends.find("cpu") != availableBackends.end()){
newTensor->setBackend("cpu"); newTensor->setBackend("cpu");
newTensor->getImpl()->setRawPtr(static_cast<T*>(info.ptr), newTensor->size()); newTensor->getImpl()->copyFromHost(static_cast<T*>(info.ptr), newTensor->size());
}else{ }else{
printf("Warning : Could not use aidge_cpu backend, verify you have `import aidge_cpu`\n"); printf("Warning : Could not use aidge_cpu backend, verify you have `import aidge_cpu`\n");
} }
...@@ -95,9 +95,9 @@ void init_Tensor(py::module& m){ ...@@ -95,9 +95,9 @@ void init_Tensor(py::module& m){
case DataType::Float32: case DataType::Float32:
return py::cast(b.get<float>(idx)); return py::cast(b.get<float>(idx));
case DataType::Int32: case DataType::Int32:
return py::cast(b.get<int>(idx)); return py::cast(b.get<std::int32_t>(idx));
case DataType::Int64: case DataType::Int64:
return py::cast(b.get<long>(idx)); return py::cast(b.get<std::int64_t>(idx));
default: default:
return py::none(); return py::none();
} }
...@@ -110,9 +110,9 @@ void init_Tensor(py::module& m){ ...@@ -110,9 +110,9 @@ void init_Tensor(py::module& m){
case DataType::Float32: case DataType::Float32:
return py::cast(b.get<float>(coordIdx)); return py::cast(b.get<float>(coordIdx));
case DataType::Int32: case DataType::Int32:
return py::cast(b.get<int>(coordIdx)); return py::cast(b.get<std::int32_t>(coordIdx));
case DataType::Int64: case DataType::Int64:
return py::cast(b.get<long>(coordIdx)); return py::cast(b.get<std::int64_t>(coordIdx));
default: default:
return py::none(); return py::none();
} }
...@@ -141,10 +141,10 @@ void init_Tensor(py::module& m){ ...@@ -141,10 +141,10 @@ void init_Tensor(py::module& m){
dataFormatDescriptor = py::format_descriptor<float>::format(); dataFormatDescriptor = py::format_descriptor<float>::format();
break; break;
case DataType::Int32: case DataType::Int32:
dataFormatDescriptor = py::format_descriptor<int>::format(); dataFormatDescriptor = py::format_descriptor<std::int32_t>::format();
break; break;
case DataType::Int64: case DataType::Int64:
dataFormatDescriptor = py::format_descriptor<long>::format(); dataFormatDescriptor = py::format_descriptor<std::int64_t>::format();
break; break;
default: default:
throw py::value_error("Unsupported data format"); throw py::value_error("Unsupported data format");
...@@ -162,8 +162,8 @@ void init_Tensor(py::module& m){ ...@@ -162,8 +162,8 @@ void init_Tensor(py::module& m){
// TODO : If the ctor with the right data type does not exist, pybind will always convert the data to INT ! // TODO : If the ctor with the right data type does not exist, pybind will always convert the data to INT !
// Need to find a way to avoid this ! // Need to find a way to avoid this !
addCtor<int>(pyClassTensor); addCtor<std::int32_t>(pyClassTensor);
addCtor<long>(pyClassTensor); addCtor<std::int64_t>(pyClassTensor);
addCtor<float>(pyClassTensor); addCtor<float>(pyClassTensor);
// #if SIZE_MAX != 0xFFFFFFFF // #if SIZE_MAX != 0xFFFFFFFF
addCtor<double>(pyClassTensor); addCtor<double>(pyClassTensor);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment