uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
192
pkgs/applications/science/machine-learning/shogun/default.nix
Normal file
192
pkgs/applications/science/machine-learning/shogun/default.nix
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
{ lib
|
||||
, stdenv
|
||||
, fetchFromGitHub
|
||||
, fetchpatch
|
||||
, fetchurl
|
||||
# build
|
||||
, cmake
|
||||
, ctags
|
||||
, python3Packages
|
||||
, swig
|
||||
# math
|
||||
, eigen
|
||||
, blas
|
||||
, lapack
|
||||
, glpk
|
||||
# data
|
||||
, protobuf
|
||||
, json_c
|
||||
, libxml2
|
||||
, hdf5
|
||||
, curl
|
||||
# compression
|
||||
, libarchive
|
||||
, bzip2
|
||||
, xz
|
||||
, snappy
|
||||
, lzo
|
||||
# more math
|
||||
, nlopt
|
||||
, lp_solve
|
||||
, colpack
|
||||
# extra support
|
||||
, pythonSupport ? false
|
||||
, opencvSupport ? false
|
||||
, opencv ? null
|
||||
, withSvmLight ? false
|
||||
}:
|
||||
|
||||
assert pythonSupport -> python3Packages != null;
|
||||
assert opencvSupport -> opencv != null;
|
||||
|
||||
assert (!blas.isILP64) && (!lapack.isILP64);
|
||||
|
||||
let
|
||||
pname = "shogun";
|
||||
version = "6.1.4";
|
||||
|
||||
rxcppVersion = "4.0.0";
|
||||
gtestVersion = "1.8.0";
|
||||
|
||||
srcs = {
|
||||
toolbox = fetchFromGitHub {
|
||||
owner = pname + "-toolbox";
|
||||
repo = pname;
|
||||
rev = pname + "_" + version;
|
||||
sha256 = "05s9dclmk7x5d7wnnj4qr6r6c827m72a44gizcv09lxr28pr9inz";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
# The CMake external projects expect the packed archives
|
||||
rxcpp = fetchurl {
|
||||
url = "https://github.com/Reactive-Extensions/RxCpp/archive/v${rxcppVersion}.tar.gz";
|
||||
sha256 = "0y2isr8dy2n1yjr9c5570kpc9lvdlch6jv0jvw000amwn5d3krsh";
|
||||
};
|
||||
gtest = fetchurl {
|
||||
url = "https://github.com/google/googletest/archive/release-${gtestVersion}.tar.gz";
|
||||
sha256 = "1n5p1m2m3fjrjdj752lf92f9wq3pl5cbsfrb49jqbg52ghkz99jq";
|
||||
};
|
||||
};
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
inherit pname version;
|
||||
|
||||
outputs = [ "out" "dev" "doc" ];
|
||||
|
||||
src = srcs.toolbox;
|
||||
|
||||
patches = [
|
||||
# Fix compile errors with json-c
|
||||
# https://github.com/shogun-toolbox/shogun/pull/4104
|
||||
(fetchpatch {
|
||||
url = "https://github.com/shogun-toolbox/shogun/commit/365ce4c4c700736d2eec8ba6c975327a5ac2cd9b.patch";
|
||||
sha256 = "158hqv4xzw648pmjbwrhxjp7qcppqa7kvriif87gn3zdn711c49s";
|
||||
})
|
||||
|
||||
# Fix compile errors with GCC 9+
|
||||
# https://github.com/shogun-toolbox/shogun/pull/4811
|
||||
(fetchpatch {
|
||||
url = "https://github.com/shogun-toolbox/shogun/commit/c8b670be4790e0f06804b048a6f3d77c17c3ee95.patch";
|
||||
sha256 = "sha256-MxsR3Y2noFQevfqWK3nmX5iK4OVWeKBl5tfeDNgjcXk=";
|
||||
})
|
||||
(fetchpatch {
|
||||
url = "https://github.com/shogun-toolbox/shogun/commit/5aceefd9fb0e2132c354b9a0c0ceb9160cc9b2f7.patch";
|
||||
sha256 = "sha256-AgJJKQA8vc5oKaTQDqMdwBR4hT4sn9+uW0jLe7GteJw=";
|
||||
})
|
||||
|
||||
# Fix compile errors with Eigen 3.4
|
||||
./eigen-3.4.patch
|
||||
|
||||
] ++ lib.optional (!withSvmLight) ./svmlight-scrubber.patch;
|
||||
|
||||
nativeBuildInputs = [ cmake swig ctags ]
|
||||
++ (with python3Packages; [ python jinja2 ply ]);
|
||||
|
||||
buildInputs = [
|
||||
eigen
|
||||
blas
|
||||
lapack
|
||||
glpk
|
||||
protobuf
|
||||
json_c
|
||||
libxml2
|
||||
hdf5
|
||||
curl
|
||||
libarchive
|
||||
bzip2
|
||||
xz
|
||||
snappy
|
||||
lzo
|
||||
nlopt
|
||||
lp_solve
|
||||
colpack
|
||||
] ++ lib.optionals pythonSupport (with python3Packages; [ python numpy ])
|
||||
++ lib.optional opencvSupport opencv;
|
||||
|
||||
cmakeFlags = let
|
||||
enableIf = cond: if cond then "ON" else "OFF";
|
||||
in [
|
||||
"-DBUILD_META_EXAMPLES=ON"
|
||||
"-DCMAKE_DISABLE_FIND_PACKAGE_ARPACK=ON"
|
||||
"-DCMAKE_DISABLE_FIND_PACKAGE_ARPREC=ON"
|
||||
"-DCMAKE_DISABLE_FIND_PACKAGE_CPLEX=ON"
|
||||
"-DCMAKE_DISABLE_FIND_PACKAGE_Mosek=ON"
|
||||
"-DCMAKE_DISABLE_FIND_PACKAGE_TFLogger=ON"
|
||||
"-DCMAKE_DISABLE_FIND_PACKAGE_ViennaCL=ON"
|
||||
"-DCMAKE_SKIP_BUILD_RPATH=OFF"
|
||||
"-DCMAKE_CTEST_ARGUMENTS='--exclude-regex;TrainedModelSerialization'" # Sporadic segfault
|
||||
"-DENABLE_TESTING=${enableIf doCheck}"
|
||||
"-DDISABLE_META_INTEGRATION_TESTS=ON"
|
||||
"-DTRAVIS_DISABLE_META_CPP=ON"
|
||||
"-DINTERFACE_PYTHON=${enableIf pythonSupport}"
|
||||
"-DOpenCV=${enableIf opencvSupport}"
|
||||
"-DUSE_SVMLIGHT=${enableIf withSvmLight}"
|
||||
];
|
||||
|
||||
CXXFLAGS = "-faligned-new";
|
||||
|
||||
doCheck = true;
|
||||
|
||||
postUnpack = ''
|
||||
mkdir -p $sourceRoot/third_party/{rxcpp,GoogleMock}
|
||||
ln -s ${srcs.rxcpp} $sourceRoot/third_party/rxcpp/v${rxcppVersion}.tar.gz
|
||||
ln -s ${srcs.gtest} $sourceRoot/third_party/GoogleMock/release-${gtestVersion}.tar.gz
|
||||
'';
|
||||
|
||||
postPatch = ''
|
||||
# Fix preprocessing SVMlight code
|
||||
sed -i \
|
||||
-e 's@#ifdef SVMLIGHT@#ifdef USE_SVMLIGHT@' \
|
||||
-e '/^#ifdef USE_SVMLIGHT/,/^#endif/ s@#endif@#endif //USE_SVMLIGHT@' \
|
||||
src/shogun/kernel/string/CommUlongStringKernel.cpp
|
||||
sed -i -e 's/#if USE_SVMLIGHT/#ifdef USE_SVMLIGHT/' src/interfaces/swig/Machine.i
|
||||
sed -i -e 's@// USE_SVMLIGHT@//USE_SVMLIGHT@' src/interfaces/swig/Transfer.i
|
||||
sed -i -e 's@/\* USE_SVMLIGHT \*/@//USE_SVMLIGHT@' src/interfaces/swig/Transfer_includes.i
|
||||
'' + lib.optionalString (!withSvmLight) ''
|
||||
# Run SVMlight scrubber
|
||||
patchShebangs scripts/light-scrubber.sh
|
||||
echo "removing SVMlight code"
|
||||
./scripts/light-scrubber.sh
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p $doc/share/doc/shogun/examples
|
||||
mv $out/share/shogun/examples/cpp $doc/share/doc/shogun/examples
|
||||
cp ../examples/undocumented/libshogun/*.cpp $doc/share/doc/shogun/examples/cpp
|
||||
rm -r $out/share
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
# CMake incorrectly calculates library path from dev prefix
|
||||
substituteInPlace $dev/lib/cmake/shogun/ShogunTargets-release.cmake \
|
||||
--replace "\''${_IMPORT_PREFIX}/lib/" "$out/lib/"
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "A toolbox which offers a wide range of efficient and unified machine learning methods";
|
||||
homepage = "http://shogun-toolbox.org/";
|
||||
license = if withSvmLight then licenses.unfree else licenses.gpl3Plus;
|
||||
maintainers = with maintainers; [ edwtjo smancill ];
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
From: Sebastián Mancilla <smancill@smancill.dev>
|
||||
Subject: [PATCH] Fix compile errors when using Eigen 3.4
|
||||
|
||||
---
|
||||
.../machine/gp/MultiLaplaceInferenceMethod.cpp | 18 +++++++++---------
|
||||
1 file changed, 9 insertions(+), 9 deletions(-)
|
||||
|
||||
diff --git a/src/shogun/machine/gp/MultiLaplaceInferenceMethod.cpp b/src/shogun/machine/gp/MultiLaplaceInferenceMethod.cpp
|
||||
index 2e27678d2..60050afea 100644
|
||||
--- a/src/shogun/machine/gp/MultiLaplaceInferenceMethod.cpp
|
||||
+++ b/src/shogun/machine/gp/MultiLaplaceInferenceMethod.cpp
|
||||
@@ -84,9 +84,9 @@ class CMultiPsiLine : public func_base
|
||||
float64_t result=0;
|
||||
for(index_t bl=0; bl<C; bl++)
|
||||
{
|
||||
- eigen_f.block(bl*n,0,n,1)=K*alpha->block(bl*n,0,n,1)*CMath::exp(log_scale*2.0);
|
||||
- result+=alpha->block(bl*n,0,n,1).dot(eigen_f.block(bl*n,0,n,1))/2.0;
|
||||
- eigen_f.block(bl*n,0,n,1)+=eigen_m;
|
||||
+ eigen_f.segment(bl*n,n)=K*alpha->segment(bl*n,n)*CMath::exp(log_scale*2.0);
|
||||
+ result+=alpha->segment(bl*n,n).dot(eigen_f.segment(bl*n,n))/2.0;
|
||||
+ eigen_f.segment(bl*n,n)+=eigen_m;
|
||||
}
|
||||
|
||||
// get first and second derivatives of log likelihood
|
||||
@@ -272,7 +272,7 @@ void CMultiLaplaceInferenceMethod::update_alpha()
|
||||
{
|
||||
Map<VectorXd> alpha(m_alpha.vector, m_alpha.vlen);
|
||||
for(index_t bl=0; bl<C; bl++)
|
||||
- eigen_mu.block(bl*n,0,n,1)=eigen_ktrtr*CMath::exp(m_log_scale*2.0)*alpha.block(bl*n,0,n,1);
|
||||
+ eigen_mu.segment(bl*n,n)=eigen_ktrtr*CMath::exp(m_log_scale*2.0)*alpha.segment(bl*n,n);
|
||||
|
||||
//alpha'*(f-m)/2.0
|
||||
Psi_New=alpha.dot(eigen_mu)/2.0;
|
||||
@@ -316,7 +316,7 @@ void CMultiLaplaceInferenceMethod::update_alpha()
|
||||
|
||||
for(index_t bl=0; bl<C; bl++)
|
||||
{
|
||||
- VectorXd eigen_sD=eigen_dpi.block(bl*n,0,n,1).cwiseSqrt();
|
||||
+ VectorXd eigen_sD=eigen_dpi.segment(bl*n,n).cwiseSqrt();
|
||||
LLT<MatrixXd> chol_tmp((eigen_sD*eigen_sD.transpose()).cwiseProduct(eigen_ktrtr*CMath::exp(m_log_scale*2.0))+
|
||||
MatrixXd::Identity(m_ktrtr.num_rows, m_ktrtr.num_cols));
|
||||
MatrixXd eigen_L_tmp=chol_tmp.matrixU();
|
||||
@@ -341,11 +341,11 @@ void CMultiLaplaceInferenceMethod::update_alpha()
|
||||
VectorXd tmp2=m_tmp.array().rowwise().sum();
|
||||
|
||||
for(index_t bl=0; bl<C; bl++)
|
||||
- eigen_b.block(bl*n,0,n,1)+=eigen_dpi.block(bl*n,0,n,1).cwiseProduct(eigen_mu.block(bl*n,0,n,1)-eigen_mean_bl-tmp2);
|
||||
+ eigen_b.segment(bl*n,n)+=eigen_dpi.segment(bl*n,n).cwiseProduct(eigen_mu.segment(bl*n,n)-eigen_mean_bl-tmp2);
|
||||
|
||||
Map<VectorXd> &eigen_c=eigen_W;
|
||||
for(index_t bl=0; bl<C; bl++)
|
||||
- eigen_c.block(bl*n,0,n,1)=eigen_E.block(0,bl*n,n,n)*(eigen_ktrtr*CMath::exp(m_log_scale*2.0)*eigen_b.block(bl*n,0,n,1));
|
||||
+ eigen_c.segment(bl*n,n)=eigen_E.block(0,bl*n,n,n)*(eigen_ktrtr*CMath::exp(m_log_scale*2.0)*eigen_b.segment(bl*n,n));
|
||||
|
||||
Map<MatrixXd> c_tmp(eigen_c.data(),n,C);
|
||||
|
||||
@@ -409,7 +409,7 @@ float64_t CMultiLaplaceInferenceMethod::get_derivative_helper(SGMatrix<float64_t
|
||||
{
|
||||
result+=((eigen_E.block(0,bl*n,n,n)-eigen_U.block(0,bl*n,n,n).transpose()*eigen_U.block(0,bl*n,n,n)).array()
|
||||
*eigen_dK.array()).sum();
|
||||
- result-=(eigen_dK*eigen_alpha.block(bl*n,0,n,1)).dot(eigen_alpha.block(bl*n,0,n,1));
|
||||
+ result-=(eigen_dK*eigen_alpha.segment(bl*n,n)).dot(eigen_alpha.segment(bl*n,n));
|
||||
}
|
||||
|
||||
return result/2.0;
|
||||
@@ -489,7 +489,7 @@ SGVector<float64_t> CMultiLaplaceInferenceMethod::get_derivative_wrt_mean(
|
||||
result[i]=0;
|
||||
//currently only compute the explicit term
|
||||
for(index_t bl=0; bl<C; bl++)
|
||||
- result[i]-=eigen_alpha.block(bl*n,0,n,1).dot(eigen_dmu);
|
||||
+ result[i]-=eigen_alpha.segment(bl*n,n).dot(eigen_dmu);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
From: Sebastián Mancilla <smancill@smancill.dev>
|
||||
Subject: Update SVMlight scrubber script
|
||||
|
||||
This requires previously fixing a few wrong preprocessor directives that
|
||||
are supposed to fence code using SVMlight.
|
||||
|
||||
- The script was too eager and removing *.light files in SVMlight format
|
||||
that are used by other tests. The code reading those files doesn't use
|
||||
any SVMlight code so it should be fine to keep it and run the tests.
|
||||
|
||||
- The Python test *domainadaptationsvm.py was not removed because of
|
||||
wrong globbing.
|
||||
|
||||
- Remove a couple of examples using SVMlight that were missed.
|
||||
|
||||
- The script is actually modifying (and breaking) itself because the
|
||||
grep for the USE_SVMLIGHT macro is too eager again and matches itself
|
||||
(and the version stored in upstream's Debian package control tarball
|
||||
is broken because of it). Just fix it by grepping for preprocessor
|
||||
directives only.
|
||||
|
||||
- No need to fix the Transfer_includes.i file in the script with a final
|
||||
%} when its preprocessor directives have been fixed.
|
||||
|
||||
- The Swig files were moved to a new directory at some point but the
|
||||
script was not updated accordingly.
|
||||
---
|
||||
scripts/light-scrubber.sh | 16 ++++++----------
|
||||
1 file changed, 6 insertions(+), 10 deletions(-)
|
||||
|
||||
diff a/scripts/light-scrubber.sh b/scripts/light-scrubber.sh
|
||||
--- a/scripts/light-scrubber.sh
|
||||
+++ b/scripts/light-scrubber.sh
|
||||
@@ -26,14 +26,16 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
-rm -rf examples/*/*/{*light*,*_domainadaptationsvm_*} \
|
||||
+rm -rf examples/*/*/{*light*.*,*domainadaptationsvm*} \
|
||||
examples/undocumented/matlab_and_octave/tests/*light* \
|
||||
+ examples/undocumented/python/serialization_string_kernels.py \
|
||||
+ examples/undocumented/python/mkl_binclass.py \
|
||||
src/shogun/classifier/svm/SVMLight.* \
|
||||
src/shogun/classifier/svm/SVMLightOneClass.* \
|
||||
src/shogun/regression/svr/SVRLight.* \
|
||||
doc/md/LICENSE_SVMlight*
|
||||
|
||||
-for _file in `grep -rl USE_SVMLIGHT .`
|
||||
+grep -rl '^#ifdef USE_SVMLIGHT' . | while read -r _file
|
||||
do
|
||||
sed -i.orig -e \
|
||||
'/\#ifdef USE_SVMLIGHT/,/\#endif \/\/USE_SVMLIGHT/c \\' ${_file} && \
|
||||
@@ -41,7 +43,7 @@ do
|
||||
rm -rf ${_file}.orig
|
||||
done
|
||||
|
||||
-for _file in `find . -depth -name 'CMakeLists.txt'`
|
||||
+find . -depth -name 'CMakeLists.txt' | while read -r _file
|
||||
do
|
||||
sed -i.orig -e 's!.*_sv[mr]light_.*!!g' ${_file} && \
|
||||
touch -r ${_file}.orig ${_file} && \
|
||||
@@ -56,13 +58,7 @@ do
|
||||
rm -rf ${_file}.orig
|
||||
done
|
||||
|
||||
-_file="src/interfaces/modular/Transfer_includes.i" && \
|
||||
-cp -a ${_file} ${_file}.orig && \
|
||||
-echo '%}' >> ${_file} && \
|
||||
-touch -r ${_file}.orig ${_file} && \
|
||||
-rm -rf ${_file}.orig
|
||||
-
|
||||
-_file="src/interfaces/modular/Machine.i" && \
|
||||
+_file="src/interfaces/swig/Machine.i" && \
|
||||
sed -i.orig -e '/.*CSVRLight.*/d' ${_file} && \
|
||||
touch -r ${_file}.orig ${_file} && \
|
||||
rm -rf ${_file}.orig
|
||||
Loading…
Add table
Add a link
Reference in a new issue