Skip to content
Snippets Groups Projects
Commit 6fbf32e2 authored by laurent soulier's avatar laurent soulier
Browse files

[FIX] fix for python binding only

parent dfbb1f27
No related branches found
No related tags found
2 merge requests!41Support for any backend storage,!13Refactoring Tensor
Pipeline #32567 failed
......@@ -488,6 +488,15 @@ public:
/// @return Linear index of the first Byte_t of the data at given coordinates
NbElts_t getIdx(std::vector<Coord_t> const &coordIdx) const noexcept;
/// @brief Get the logical coordinates of the data at given index, to be used only for
/// Python binding
/// @param coordIdx coordinates of the desired data
/// @note The index is expressed in number of elements
/// @return Logical coordinates of the data at given index
std::vector<Coord_t>
getCoordOnlyForPythonIfYoureUsingItYoureProbablyDoingSomethingWrong(
NbElts_t const flatIdx) const noexcept;
private:
/// @brief Getting the address of the very first data in memory (lexicographic
/// order), read only access to data
......
......@@ -91,7 +91,9 @@ void init_Tensor(py::module& m)
.def("size", &Tensor::size)
.def("resize", (void(Tensor::*)(const std::vector<DimSize_t>&)) & Tensor::resize)
.def("has_impl", &Tensor::hasImpl)
.def("get_coord", &Tensor::getCoord)
.def(
"get_coord",
&Tensor::getCoordOnlyForPythonIfYoureUsingItYoureProbablyDoingSomethingWrong)
.def("get_idx", &Tensor::getIdx)
.def_static("get_available_backends", &Tensor::getAvailableBackends)
.def("__str__", [](Tensor& b) { return b.toString(); })
......
......@@ -72,6 +72,16 @@ void Tensor::getCoord(
{
mImpl->getCoord(flatIdx, coordIdx);
}
std::vector<Coord_t>
Tensor::getCoordOnlyForPythonIfYoureUsingItYoureProbablyDoingSomethingWrong(
NbElts_t const flatIdx) const noexcept
{
std::vector<Coord_t> Coords(mDims.size());
getCoord(flatIdx, Coords);
return Coords;
}
NbElts_t Tensor::getIdx(std::vector<Coord_t> const &coordIdx) const noexcept
{
return mImpl->getIdx(coordIdx);
......
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