git.iko.soy/typeable/nixpkgs
on master help sign in
libtorch-bin: cleanup passthru test

- Make passthru.tests an attrset. - Remove CMake VERBOSE option. - Remove spurious `cat CMakeLists.txt`. - Run the test as well. - Actually test some functionality.

commita71f07694c1b51ff2100a46ef3a54ff19e4632d5 authorDaniël de Kok <me@danieldk.eu> dateSat 7 Nov 2020, 13:50 (6 years ago) parent126e5c1
3 files changed+18−9
pkgs/development/libraries/science/math/libtorch/bin.nix+1−1 pkgs/development/libraries/science/math/libtorch/test/default.nix+2−6 pkgs/development/libraries/science/math/libtorch/test/test.cpp+15−2
pkgs/development/libraries/science/math/libtorch/bin.nix+1−1
@@ -100,7 +100,7 @@ in stdenv.mkDerivation {
100100
101101 outputs = [ "out" "dev" ];
102102
103− passthru.tests = callPackage ./test { };
103+ passthru.tests.cmake = callPackage ./test { };
104104
105105 meta = with stdenv.lib; {
106106 description = "C++ API of the PyTorch machine learning framework";
pkgs/development/libraries/science/math/libtorch/test/default.nix+2−6
@@ -6,16 +6,12 @@ stdenv.mkDerivation {
66
77 src = ./.;
88
9− postPatch = ''
10− cat CMakeLists.txt
11− '';
12−
13− makeFlags = [ "VERBOSE=1" ];
14−
159 nativeBuildInputs = [ cmake ];
1610
1711 buildInputs = [ libtorch-bin ];
1812
13+ doCheck = true;
14+
1915 installPhase = ''
2016 touch $out
2117 '';
pkgs/development/libraries/science/math/libtorch/test/test.cpp+15−2
@@ -1,7 +1,20 @@
1−#include <torch/torch.h>
1+#undef NDEBUG
2+#include <cassert>
3+
24#include <iostream>
35
6+#include <torch/torch.h>
7+
48int main() {
59 torch::Tensor tensor = torch::eye(3);
6− std::cout << tensor << std::endl;
10+
11+ float checkData[] = {
12+ 1, 0, 0,
13+ 0, 1, 0,
14+ 0, 0, 1
15+ };
16+
17+ torch::Tensor check = torch::from_blob(checkData, {3, 3});
18+
19+ assert(tensor.allclose(check));
720}