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

Prevent H5Easy from serializing column-major xt:: objects. #917

Closed
1uc opened this issue Jan 17, 2024 · 2 comments
Closed

Prevent H5Easy from serializing column-major xt:: objects. #917

1uc opened this issue Jan 17, 2024 · 2 comments
Labels
bug v3 Anything that needs to be resolved before `v3`.

Comments

@1uc
Copy link
Collaborator

1uc commented Jan 17, 2024

XTensor support various memory layouts. H5Easy implements XTensor support as follows:

template <typename T>
struct io_impl<T, typename std::enable_if<xt::is_xexpression<T>::value>::type> {
    ...
    inline static DataSet dump(File& file,
                               const std::string& path,
                               const T& data,
                               const DumpOptions& options) {

        DataSet dataset = initDataset<value_type>(file, path, shape(data), options);
        dataset.write_raw(data.data());
        ...

which is correct for row-major layouts without padding or striding. The following code however compiles and runs:

xt::xarray<double, xt::layout_type::row_major> a({{1, 2, 3}, {4, 5, 6}});
H5Easy::dump(file, "a", a);
@1uc 1uc added the bug label Jan 23, 2024
@tdegeus
Copy link
Collaborator

tdegeus commented Feb 14, 2024

(In your example, you meant to put column_major I guess?)

A quick fix is to add a static_assert

@1uc 1uc added the v3 Anything that needs to be resolved before `v3`. label Feb 21, 2024
@1uc
Copy link
Collaborator Author

1uc commented May 6, 2024

Fixed by #989.

@1uc 1uc closed this as completed May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v3 Anything that needs to be resolved before `v3`.
Projects
None yet
Development

No branches or pull requests

2 participants