Skip to content
This repository was archived by the owner on Apr 6, 2026. It is now read-only.

Commit 967c94e

Browse files
authored
Add onednn support for XPU (#227)
Signed-off-by: Wang, Yi A <yi.a.wang@intel.com>
1 parent 8ec5c3b commit 967c94e

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

build2cmake/src/templates/xpu/torch-extension.cmake

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
define_gpu_extension_target(
22
{{ ops_name }}
33
DESTINATION {{ ops_name }}
4+
INCLUDE_DIRECTORIES "${ONEDNN_XPU_INCLUDE_DIR}"
45
LANGUAGE ${GPU_LANG}
56
SOURCES ${SRC}
67
COMPILE_FLAGS ${sycl_flags}

lib/torch-extension/default.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ let
5252
);
5353

5454
oneapi-torch-dev = xpuPackages.oneapi-torch-dev.override { inherit stdenv; };
55+
onednn-xpu = xpuPackages.onednn-xpu.override { inherit stdenv oneapi-torch-dev; };
5556

5657
# On Darwin, we need the host's xcrun for `xcrun metal` to compile Metal shaders.
5758
# t's not supported by the nixpkgs shim.
@@ -132,7 +133,7 @@ stdenv.mkDerivation (prevAttrs: {
132133
++ lib.optionals rocmSupport (with rocmPackages; [ hipsparselt ])
133134
++ lib.optionals xpuSupport ([
134135
oneapi-torch-dev
135-
xpuPackages.onednn-xpu
136+
onednn-xpu
136137
])
137138
++ lib.optionals stdenv.hostPlatform.isDarwin [
138139
apple-sdk_15
@@ -172,6 +173,9 @@ stdenv.mkDerivation (prevAttrs: {
172173
(lib.cmakeFeature "CMAKE_HIP_COMPILER_ROCM_ROOT" "${clr}")
173174
(lib.cmakeFeature "HIP_ROOT_DIR" "${clr}")
174175
]
176+
++ lib.optionals xpuSupport [
177+
(lib.cmakeFeature "ONEDNN_XPU_INCLUDE_DIR" "${onednn-xpu}/include")
178+
]
175179
++ lib.optionals stdenv.hostPlatform.isDarwin [
176180
# Use host compiler for Metal. Not included in the redistributable SDK.
177181
(lib.cmakeFeature "METAL_COMPILER" "${xcrunHost}/bin/xcrunHost")

0 commit comments

Comments
 (0)