Closed bordingj closed 6 years ago
Hi bordingj,
no, there is no way to do that. but you can use all functions that you have on xtensor on the pytensor as well.
If you want to write expression agnostic code, writing templated code in this fashion is recommended:
template <class T>
auto func(xexpression<T>& expr)
{
auto& de = expr.derived_cast();
de[0] += 123;
return de;
}
xtensor
owns its data buffer and manages the memory with C++ allocators whereas the memory of the pytensor
is managed by python allocators, so you cannot transfer ownership from one world to the other.
As mentioned by @wolfv, pytensor
is a valid expression so it supports all the operations / features of xtensor
and you can write code agnostic from the data backend.
I understand. Thank you.
Is there a way to go from a xt::pytensor to xt::xtensor and back again without copying the underlying data ? If so, it would be nice with some documentation on how to do it. If not, then I have a feature request :) .