You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
std::array shape{3, 4, 5};
auto shape_adapt = xt::adapt(shape);
auto tensor = xt::eval(2 * shape_adapt);
The resulting type of tensor is xtensor_container, which is vector underneath. So we went from array to vector.
This is a very common use case for working with tensor shapes and would optimize quite a bit. Currently we go for std::transform and xtl::make_sequence in these cases, which is not so nice. Adapting shapes would be much nicer))
The text was updated successfully, but these errors were encountered:
I think this is a good idea to have. I do think though that using shape as an example is confusing. xt::adapt transforms data into an xtensor object (of the appropriate shape). It does not allocate a tensor of a certain shape (as the example is suggesting).
Furthermore, there is a question about defaults. In particular, I do think that xtensor_fixed should get a bit of attention before this could be the default: I have been having many problems on Windows, so personally I have temporarily stopped using xtensor_fixed altogether.
In that light, it may make sense to allow an option or template argument for xt::adapt?
The example was about adapting the shape of the container (usually std::array or std::vector) to perform some arithmetic on it (get the shape that is twice as big).
Sorry for the confusion.
Also a nice example is working with multidimensional indices: e.g. getting the central element:
auto& center = tensor[xt::adapt(tensor.shape()) / 2];
@vakokako OK, that clarifies things. But then isn't the wanted extension more that some of xtensor's function should work on xtensor objects too (if they now only work on std::array or std::vector)?
Take a look at this example:
The resulting type of
tensor
isxtensor_container
, which isvector
underneath. So we went fromarray
tovector
.This is a very common use case for working with tensor shapes and would optimize quite a bit. Currently we go for
std::transform
andxtl::make_sequence
in these cases, which is not so nice. Adapting shapes would be much nicer))The text was updated successfully, but these errors were encountered: