Skip to content

Commit b3369ca

Browse files
committed
Add patch for saving HDF5 files.
1 parent 49d8eb7 commit b3369ca

File tree

4 files changed

+83
-0
lines changed

4 files changed

+83
-0
lines changed

Jenkinsfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ pipeline
2626
git clone https://github.com/mlpack/mlpack
2727
cd mlpack/
2828
git checkout $MLPACK_VERSION
29+
patch -p1 < ../hdf5_filename.patch
2930
3031
mkdir build/
3132
cd build/

azure-pipelines-macos-steps.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ steps:
1111
git clone https://github.com/mlpack/mlpack
1212
cd mlpack
1313
git checkout $(MLPACK_VERSION)
14+
patch -p1 < ../hdf5_filename.patch
1415
displayName: Clone mlpack
1516
1617
- bash: |

azure-pipelines-windows-steps.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ steps:
5353
git clone https://github.com/mlpack/mlpack
5454
cd mlpack
5555
git checkout $(MLPACK_VERSION)
56+
patch -p1 < ../hdf5_filename.patch
5657
displayName: Clone mlpack
5758
5859
- powershell: |

hdf5_filename.patch

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
--- mlpack-4.6.1/src/mlpack/core/data/utilities.hpp 2025-05-14 14:48:05.000000000 -0400
2+
+++ mlpack-4.6.1-new/src/mlpack/core/data/utilities.hpp 2025-05-15 09:59:41.590371158 -0400
3+
@@ -134,6 +134,7 @@
4+
template<typename MatType, typename DataOptionsType>
5+
bool SaveMatrix(const MatType& matrix,
6+
const DataOptionsType& opts,
7+
+ const std::string& filename,
8+
std::fstream& stream)
9+
{
10+
bool success = false;
11+
--- mlpack-4.6.1/src/mlpack/core/data/save_impl.hpp 2025-05-14 14:48:05.000000000 -0400
12+
+++ mlpack-4.6.1-new/src/mlpack/core/data/save_impl.hpp 2025-05-15 09:59:41.590371158 -0400
13+
@@ -135,21 +135,21 @@
14+
TextOptions txtOpts(std::move(opts));
15+
if constexpr (IsSparseMat<MatType>::value)
16+
{
17+
- success = SaveSparse(matrix, txtOpts, stream);
18+
+ success = SaveSparse(matrix, txtOpts, filename, stream);
19+
}
20+
else if constexpr (IsCol<MatType>::value)
21+
{
22+
opts.NoTranspose() = true;
23+
- success = SaveDense(matrix, txtOpts, stream);
24+
+ success = SaveDense(matrix, txtOpts, filename, stream);
25+
}
26+
else if constexpr (IsRow<MatType>::value)
27+
{
28+
opts.NoTranspose() = false;
29+
- success = SaveDense(matrix, txtOpts, stream);
30+
+ success = SaveDense(matrix, txtOpts, filename, stream);
31+
}
32+
else if constexpr (IsDense<MatType>::value)
33+
{
34+
- success = SaveDense(matrix, txtOpts, stream);
35+
+ success = SaveDense(matrix, txtOpts, filename, stream);
36+
}
37+
opts = std::move(txtOpts);
38+
}
39+
@@ -183,6 +183,7 @@
40+
template<typename eT>
41+
bool SaveDense(const arma::Mat<eT>& matrix,
42+
TextOptions& opts,
43+
+ const std::string& filename,
44+
std::fstream& stream)
45+
{
46+
bool success = false;
47+
@@ -191,10 +192,10 @@
48+
if (!opts.NoTranspose())
49+
{
50+
tmp = trans(matrix);
51+
- success = SaveMatrix(tmp, opts, stream);
52+
+ success = SaveMatrix(tmp, opts, filename, stream);
53+
}
54+
else
55+
- success = SaveMatrix(matrix, opts, stream);
56+
+ success = SaveMatrix(matrix, opts, filename, stream);
57+
58+
return success;
59+
}
60+
@@ -203,6 +204,7 @@
61+
template<typename eT>
62+
bool SaveSparse(const arma::SpMat<eT>& matrix,
63+
TextOptions& opts,
64+
+ const std::string& filename,
65+
std::fstream& stream)
66+
{
67+
bool success = false;
68+
@@ -212,10 +214,10 @@
69+
if (!opts.NoTranspose())
70+
{
71+
arma::SpMat<eT> tmp = trans(matrix);
72+
- success = SaveMatrix(tmp, opts, stream);
73+
+ success = SaveMatrix(tmp, opts, filename, stream);
74+
}
75+
else
76+
- success = SaveMatrix(matrix, opts, stream);
77+
+ success = SaveMatrix(matrix, opts, filename, stream);
78+
79+
return success;
80+
}

0 commit comments

Comments
 (0)