lol

tensorflow-lite: init at v2.5.0

authored by

Phillip Cloud and committed by
Phillip Cloud
de470025 3f7c764f

+206
+159
pkgs/development/libraries/science/math/tensorflow-lite/default.nix
··· 1 + { stdenv 2 + , bash 3 + , abseil-cpp 4 + , fetchFromGitHub 5 + , fetchFromGitLab 6 + , fetchpatch 7 + , fetchurl 8 + , flatbuffers 9 + , hostPlatform 10 + , lib 11 + , zlib 12 + }: 13 + let 14 + tflite-eigen = fetchFromGitLab { 15 + owner = "libeigen"; 16 + repo = "eigen"; 17 + rev = "3d9051ea84a5089b277c88dac456b3b1576bfa7f"; 18 + sha256 = "1y3f2jvimb5i904f4n37h23cv2pkdlbz8656s0kga1y7c0p50wif"; 19 + }; 20 + 21 + gemmlowp-src = fetchFromGitHub { 22 + owner = "google"; 23 + repo = "gemmlowp"; 24 + rev = "fda83bdc38b118cc6b56753bd540caa49e570745"; 25 + sha256 = "1sbp8kmr2azwlvfbzryy1frxi99jhsh1nc93bdbxdf8zdgpv0kxl"; 26 + }; 27 + 28 + neon-2-sse-src = fetchFromGitHub { 29 + owner = "intel"; 30 + repo = "ARM_NEON_2_x86_SSE"; 31 + rev = "1200fe90bb174a6224a525ee60148671a786a71f"; 32 + sha256 = "0fhxch711ck809dpq1myxz63jiiwfcnxvj45ww0kg8s0pqpn5kv6"; 33 + }; 34 + 35 + farmhash-src = fetchFromGitHub { 36 + owner = "google"; 37 + repo = "farmhash"; 38 + rev = "816a4ae622e964763ca0862d9dbd19324a1eaf45"; 39 + sha256 = "1mqxsljq476n1hb8ilkrpb39yz3ip2hnc7rhzszz4sri8ma7qzp6"; 40 + }; 41 + 42 + fft2d-src = fetchurl { 43 + url = "http://www.kurims.kyoto-u.ac.jp/~ooura/fft2d.tgz"; 44 + sha256 = "ada7e99087c4ed477bfdf11413f2ba8db8a840ba9bbf8ac94f4f3972e2a7cec9"; 45 + }; 46 + 47 + fp16-src = fetchFromGitHub { 48 + owner = "Maratyszcza"; 49 + repo = "FP16"; 50 + rev = "4dfe081cf6bcd15db339cf2680b9281b8451eeb3"; 51 + sha256 = "06a8dfl3a29r93nxpp6hpywsajz5d555n3sqd3i6krybb6swnvh7"; 52 + }; 53 + 54 + ruy-src = fetchFromGitHub { 55 + owner = "google"; 56 + repo = "ruy"; 57 + rev = "23633b37099b614a2f836ef012cafc8087fdb98c"; 58 + sha256 = "14k9hz6ss8qy8nsajk6lrq25f6qxrldxky31ijw0dpqnfnnswrx4"; 59 + }; 60 + 61 + cpuinfo-src = fetchFromGitHub { 62 + owner = "pytorch"; 63 + repo = "cpuinfo"; 64 + rev = "5916273f79a21551890fd3d56fc5375a78d1598d"; 65 + sha256 = "0q6760xdxsg18acdv8vq3yrq7ksr7wsm8zbyan01zf2khnb6fw4x"; 66 + }; 67 + in 68 + stdenv.mkDerivation rec { 69 + pname = "tensorflow-lite"; 70 + version = "2.5.0"; 71 + 72 + src = fetchFromGitHub { 73 + owner = "tensorflow"; 74 + repo = "tensorflow"; 75 + rev = "v${version}"; 76 + sha256 = "1jdw2i1rq06zqd6aabh7bbm0avsg4pygnfmd7gviv0blhih9054l"; 77 + }; 78 + 79 + buildInputs = [ zlib flatbuffers ]; 80 + 81 + dontConfigure = true; 82 + 83 + postPatch = '' 84 + substituteInPlace ./tensorflow/lite/tools/make/Makefile \ 85 + --replace /bin/bash ${bash}/bin/bash \ 86 + --replace /bin/sh ${bash}/bin/sh 87 + ''; 88 + 89 + makefile = "tensorflow/lite/tools/make/Makefile"; 90 + 91 + preBuild = 92 + let 93 + includes = 94 + lib.concatMapStringsSep 95 + " " 96 + (subdir: "-I $PWD/tensorflow/lite/tools/make/downloads/${subdir}") 97 + [ 98 + "neon_2_sse" 99 + "gemmlowp" 100 + "absl" 101 + "fp16/include" 102 + "farmhash/src" 103 + "ruy" 104 + "cpuinfo" 105 + "cpuinfo/src" 106 + "cpuinfo/include" 107 + "cpuinfo/deps/clog/include" 108 + "eigen" 109 + ]; 110 + in 111 + '' 112 + # enter the vendoring lair of doom 113 + 114 + prefix="$PWD/tensorflow/lite/tools/make/downloads" 115 + 116 + mkdir -p "$prefix" 117 + 118 + tar xzf ${fft2d-src} -C "$prefix" 119 + 120 + ln -s ${ruy-src} "$prefix/ruy" 121 + ln -s ${gemmlowp-src} "$prefix/gemmlowp" 122 + ln -s ${neon-2-sse-src} "$prefix/neon_2_sse" 123 + ln -s ${farmhash-src} "$prefix/farmhash" 124 + ln -s ${cpuinfo-src} "$prefix/cpuinfo" 125 + ln -s ${fp16-src} "$prefix/fp16" 126 + ln -s ${tflite-eigen} "$prefix/eigen" 127 + 128 + # tensorflow lite is using the *source* of flatbuffers 129 + ln -s ${flatbuffers.src} "$prefix/flatbuffers" 130 + 131 + # tensorflow lite expects to compile abseil into `libtensorflow-lite.a` 132 + ln -s ${abseil-cpp.src} "$prefix/absl" 133 + 134 + buildFlagsArray+=(INCLUDES="-I $PWD ${includes}" TARGET_TOOLCHAIN_PREFIX="" -j$NIX_BUILD_CORES all) 135 + ''; 136 + 137 + installPhase = '' 138 + mkdir "$out" 139 + 140 + # copy the static lib and binaries into the output dir 141 + cp -r ./tensorflow/lite/tools/make/gen/linux_${hostPlatform.uname.processor}/{bin,lib} "$out" 142 + 143 + find ./tensorflow/lite -type f -name '*.h' | while read f; do 144 + path="$out/include/''${f/.\//}" 145 + install -D "$f" "$path" 146 + 147 + # remove executable bit from headers 148 + chmod -x "$path" 149 + done 150 + ''; 151 + 152 + meta = with lib; { 153 + description = "An open source deep learning framework for on-device inference."; 154 + homepage = "https://www.tensorflow.org/lite"; 155 + license = licenses.asl20; 156 + maintainers = with maintainers; [ cpcloud ]; 157 + platforms = [ "x86_64-linux" "aarch64-linux" ]; 158 + }; 159 + }
+45
pkgs/development/libraries/science/math/tensorflow-lite/eigen_include_dir.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index 28103856e..a36909c0e 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -449,13 +449,6 @@ install(FILES 6 + DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel 7 + ) 8 + 9 + -if(EIGEN_BUILD_PKGCONFIG) 10 + - configure_file(eigen3.pc.in eigen3.pc @ONLY) 11 + - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/eigen3.pc 12 + - DESTINATION ${PKGCONFIG_INSTALL_DIR} 13 + - ) 14 + -endif() 15 + - 16 + install(DIRECTORY Eigen DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel) 17 + 18 + add_subdirectory(doc EXCLUDE_FROM_ALL) 19 + @@ -570,8 +563,15 @@ set ( EIGEN_VERSION_MAJOR ${EIGEN_WORLD_VERSION} ) 20 + set ( EIGEN_VERSION_MINOR ${EIGEN_MAJOR_VERSION} ) 21 + set ( EIGEN_VERSION_PATCH ${EIGEN_MINOR_VERSION} ) 22 + set ( EIGEN_DEFINITIONS "") 23 + -set ( EIGEN_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/${INCLUDE_INSTALL_DIR}" ) 24 + set ( EIGEN_ROOT_DIR ${CMAKE_INSTALL_PREFIX} ) 25 + +GNUInstallDirs_get_absolute_install_dir(EIGEN_INCLUDE_DIR INCLUDE_INSTALL_DIR) 26 + + 27 + +if(EIGEN_BUILD_PKGCONFIG) 28 + + configure_file(eigen3.pc.in eigen3.pc @ONLY) 29 + + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/eigen3.pc 30 + + DESTINATION ${PKGCONFIG_INSTALL_DIR} 31 + + ) 32 + +endif() 33 + 34 + # Interface libraries require at least CMake 3.0 35 + if (NOT CMAKE_VERSION VERSION_LESS 3.0) 36 + diff --git a/eigen3.pc.in b/eigen3.pc.in 37 + index 3368a3aa1..d6778bf06 100644 38 + --- a/eigen3.pc.in 39 + +++ b/eigen3.pc.in 40 + @@ -6,4 +6,4 @@ Description: A C++ template library for linear algebra: vectors, matrices, and r 41 + Requires: 42 + Version: @EIGEN_VERSION_NUMBER@ 43 + Libs: 44 + -Cflags: -I${prefix}/@INCLUDE_INSTALL_DIR@ 45 + +Cflags: -I@EIGEN_INCLUDE_DIR@
+2
pkgs/top-level/all-packages.nix
··· 1950 1950 cudaSupport = config.cudaSupport or false; 1951 1951 }; 1952 1952 1953 + tensorflow-lite = callPackage ../development/libraries/science/math/tensorflow-lite { }; 1954 + 1953 1955 behdad-fonts = callPackage ../data/fonts/behdad-fonts { }; 1954 1956 1955 1957 bfetch = callPackage ../tools/misc/bfetch { };