{ lib, stdenv, fetchFromGitHub, rocmUpdateScript, pkg-config, cmake, rocm-cmake, clr, openmp, rocblas, hipblas-common, hipblas, hipblaslt, rocmlir, miopen, protobuf, abseil-cpp, half, nlohmann_json, boost, msgpack-cxx, sqlite, # TODO(@LunNova): Swap to `oneDNN` once v3 is supported # Upstream issue: https://github.com/ROCm/AMDMIGraphX/issues/4351 oneDNN_2, blaze, texliveSmall, doxygen, sphinx, docutils, ghostscript, python3Packages, writableTmpDirAsHomeHook, buildDocs ? false, buildTests ? false, gpuTargets ? clr.gpuTargets, }: let latex = lib.optionalAttrs buildDocs ( texliveSmall.withPackages ( ps: with ps; [ latexmk tex-gyre fncychap wrapfig capt-of framed needspace tabulary varwidth titlesec epstopdf ] ) ); in stdenv.mkDerivation (finalAttrs: { pname = "migraphx"; version = "7.1.1"; outputs = [ "out" ] ++ lib.optionals buildDocs [ "doc" ] ++ lib.optionals buildTests [ "test" ]; src = fetchFromGitHub { owner = "ROCm"; repo = "AMDMIGraphX"; rev = "rocm-${finalAttrs.version}"; hash = "sha256-s6w4bF7koK4wnf6leVKBzwIB4X2ROHa3EgX6XuJIAew="; }; nativeBuildInputs = [ pkg-config cmake rocm-cmake clr python3Packages.python ] ++ lib.optionals buildDocs [ latex doxygen sphinx docutils ghostscript python3Packages.sphinx-rtd-theme python3Packages.breathe writableTmpDirAsHomeHook ]; buildInputs = [ openmp rocblas hipblas-common hipblas hipblaslt rocmlir miopen protobuf half nlohmann_json boost msgpack-cxx sqlite oneDNN_2 blaze python3Packages.pybind11 python3Packages.onnx ]; env.LDFLAGS = "-Wl,--allow-shlib-undefined"; cmakeFlags = [ "-DMIGRAPHX_ENABLE_GPU=ON" "-DMIGRAPHX_ENABLE_CPU=ON" "-DMIGRAPHX_ENABLE_FPGA=ON" "-DMIGRAPHX_ENABLE_MLIR=OFF" # LLVM or rocMLIR mismatch? "-DCMAKE_C_COMPILER=amdclang" "-DCMAKE_CXX_COMPILER=amdclang++" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DEMBED_USE=CArrays" # Fixes error with lld "-DDMIGRAPHX_ENABLE_PYTHON=ON" "-DROCM_PATH=${clr}" "-DHIP_ROOT_DIR=${clr}" # migraphx relies on an incompatible fork of composable_kernel # migraphxs relies on miopen which relies on current composable_kernel # impossible to build with this ON; we can't link both of them even if we package both "-DMIGRAPHX_USE_COMPOSABLEKERNEL=OFF" # Manually define CMAKE_INSTALL_