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
No related merge requests found
......@@ -42,7 +42,7 @@ void addCtor(py::class_<Tensor,
std::set<std::string> availableBackends = Tensor::getAvailableBackends();
if (availableBackends.find("cpu") != availableBackends.end()){
newTensor->setBackend("cpu");
newTensor->getImpl()->setRawPtr(static_cast<T*>(info.ptr), newTensor->size());
newTensor->getImpl()->copyFromHost(static_cast<T*>(info.ptr), newTensor->size());
}else{
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){
case DataType::Float32:
return py::cast(b.get<float>(idx));
case DataType::Int32:
return py::cast(b.get<int>(idx));
return py::cast(b.get<std::int32_t>(idx));
case DataType::Int64:
return py::cast(b.get<long>(idx));
return py::cast(b.get<std::int64_t>(idx));
default:
return py::none();
}
......@@ -110,9 +110,9 @@ void init_Tensor(py::module& m){
case DataType::Float32:
return py::cast(b.get<float>(coordIdx));
case DataType::Int32:
return py::cast(b.get<int>(coordIdx));
return py::cast(b.get<std::int32_t>(coordIdx));
case DataType::Int64:
return py::cast(b.get<long>(coordIdx));
return py::cast(b.get<std::int64_t>(coordIdx));
default:
return py::none();
}
......@@ -141,10 +141,10 @@ void init_Tensor(py::module& m){
dataFormatDescriptor = py::format_descriptor<float>::format();
break;
case DataType::Int32:
dataFormatDescriptor = py::format_descriptor<int>::format();
dataFormatDescriptor = py::format_descriptor<std::int32_t>::format();
break;
case DataType::Int64:
dataFormatDescriptor = py::format_descriptor<long>::format();
dataFormatDescriptor = py::format_descriptor<std::int64_t>::format();
break;
default:
throw py::value_error("Unsupported data format");
......@@ -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 !
// Need to find a way to avoid this !
addCtor<int>(pyClassTensor);
addCtor<long>(pyClassTensor);
addCtor<std::int32_t>(pyClassTensor);
addCtor<std::int64_t>(pyClassTensor);
addCtor<float>(pyClassTensor);
// #if SIZE_MAX != 0xFFFFFFFF
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