mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
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.
This commit is contained in:
parent
126e5c1bd1
commit
a71f07694c
3 changed files with 18 additions and 9 deletions
|
@ -100,7 +100,7 @@ in stdenv.mkDerivation {
|
||||||
|
|
||||||
outputs = [ "out" "dev" ];
|
outputs = [ "out" "dev" ];
|
||||||
|
|
||||||
passthru.tests = callPackage ./test { };
|
passthru.tests.cmake = callPackage ./test { };
|
||||||
|
|
||||||
meta = with stdenv.lib; {
|
meta = with stdenv.lib; {
|
||||||
description = "C++ API of the PyTorch machine learning framework";
|
description = "C++ API of the PyTorch machine learning framework";
|
||||||
|
|
|
@ -6,16 +6,12 @@ stdenv.mkDerivation {
|
||||||
|
|
||||||
src = ./.;
|
src = ./.;
|
||||||
|
|
||||||
postPatch = ''
|
|
||||||
cat CMakeLists.txt
|
|
||||||
'';
|
|
||||||
|
|
||||||
makeFlags = [ "VERBOSE=1" ];
|
|
||||||
|
|
||||||
nativeBuildInputs = [ cmake ];
|
nativeBuildInputs = [ cmake ];
|
||||||
|
|
||||||
buildInputs = [ libtorch-bin ];
|
buildInputs = [ libtorch-bin ];
|
||||||
|
|
||||||
|
doCheck = true;
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
touch $out
|
touch $out
|
||||||
'';
|
'';
|
||||||
|
|
|
@ -1,7 +1,20 @@
|
||||||
#include <torch/torch.h>
|
#undef NDEBUG
|
||||||
|
#include <cassert>
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <torch/torch.h>
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
torch::Tensor tensor = torch::eye(3);
|
torch::Tensor tensor = torch::eye(3);
|
||||||
std::cout << tensor << std::endl;
|
|
||||||
|
float checkData[] = {
|
||||||
|
1, 0, 0,
|
||||||
|
0, 1, 0,
|
||||||
|
0, 0, 1
|
||||||
|
};
|
||||||
|
|
||||||
|
torch::Tensor check = torch::from_blob(checkData, {3, 3});
|
||||||
|
|
||||||
|
assert(tensor.allclose(check));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue