Merge pull request #237788 from misuzu/ctranslate2-onednn
ctranslate2: add withOneDNN, withOpenblas, withRuy
This commit is contained in:
@@ -4,9 +4,12 @@
|
||||
, cmake
|
||||
, darwin # Accelerate
|
||||
, llvmPackages # openmp
|
||||
, oneDNN
|
||||
, openblas
|
||||
, withMkl ? false, mkl
|
||||
# Enabling both withOneDNN and withOpenblas is broken
|
||||
# https://github.com/OpenNMT/CTranslate2/issues/1294
|
||||
, withOneDNN ? false, oneDNN
|
||||
, withOpenblas ? true, openblas
|
||||
, withRuy ? true
|
||||
}:
|
||||
|
||||
let
|
||||
@@ -30,19 +33,24 @@ stdenv.mkDerivation rec {
|
||||
|
||||
cmakeFlags = [
|
||||
# https://opennmt.net/CTranslate2/installation.html#build-options
|
||||
"-DWITH_DNNL=OFF" # requires oneDNN>=3.0
|
||||
"-DWITH_OPENBLAS=ON"
|
||||
# https://github.com/OpenNMT/CTranslate2/blob/54810350e662ebdb01ecbf8e4a746f02aeff1dd7/python/tools/prepare_build_environment_linux.sh#L53
|
||||
# https://github.com/OpenNMT/CTranslate2/blob/59d223abcc7e636c1c2956e62482bc3299cc7766/python/tools/prepare_build_environment_macos.sh#L12
|
||||
"-DOPENMP_RUNTIME=COMP"
|
||||
"-DWITH_DNNL=${cmakeBool withOneDNN}"
|
||||
"-DWITH_OPENBLAS=${cmakeBool withOpenblas}"
|
||||
"-DWITH_RUY=${cmakeBool withRuy}"
|
||||
"-DWITH_MKL=${cmakeBool withMkl}"
|
||||
]
|
||||
++ lib.optional stdenv.isDarwin "-DWITH_ACCELERATE=ON";
|
||||
|
||||
buildInputs = [
|
||||
llvmPackages.openmp
|
||||
openblas
|
||||
oneDNN
|
||||
] ++ lib.optional withMkl [
|
||||
buildInputs = lib.optionals withMkl [
|
||||
mkl
|
||||
] ++ lib.optionals withOneDNN [
|
||||
oneDNN
|
||||
] ++ lib.optionals withOpenblas [
|
||||
openblas
|
||||
] ++ lib.optionals stdenv.isDarwin [
|
||||
llvmPackages.openmp
|
||||
darwin.apple_sdk.frameworks.Accelerate
|
||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isx86_64) [
|
||||
darwin.apple_sdk.frameworks.CoreGraphics
|
||||
@@ -54,6 +62,6 @@ stdenv.mkDerivation rec {
|
||||
homepage = "https://github.com/OpenNMT/CTranslate2";
|
||||
changelog = "https://github.com/OpenNMT/CTranslate2/blob/${src.rev}/CHANGELOG.md";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ hexa ];
|
||||
maintainers = with maintainers; [ hexa misuzu ];
|
||||
};
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
, nlohmann_json
|
||||
, msgpack
|
||||
, sqlite
|
||||
, oneDNN
|
||||
, oneDNN_2
|
||||
, blaze
|
||||
, texlive
|
||||
, doxygen
|
||||
@@ -91,7 +91,7 @@ in stdenv.mkDerivation (finalAttrs: {
|
||||
nlohmann_json
|
||||
msgpack
|
||||
sqlite
|
||||
oneDNN
|
||||
oneDNN_2
|
||||
blaze
|
||||
python3Packages.pybind11
|
||||
python3Packages.onnx
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
{ stdenv, lib, fetchFromGitHub, cmake }:
|
||||
|
||||
# This was originally called mkl-dnn, then it was renamed to dnnl, and it has
|
||||
# just recently been renamed again to oneDNN. See here for details:
|
||||
# https://github.com/oneapi-src/oneDNN#oneapi-deep-neural-network-library-onednn
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "oneDNN";
|
||||
version = "2.7.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "oneapi-src";
|
||||
repo = "oneDNN";
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-HBCuSZkApd/6UkAxz/KDFb/gyX2SI1S2GwgXAXSTU/c=";
|
||||
};
|
||||
|
||||
outputs = [ "out" "dev" "doc" ];
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
|
||||
# Tests fail on some Hydra builders, because they do not support SSE4.2.
|
||||
doCheck = false;
|
||||
|
||||
# Fixup bad cmake paths
|
||||
postInstall = ''
|
||||
substituteInPlace $out/lib/cmake/dnnl/dnnl-config.cmake \
|
||||
--replace "\''${PACKAGE_PREFIX_DIR}/" ""
|
||||
|
||||
substituteInPlace $out/lib/cmake/dnnl/dnnl-targets.cmake \
|
||||
--replace "\''${_IMPORT_PREFIX}/" ""
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "oneAPI Deep Neural Network Library (oneDNN)";
|
||||
homepage = "https://01.org/oneDNN";
|
||||
changelog = "https://github.com/oneapi-src/oneDNN/releases/tag/v${version}";
|
||||
license = licenses.asl20;
|
||||
platforms = platforms.all;
|
||||
maintainers = with maintainers; [ alexarice bhipple ];
|
||||
};
|
||||
}
|
||||
@@ -5,13 +5,13 @@
|
||||
# https://github.com/oneapi-src/oneDNN#oneapi-deep-neural-network-library-onednn
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "oneDNN";
|
||||
version = "2.7.1";
|
||||
version = "3.1.1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "oneapi-src";
|
||||
repo = "oneDNN";
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-HBCuSZkApd/6UkAxz/KDFb/gyX2SI1S2GwgXAXSTU/c=";
|
||||
sha256 = "sha256-02S9eG9eAUS7S59YtyaAany07A2V/Cu7Vto2IruDCtc=";
|
||||
};
|
||||
|
||||
outputs = [ "out" "dev" "doc" ];
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
, howard-hinnant-date
|
||||
, nlohmann_json
|
||||
, boost
|
||||
, oneDNN
|
||||
, oneDNN_2
|
||||
, abseil-cpp_202111
|
||||
, gtest
|
||||
, pythonSupport ? false
|
||||
@@ -67,7 +67,7 @@ stdenv.mkDerivation rec {
|
||||
howard-hinnant-date
|
||||
nlohmann_json
|
||||
boost
|
||||
oneDNN
|
||||
oneDNN_2
|
||||
protobuf
|
||||
] ++ lib.optionals pythonSupport [
|
||||
nsync
|
||||
|
||||
@@ -23454,6 +23454,8 @@ with pkgs;
|
||||
|
||||
oneDNN = callPackage ../development/libraries/oneDNN { };
|
||||
|
||||
oneDNN_2 = callPackage ../development/libraries/oneDNN/2.nix { };
|
||||
|
||||
onedrive = callPackage ../applications/networking/sync/onedrive { };
|
||||
|
||||
oneko = callPackage ../applications/misc/oneko { };
|
||||
|
||||
Reference in New Issue
Block a user