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

Implement XTensor support in core. #976

Merged
merged 3 commits into from
May 24, 2024
Merged

Implement XTensor support in core. #976

merged 3 commits into from
May 24, 2024

Conversation

1uc
Copy link
Collaborator

@1uc 1uc commented Apr 5, 2024

Adds support for xt::xtensor, both row and column major. We're missing xt::xarray and views. Views fail because they claim to have runtime variable rank.

@codecov-commenter
Copy link

codecov-commenter commented Apr 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.81%. Comparing base (ce46f86) to head (93670a6).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #976      +/-   ##
==========================================
- Coverage   86.81%   86.81%   -0.01%     
==========================================
  Files         100      100              
  Lines        6083     6081       -2     
==========================================
- Hits         5281     5279       -2     
  Misses        802      802              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@1uc 1uc marked this pull request as ready for review April 8, 2024 10:56
@pramodk pramodk requested a review from alkino April 8, 2024 13:21
Comment on lines 37 to 63
val.resize(shape);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no recursivity here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of it works with non-trivial elements. I should check if they even allow anything non-trivial.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're now asserting the fact. I propose we revisit, if we ever need to support them.

@1uc 1uc requested a review from alkino April 19, 2024 14:16
@1uc
Copy link
Collaborator Author

1uc commented May 6, 2024

@alkino The reason for not allowing non-trivial elements, is that this way we can use xt::adapt which also paves the way for implementing all other flavours of xt objects. With the same idea we will be able to take any xt object, and assign it to (read it from) memory we've wrapped with an xt::adapt. This idea works for row-/column-major and stridded/padded arrays.

It doesn't work for anything that contains non-trivial elements.

@1uc 1uc force-pushed the 1uc/xtensor branch 3 times, most recently from 7fbae3e to a87ef6e Compare May 14, 2024 08:32
@1uc 1uc marked this pull request as draft May 14, 2024 10:27
@1uc 1uc force-pushed the 1uc/xtensor branch 2 times, most recently from b24a97d to 35ab518 Compare May 17, 2024 09:07
@1uc 1uc marked this pull request as ready for review May 17, 2024 10:18
@1uc 1uc mentioned this pull request May 18, 2024
@1uc
Copy link
Collaborator Author

1uc commented May 18, 2024

Closes #594.

@1uc 1uc force-pushed the 1uc/xtensor branch 2 times, most recently from 8be6326 to 09959cc Compare May 23, 2024 07:37
1uc added 2 commits May 23, 2024 09:44
Adds support for `xt::xtensor`, `xt::xarray` and `xt::xview`, both row
and column major. This works by wrapping the internal row-major with
`xt::adapt`. Therefore, the `T` in `xt::xtensor<T, ...>` must be scalar
(trivial).

static hdf5_type* data(type& val) {
if (!is_trivially_copyable) {
throw DataSetException("Invalid used of `inspector<xarray>::data`.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really xarray here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, there used to be separate inspectors for xarray and xtensor. Looks like I copied these lines from the xarray variation.

include/highfive/xtensor.hpp Outdated Show resolved Hide resolved
@1uc 1uc merged commit 5f3ded6 into master May 24, 2024
36 checks passed
@1uc 1uc deleted the 1uc/xtensor branch May 24, 2024 05:39
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

Successfully merging this pull request may close these issues.

4 participants