Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding xt::reshape like reshape intrinsic in Fortran #44

Open
czgdp1807 opened this issue Jan 3, 2024 · 3 comments
Open

Adding xt::reshape like reshape intrinsic in Fortran #44

czgdp1807 opened this issue Jan 3, 2024 · 3 comments

Comments

@czgdp1807
Copy link
Collaborator

czgdp1807 commented Jan 3, 2024

So here is one thing I noticed in xtensor. xtensor has no intrinsic like reshape. reshape intrinsic in Fortran doesn't modify the input array but creates a new array with the shape specified in second argument. It has no restrictions like the new array must have same rank as the input array. The only restriction it has is that the shape argument must be of fixed size.
xtensor has a method called, .reshape but it modifies the array/tensor itself. Doesn't behave like reshape in Fortran. Also it has the restriction that the new shape must be of same size as the rank of input array (obviously because it is modifying the input array).
xtensor has xt::reshape_view which comes close to reshape but again it just shallow copies and doesn't work like reshape at all. If you try to use it like reshape intrinsic it won't be compiled by clang/gcc.
@certik So would it be possible to discuss with xtensor team to add an intrinsic like, xt::reshape which would accept two arguments. First one, xt::xtensor or xt::xtensor_fixed or xt::array- the input array. Second one, would be an xt::xtensor_fixed or {...} (array constant in C++). And return xt::xtensor object? We will be able to port tests like, integration_tests/arrays_reshape_14.f90 from LFortran?

xtensor-stack/xtensor#2760

@certik
Copy link
Contributor

certik commented Jan 3, 2024

Yes, go ahead and open up an issue at xtensor to discuss this.

I don't think we need to have exactly the same reshape function though.

@czgdp1807
Copy link
Collaborator Author

Opened an issue in xtensor.

@czgdp1807
Copy link
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants