1{ stdenv
2, lib
3, fetchgit
4, cmake
5, llvmPackages
6, enablePython ? false
7, python ? null
8}:
9
10let pyEnv = python.withPackages (p: with p; [ numpy scipy ]);
11
12in stdenv.mkDerivation rec {
13 pname = "taco";
14 version = "unstable-2022-08-02";
15
16 src = fetchgit {
17 url = "https://github.com/tensor-compiler/${pname}.git";
18 rev = "2b8ece4c230a5f0f0a74bc6f48e28edfb6c1c95e";
19 fetchSubmodules = true;
20 hash = "sha256-PnBocyRLiLALuVS3Gkt/yJeslCMKyK4zdsBI8BFaTSg=";
21 };
22
23 # Remove test cases from cmake build as they violate modern C++ expectations
24 patches = [ ./taco.patch ];
25
26 nativeBuildInputs = [ cmake ];
27
28 buildInputs = lib.optional stdenv.isDarwin llvmPackages.openmp;
29
30 propagatedBuildInputs = lib.optional enablePython pyEnv;
31
32 cmakeFlags = [
33 "-DOPENMP=ON"
34 ] ++ lib.optional enablePython "-DPYTHON=ON" ;
35
36 postInstall = lib.strings.optionalString enablePython ''
37 mkdir -p $out/${python.sitePackages}
38 cp -r lib/pytaco $out/${python.sitePackages}/.
39 '';
40
41 # The standard CMake test suite fails a single test of the CLI interface.
42 doCheck = false;
43
44 # Cython somehow gets built with references to /build/.
45 # However, the python module works flawlessly.
46 dontFixup = enablePython;
47
48 meta = with lib; {
49 description = "Computes sparse tensor expressions on CPUs and GPUs";
50 license = licenses.mit;
51 homepage = "https://github.com/tensor-compiler/taco";
52 maintainers = [ maintainers.sheepforce ];
53 };
54}