about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/taco/default.nix
blob: 693b5f25f9904a82e7ad77bfebb6e553cd2352d2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ stdenv
, lib
, fetchgit
, cmake
, llvmPackages
, enablePython ? false
, python ? null
}:

let pyEnv = python.withPackages (p: with p; [ numpy scipy ]);

in stdenv.mkDerivation rec {
  pname = "taco";
  version = "unstable-2022-08-02";

  src = fetchgit {
    url = "https://github.com/tensor-compiler/${pname}.git";
    rev = "2b8ece4c230a5f0f0a74bc6f48e28edfb6c1c95e";
    fetchSubmodules = true;
    hash = "sha256-PnBocyRLiLALuVS3Gkt/yJeslCMKyK4zdsBI8BFaTSg=";
  };

  # Remove test cases from cmake build as they violate modern C++ expectations
  patches = [ ./taco.patch ];

  nativeBuildInputs = [ cmake ];

  buildInputs = lib.optional stdenv.isDarwin llvmPackages.openmp;

  propagatedBuildInputs = lib.optional enablePython pyEnv;

  cmakeFlags = [
    "-DOPENMP=ON"
  ] ++ lib.optional enablePython "-DPYTHON=ON" ;

  postInstall = lib.strings.optionalString enablePython ''
    mkdir -p $out/${python.sitePackages}
    cp -r lib/pytaco $out/${python.sitePackages}/.
  '';

  # The standard CMake test suite fails a single test of the CLI interface.
  doCheck = false;

  # Cython somehow gets built with references to /build/.
  # However, the python module works flawlessly.
  dontFixup = enablePython;

  meta = with lib; {
    description = "Computes sparse tensor expressions on CPUs and GPUs";
    mainProgram = "taco";
    license = licenses.mit;
    homepage = "https://github.com/tensor-compiler/taco";
    maintainers = [ maintainers.sheepforce ];
  };
}