diff options
Diffstat (limited to 'infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch')
5 files changed, 36 insertions, 18 deletions
diff --git a/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/bin.nix b/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/bin.nix index 3ae462705868..7c78f61af694 100644 --- a/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/bin.nix +++ b/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/bin.nix @@ -12,9 +12,9 @@ }: let - version = "1.6.0"; + version = "1.7.0"; device = if cudaSupport then "cuda" else "cpu"; - srcs = import ./binary-hashes.nix; + srcs = import ./binary-hashes.nix version; unavailable = throw "libtorch is not available for this platform"; in stdenv.mkDerivation { inherit version; @@ -45,6 +45,14 @@ in stdenv.mkDerivation { # We do not care about Java support... rm -f $out/lib/lib*jni* 2> /dev/null || true + + # Fix up library paths for split outputs + substituteInPlace $dev/share/cmake/Torch/TorchConfig.cmake \ + --replace \''${TORCH_INSTALL_PREFIX}/lib "$out/lib" \ + + substituteInPlace \ + $dev/share/cmake/Caffe2/Caffe2Targets-release.cmake \ + --replace \''${_IMPORT_PREFIX}/lib "$out/lib" \ ''; postFixup = let @@ -100,7 +108,7 @@ in stdenv.mkDerivation { outputs = [ "out" "dev" ]; - passthru.tests = callPackage ./test { }; + passthru.tests.cmake = callPackage ./test { }; meta = with stdenv.lib; { description = "C++ API of the PyTorch machine learning framework"; diff --git a/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/binary-hashes.nix b/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/binary-hashes.nix index 92a2e05e0ba3..6048fe8676b7 100644 --- a/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/binary-hashes.nix +++ b/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/binary-hashes.nix @@ -1,14 +1,14 @@ -{ +version: { x86_64-darwin-cpu = { - url = "https://download.pytorch.org/libtorch/cpu/libtorch-macos-1.6.0.zip"; - sha256 = "0d4n7la31qzl4s9pwvm07la7q6lhcwiww0yjpfz3kw6nvx84p22r"; + url = "https://download.pytorch.org/libtorch/cpu/libtorch-macos-${version}.zip"; + sha256 = "1912lklil0i7i10j1fm4qzcq96cc8c281l9fn5gfbwa2wwry0r59"; }; x86_64-linux-cpu = { - url = "https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-1.6.0%2Bcpu.zip"; - sha256 = "1975b4zvyihzh89vnwspw0vf9qr05sxj8939vcrlmv3gzvdspcxz"; + url = "https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-${version}%2Bcpu.zip"; + sha256 = "0jdd7bjcy20xz2gfv8f61zdrbzxz5425bnqaaqgrwpzvd45ay8px"; }; x86_64-linux-cuda = { - url = "https://download.pytorch.org/libtorch/cu102/libtorch-cxx11-abi-shared-with-deps-1.6.0.zip"; - sha256 = "127qnfyi1faqbm40sbnsyqxjhrqj82bzwqyz7c1hs2bm0zgrrpya"; + url = "https://download.pytorch.org/libtorch/cu102/libtorch-cxx11-abi-shared-with-deps-${version}.zip"; + sha256 = "1ag6lvf3a400ivqq4g9cxpmxzlfrga0y5ssjy0rfpw6i1xljibn6"; }; } diff --git a/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/CMakeLists.txt b/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/CMakeLists.txt index b302449ef772..4e96704a4c17 100644 --- a/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/CMakeLists.txt +++ b/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/CMakeLists.txt @@ -1,3 +1,4 @@ +cmake_minimum_required(VERSION 3.0) find_package(Torch REQUIRED) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}") add_executable(test test.cpp) diff --git a/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/default.nix b/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/default.nix index d661ec28db98..e69807871f46 100644 --- a/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/default.nix +++ b/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/default.nix @@ -6,16 +6,12 @@ stdenv.mkDerivation { src = ./.; - postPatch = '' - cat CMakeLists.txt - ''; - - makeFlags = [ "VERBOSE=1" ]; - nativeBuildInputs = [ cmake ]; buildInputs = [ libtorch-bin ]; + doCheck = true; + installPhase = '' touch $out ''; diff --git a/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/test.cpp b/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/test.cpp index 5537724ce5f6..ca238fba521d 100644 --- a/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/test.cpp +++ b/infra/libkookie/nixpkgs/pkgs/development/libraries/science/math/libtorch/test/test.cpp @@ -1,7 +1,20 @@ -#include <torch/torch.h> +#undef NDEBUG +#include <cassert> + #include <iostream> +#include <torch/torch.h> + int main() { 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)); } |