Merge pull request #103078 from danieldk/cleanup-libtorch-bin-test
libtorch-bin: cleanup passthru test
commitd36077239cd504a82788411d0a58a24a6c529fb8
authorDaniël de Kok <me@danieldk.eu>
dateMon 9 Nov 2020, 07:49 (6 years ago)
parent1a7131aa71f076
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}