tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
caffe: fix compilation against C++17
uku
8 months ago
75cdeccf
f349c0d6
+68
-1
2 changed files
expand all
collapse all
unified
split
pkgs
applications
science
math
caffe
default.nix
random-shuffle.patch
+1
-1
pkgs/applications/science/math/caffe/default.nix
···
1
1
{
2
2
-
config,
3
2
stdenv,
4
3
lib,
5
4
fetchFromGitHub,
···
117
116
[
118
117
./darwin.patch
119
118
./glog-cmake.patch
119
119
+
./random-shuffle.patch
120
120
(fetchpatch {
121
121
name = "support-opencv4";
122
122
url = "https://github.com/BVLC/caffe/pull/6638/commits/0a04cc2ccd37ba36843c18fea2d5cbae6e7dd2b5.patch";
+67
pkgs/applications/science/math/caffe/random-shuffle.patch
···
1
1
+
From 11e585e52ab92bb9d7a995c5002cb55fbff687b2 Mon Sep 17 00:00:00 2001
2
2
+
From: uku <hi@uku.moe>
3
3
+
Date: Thu, 15 May 2025 11:10:50 +0200
4
4
+
Subject: [PATCH] fix: remove usages of random_shuffle
5
5
+
6
6
+
---
7
7
+
src/caffe/layers/hdf5_data_layer.cpp | 17 ++++++++++++-----
8
8
+
1 file changed, 12 insertions(+), 5 deletions(-)
9
9
+
10
10
+
diff --git a/src/caffe/layers/hdf5_data_layer.cpp b/src/caffe/layers/hdf5_data_layer.cpp
11
11
+
index 00716a92..01213691 100644
12
12
+
--- a/src/caffe/layers/hdf5_data_layer.cpp
13
13
+
+++ b/src/caffe/layers/hdf5_data_layer.cpp
14
14
+
@@ -61,7 +61,9 @@ void HDF5DataLayer<Dtype>::LoadHDF5FileData(const char* filename) {
15
15
+
16
16
+
// Shuffle if needed.
17
17
+
if (this->layer_param_.hdf5_data_param().shuffle()) {
18
18
+
- std::random_shuffle(data_permutation_.begin(), data_permutation_.end());
19
19
+
+ std::random_device rand_device;
20
20
+
+ std::default_random_engine rand_engine(rand_device());
21
21
+
+ std::shuffle(data_permutation_.begin(), data_permutation_.end(), rand_engine);
22
22
+
DLOG(INFO) << "Successfully loaded " << hdf_blobs_[0]->shape(0)
23
23
+
<< " rows (shuffled)";
24
24
+
} else {
25
25
+
@@ -104,7 +106,9 @@ void HDF5DataLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype>*>& bottom,
26
26
+
27
27
+
// Shuffle if needed.
28
28
+
if (this->layer_param_.hdf5_data_param().shuffle()) {
29
29
+
- std::random_shuffle(file_permutation_.begin(), file_permutation_.end());
30
30
+
+ std::random_device rand_device;
31
31
+
+ std::default_random_engine rand_engine(rand_device());
32
32
+
+ std::shuffle(file_permutation_.begin(), file_permutation_.end(), rand_engine);
33
33
+
}
34
34
+
35
35
+
// Load the first HDF5 file and initialize the line counter.
36
36
+
@@ -137,14 +141,17 @@ bool HDF5DataLayer<Dtype>::Skip() {
37
37
+
38
38
+
template<typename Dtype>
39
39
+
void HDF5DataLayer<Dtype>::Next() {
40
40
+
+ std::random_device rand_device;
41
41
+
+ std::default_random_engine rand_engine(rand_device());
42
42
+
if (++current_row_ == hdf_blobs_[0]->shape(0)) {
43
43
+
if (num_files_ > 1) {
44
44
+
++current_file_;
45
45
+
if (current_file_ == num_files_) {
46
46
+
current_file_ = 0;
47
47
+
if (this->layer_param_.hdf5_data_param().shuffle()) {
48
48
+
- std::random_shuffle(file_permutation_.begin(),
49
49
+
- file_permutation_.end());
50
50
+
+ std::shuffle(file_permutation_.begin(),
51
51
+
+ file_permutation_.end(),
52
52
+
+ rand_engine);
53
53
+
}
54
54
+
DLOG(INFO) << "Looping around to first file.";
55
55
+
}
56
56
+
@@ -153,7 +160,7 @@ void HDF5DataLayer<Dtype>::Next() {
57
57
+
}
58
58
+
current_row_ = 0;
59
59
+
if (this->layer_param_.hdf5_data_param().shuffle())
60
60
+
- std::random_shuffle(data_permutation_.begin(), data_permutation_.end());
61
61
+
+ std::shuffle(data_permutation_.begin(), data_permutation_.end(), rand_engine);
62
62
+
}
63
63
+
offset_++;
64
64
+
}
65
65
+
--
66
66
+
2.49.0
67
67
+