Skip to content

Commit

Permalink
Upgrade oneDNN to v2.3.3 and package oneDNN Graph API together (#63748)
Browse files Browse the repository at this point in the history
Summary:
This PR upgrades oneDNN to [v2.3.3](https://github.com/oneapi-src/oneDNN/releases/tag/v2.3.3) and includes [Graph API preview release](https://github.com/oneapi-src/oneDNN/releases/tag/graph-v0.2) in one package.

- oneDNN will be located at `pytorch/third_party/ideep/mkl-dnn/third_party/oneDNN`
- The version of oneDNN will be [v2.3.3](https://github.com/oneapi-src/oneDNN/releases/tag/v2.3.3)
  The main changes on CPU:

  - v2.3
    - Extended primitive cache to improve primitive descriptor creation performance.
    - Improved primitive cache performance in multithreaded configurations.
    - Introduced initial optimizations for bfloat16 compute functionality for future Intel Xeon Scalable processor (code name Sapphire Rapids).
    - Improved performance of binary primitive and binary post-op for cases with broadcast and mixed source and destination formats.
    - Improved performance of reduction primitive
    - Improved performance of depthwise convolution primitive with NHWC activations for training cases
  - v2.3.1
    -  Improved int8 GEMM performance for processors with Intel AVX2 and Intel DL Boost support
    - Fixed integer overflow for inner product implementation on CPUs
    - Fixed out of bounds access in GEMM implementation for Intel SSE 4.1
  - v2.3.2
    - Fixed performance regression in fp32 inner product primitive for processors with Intel AVX512 support
  - v2.3.3
    - Reverted check for memory descriptor stride validity for unit dimensions
    - Fixed memory leak in CPU GEMM implementation

  More changes can be found in https://github.com/oneapi-src/oneDNN/releases.
- The Graph API provides flexible API for aggressive fusion, and the preview2 supports fusion for FP32 inference.  See the [Graph API release branch](https://github.com/oneapi-src/oneDNN/tree/dev-graph-preview2) and [spec](https://spec.oneapi.io/onednn-graph/latest/introduction.html) for more details. A separate PR will be submitted to integrate the oneDNN Graph API to Torchscript graph.

Pull Request resolved: #63748

Reviewed By: albanD

Differential Revision: D32153889

Pulled By: malfet

fbshipit-source-id: 536071168ffe312d452f75d54f34c336ca3778c1
  • Loading branch information
chunyuan-w authored and facebook-github-bot committed Dec 9, 2021
1 parent 17641fe commit 9ad05f2
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 32 deletions.
2 changes: 1 addition & 1 deletion cmake/Modules/FindMKLDNN.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ SET(MKLDNN_LIBRARIES)
SET(MKLDNN_INCLUDE_DIR)

SET(IDEEP_ROOT "${PROJECT_SOURCE_DIR}/third_party/ideep")
SET(MKLDNN_ROOT "${IDEEP_ROOT}/mkl-dnn")
SET(MKLDNN_ROOT "${IDEEP_ROOT}/mkl-dnn/third_party/oneDNN")

FIND_PACKAGE(BLAS)
FIND_PATH(IDEEP_INCLUDE_DIR ideep.hpp PATHS ${IDEEP_ROOT} PATH_SUFFIXES include)
Expand Down
61 changes: 31 additions & 30 deletions third_party/mkl-dnn.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,54 @@ _DNNL_RUNTIME_OMP = {
"#cmakedefine DNNL_CPU_THREADING_RUNTIME DNNL_RUNTIME_${DNNL_CPU_THREADING_RUNTIME}": "#define DNNL_CPU_THREADING_RUNTIME DNNL_RUNTIME_OMP",
"#cmakedefine DNNL_CPU_RUNTIME DNNL_RUNTIME_${DNNL_CPU_RUNTIME}": "#define DNNL_CPU_RUNTIME DNNL_RUNTIME_OMP",
"#cmakedefine DNNL_GPU_RUNTIME DNNL_RUNTIME_${DNNL_GPU_RUNTIME}": "#define DNNL_GPU_RUNTIME DNNL_RUNTIME_NONE",
"#cmakedefine DNNL_USE_RT_OBJECTS_IN_PRIMITIVE_CACHE": "/* undef DNNL_USE_RT_OBJECTS_IN_PRIMITIVE_CACHE */",
"#cmakedefine DNNL_WITH_SYCL": "/* #undef DNNL_WITH_SYCL */",
"#cmakedefine DNNL_WITH_LEVEL_ZERO": "/* #undef DNNL_WITH_LEVEL_ZERO */",
"#cmakedefine DNNL_SYCL_CUDA": "/* #undef DNNL_SYCL_CUDA */",
}

template_rule(
name = "include_dnnl_version",
src = "include/oneapi/dnnl/dnnl_version.h.in",
out = "include/oneapi/dnnl/dnnl_version.h",
name = "third_party/oneDNN/include_dnnl_version",
src = "third_party/oneDNN/include/oneapi/dnnl/dnnl_version.h.in",
out = "third_party/oneDNN/include/oneapi/dnnl/dnnl_version.h",
substitutions = {
"@DNNL_VERSION_MAJOR@": "2",
"@DNNL_VERSION_MINOR@": "2",
"@DNNL_VERSION_MINOR@": "3",
"@DNNL_VERSION_PATCH@": "3",
"@DNNL_VERSION_HASH@": "7336ca9f055cf1bfa13efb658fe15dc9b41f0740",
"@DNNL_VERSION_HASH@": "f40443c413429c29570acd6cf5e3d1343cf647b4",
},
)

template_rule(
name = "include_dnnl_config",
src = "include/oneapi/dnnl/dnnl_config.h.in",
out = "include/oneapi/dnnl/dnnl_config.h",
name = "third_party/oneDNN/include_dnnl_config",
src = "third_party/oneDNN/include/oneapi/dnnl/dnnl_config.h.in",
out = "third_party/oneDNN/include/oneapi/dnnl/dnnl_config.h",
substitutions = _DNNL_RUNTIME_OMP,
)

cc_library(
name = "mkl-dnn",
srcs = glob([
"src/common/*.cpp",
"src/cpu/**/*.cpp",
"third_party/oneDNN/src/common/*.cpp",
"third_party/oneDNN/src/cpu/**/*.cpp",
], exclude=[
"src/cpu/aarch64/**/*.cpp",
"third_party/oneDNN/src/cpu/aarch64/**/*.cpp",
]),
hdrs = glob([
"include/oneapi/dnnl/*.h",
"include/oneapi/dnnl/*.hpp",
"include/*.h",
"include/*.hpp",
"src/cpu/**/*.hpp",
"src/cpu/**/*.h",
"src/common/*.hpp",
"src/common/ittnotify/jitprofiling.h",
"third_party/oneDNN/include/oneapi/dnnl/*.h",
"third_party/oneDNN/include/oneapi/dnnl/*.hpp",
"third_party/oneDNN/include/*.h",
"third_party/oneDNN/include/*.hpp",
"third_party/oneDNN/src/cpu/**/*.hpp",
"third_party/oneDNN/src/cpu/**/*.h",
"third_party/oneDNN/src/common/*.hpp",
"third_party/oneDNN/src/common/ittnotify/jitprofiling.h",
], exclude=[
"src/cpu/aarch64/**/*.hpp",
"src/cpu/aarch64/**/*.h",
"third_party/oneDNN/src/cpu/aarch64/**/*.hpp",
"third_party/oneDNN/src/cpu/aarch64/**/*.h",
]) + [
"include/oneapi/dnnl/dnnl_config.h",
"include/oneapi/dnnl/dnnl_version.h",
"third_party/oneDNN/include/oneapi/dnnl/dnnl_config.h",
"third_party/oneDNN/include/oneapi/dnnl/dnnl_version.h",
],
copts = [
"-DUSE_AVX",
Expand All @@ -69,13 +70,13 @@ cc_library(
"//conditions:default": ["-DDNNL_CPU_RUNTIME=2"],
}),
includes = [
"include/",
"include/oneapi/",
"include/oneapi/dnnl/",
"src/",
"src/common/",
"src/cpu/",
"src/cpu/x64/xbyak/",
"third_party/oneDNN/include/",
"third_party/oneDNN/include/oneapi/",
"third_party/oneDNN/include/oneapi/dnnl/",
"third_party/oneDNN/src/",
"third_party/oneDNN/src/common/",
"third_party/oneDNN/src/cpu/",
"third_party/oneDNN/src/cpu/x64/xbyak/",
],
visibility = ["//visibility:public"],
linkopts = [
Expand Down

0 comments on commit 9ad05f2

Please sign in to comment.