HighFive
HighFive copied to clipboard
Prevent H5Easy from serializing column-major `xt::` objects.
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);
(In your example, you meant to put column_major
I guess?)
A quick fix is to add a static_assert
Fixed by #989.