Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Change inner mxnet flags nomenclature for oneDNN library (#19944)
Browse files Browse the repository at this point in the history
This change includes:
* changing MXNET_USE_MKLDNN flag name to MXNET_USE_ONEDNN
* changing USE_MKLDNN flag name to USE_ONEDNN
* changing 3rdparty/mkldnn folder name to 3rdparty/onednn
* changing include/mkldnn folder name to include/onednn
* changing MKLDNN occurences in build and documentation files to ONEDNN
* adding Bartosz Kuncer to contributors list
  • Loading branch information
bartekkuncer authored Mar 15, 2021
1 parent 6834f63 commit aa92db0
Show file tree
Hide file tree
Showing 224 changed files with 531 additions and 530 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -171,5 +171,5 @@ coverage.xml
cmake_options.yml

# header file generated at compile time
include/mkldnn/oneapi/dnnl/dnnl_version.h
include/mkldnn/oneapi/dnnl/dnnl_config.h
include/onednn/oneapi/dnnl/dnnl_version.h
include/onednn/oneapi/dnnl/dnnl_config.h
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
[submodule "3rdparty/googletest"]
path = 3rdparty/googletest
url = https://github.com/google/googletest.git
[submodule "3rdparty/mkldnn"]
path = 3rdparty/mkldnn
url = https://github.com/oneapi-src/oneDNN.git
[submodule "3rdparty/tvm"]
path = 3rdparty/tvm
url = https://github.com/apache/incubator-tvm.git
Expand All @@ -28,3 +25,6 @@
[submodule "3rdparty/intgemm"]
path = 3rdparty/intgemm
url = https://github.com/kpu/intgemm
[submodule "3rdparty/onednn"]
path = 3rdparty/onednn
url = https://github.com/oneapi-src/oneDNN
26 changes: 13 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ option(USE_F16C "Build with x86 F16C instruction support" ON) # autodetects supp
option(USE_LAPACK "Build with lapack support" ON)
option(USE_MKL_LAYERNORM "Use layer normalization from MKL, which is currently slower than internal. No effect unless USE_BLAS=MKL (or mkl)." OFF)
if((NOT APPLE) AND (NOT MSVC) AND (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64") AND (NOT CMAKE_CROSSCOMPILING))
option(USE_MKLDNN "Build with MKL-DNN support" ON)
option(USE_ONEDNN "Build with ONEDNN support" ON)
else()
option(USE_MKLDNN "Build with MKL-DNN support" OFF)
option(USE_ONEDNN "Build with ONEDNN support" OFF)
endif()
cmake_dependent_option(USE_INTGEMM "Build with x86_64 intgemm library for low-precision multiplication" ON "CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64" OFF)
if(NOT MSVC)
Expand Down Expand Up @@ -257,7 +257,7 @@ endif()
if(USE_MKL_LAYERNORM)
add_definitions(-DMXNET_USE_MKL_LAYERNORM=1)
endif()
if(USE_MKLDNN)
if(USE_ONEDNN)
# CPU architecture (e.g., C5) can't run on another architecture (e.g., g3).
if(MSVC)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /EHsc")
Expand All @@ -272,7 +272,7 @@ if(USE_MKLDNN)
endif()
endif()

function(load_mkldnn)
function(load_onednn)
set(MKLDNN_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
set(MKLDNN_BUILD_EXAMPLES OFF CACHE INTERNAL "" FORCE)
set(MKLDNN_ARCH_OPT_FLAGS "" CACHE INTERNAL "" FORCE)
Expand All @@ -285,13 +285,13 @@ if(USE_MKLDNN)
set(MKLDNN_CPU_RUNTIME SEQ CACHE INTERNAL "" FORCE)
endif()

set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/mkldnn")
add_subdirectory(3rdparty/mkldnn)
set(CMAKE_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/onednn")
add_subdirectory(3rdparty/onednn)
endfunction()
load_mkldnn()
include_directories(3rdparty/mkldnn/include)
include_directories(${PROJECT_BINARY_DIR}/3rdparty/mkldnn/include)
add_definitions(-DMXNET_USE_MKLDNN=1)
load_onednn()
include_directories(3rdparty/onednn/include)
include_directories(${PROJECT_BINARY_DIR}/3rdparty/onednn/include)
add_definitions(-DMXNET_USE_ONEDNN=1)
list(APPEND mxnet_LINKER_LIBS dnnl)
set_target_properties(dnnl PROPERTIES CXX_CLANG_TIDY "") # don't lint 3rdparty dependency
endif()
Expand Down Expand Up @@ -836,12 +836,12 @@ if(USE_DIST_KVSTORE)
set_target_properties(pslite PROPERTIES CXX_CLANG_TIDY "") # don't lint 3rdparty dependency
endif()

if(USE_MKLDNN)
if(USE_ONEDNN)
add_custom_command(TARGET mxnet POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/3rdparty/mkldnn/include/oneapi/dnnl/dnnl_config.h ${CMAKE_SOURCE_DIR}/include/mkldnn/oneapi/dnnl/
${CMAKE_BINARY_DIR}/3rdparty/onednn/include/oneapi/dnnl/dnnl_config.h ${CMAKE_SOURCE_DIR}/include/onednn/oneapi/dnnl/
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_BINARY_DIR}/3rdparty/mkldnn/include/oneapi/dnnl/dnnl_version.h ${CMAKE_SOURCE_DIR}/include/mkldnn/oneapi/dnnl/)
${CMAKE_BINARY_DIR}/3rdparty/onednn/include/oneapi/dnnl/dnnl_version.h ${CMAKE_SOURCE_DIR}/include/onednn/oneapi/dnnl/)
endif()

if(USE_INTGEMM)
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ List of Contributors
* [Paweł Głomski](https://github.com/PawelGlomski-Intel)
* [Andrzej Kotlowski](https://github.com/anko-intel)
* [Yingxiao Du](https://github.com/Duconnor)
* [Bartosz Kuncer](https://github.com/bartekkuncer)

Label Bot
---------
Expand Down
16 changes: 8 additions & 8 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@
3rdparty/tvm/3rdparty/dmlc-core
3rdparty/tvm/3rdparty/dlpack
3rdparty/ps-lite
3rdparty/mkldnn
3rdparty/onednn
3rdparty/googletest/googlemock/scripts/generator
3rdparty/onnx-tensorrt/third_party/onnx/third_party/benchmark
3rdparty/mkldnn/tests/benchdnn (Copy of the License available at top of current file)
3rdparty/onednn/tests/benchdnn (Copy of the License available at top of current file)
src/operator/special_functions-inl.h Cephes Library Functions (Copy of the License available at top of current file)
3rdparty/mkldnn/doc/assets/mathjax (Copy of the License available at top of current file)
3rdparty/onednn/doc/assets/mathjax (Copy of the License available at top of current file)
docs/python_docs/themes/mx-theme/mxtheme/static/material-design-icons-3.0.1 (Copy of the License available at top of current file)
docs/python_docs/themes/mx-theme/mxtheme/static/font/Roboto (Copy of the License available at top of current file)
3rdparty/tvm/3rdparty/bfloat16/bfloat16.cc (Copy of the License available at top of current file)
Expand All @@ -256,10 +256,10 @@
3-clause BSD license
=======================================================================================

3rdparty/mkldnn/src/cpu/x64/xbyak
3rdparty/mkldnn/tests/gtests/gtest
3rdparty/mkldnn/cmake/FindOpenCL.cmake (Copy of the License available at licenses/BSD3-cmake)
3rdparty/mkldnn/src/cpu/x64/jit_utils/jitprofiling/
3rdparty/onednn/src/cpu/x64/xbyak
3rdparty/onednn/tests/gtests/gtest
3rdparty/onednn/cmake/FindOpenCL.cmake (Copy of the License available at licenses/BSD3-cmake)
3rdparty/onednn/src/cpu/x64/jit_utils/jitprofiling/
3rdparty/onnx-tensorrt/third_party/onnx/third_party/pybind11/tools/FindPythonLibsNew.cmake
3rdparty/ctc_include/contrib/moderngpu
3rdparty/nvidia_cub
Expand Down Expand Up @@ -333,7 +333,7 @@
=======================================================================================

3rdparty/intgemm/test/3rd_party/catch.hpp (Copy of the License available at licenses/BOOST1_0)
3rdparty/mkldnn/src/common/primitive_hashing.hpp
3rdparty/onednn/src/common/primitive_hashing.hpp

=======================================================================================
LLVM Release License
Expand Down
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1973,7 +1973,7 @@ Note: this feature is still experimental, for more details, refer to [design doc
* Add back R tests and fix typo around R and perl tests (#13940)
* Fix document build (#13927)
* Temporarily disables windows pipeline to unblock PRs (#14261)
* Fix USE_MKLDNN check in Makefile (#13775)
* Fix USE_ONEDNN check in Makefile (#13775)
* Fix spelling in threaded_engine_test (#14709)
* Fix cmake options parsing in dev_menu (#13458)
* Add Local test stage and option to jump directly to menu item from commandline (#13809)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ What's New

### Ecosystem News

* [MKLDNN for Faster CPU Performance](docs/python_docs/python/tutorials/performance/backend/mkldnn/mkldnn_readme.md)
* [ONEDNN for Faster CPU Performance](docs/python_docs/python/tutorials/performance/backend/mkldnn/mkldnn_readme.md)
* [MXNet Memory Monger, Training Deeper Nets with Sublinear Memory Cost](https://github.com/dmlc/mxnet-memonger)
* [Tutorial for NVidia GTC 2016](https://github.com/dmlc/mxnet-gtc-tutorial)
* [MXNet.js: Javascript Package for Deep Learning in Browser (without server)](https://github.com/dmlc/mxnet.js/)
Expand Down
2 changes: 1 addition & 1 deletion benchmark/opperf/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Benchmarks are usually done end-to-end for a given Network Architecture. For exa
2. A standard Network Architecture like ResNet-50 is made up of many operators Ex: Convolution2D, Softmax, Dense and more. Consider the following scenarios:
1. We improved the performance of Convolution2D operator, but due to a bug, Softmax performance went down. Overall, we may observe end to end benchmarks are running fine, we may miss out the performance degradation of a single operator which can accumulate and become untraceable.
2. You need to see in a given network, which operator is taking maximum time and plan optimization work. With end to end benchmarks, it is hard to get more fine grained numbers at operator level.
3. We need to know on different hardware infrastructure (Ex: CPU with MKLDNN, GPU with NVIDIA CUDA and cuDNN) how different operators performs. With these details, we can plan the optimization work at operator level, which could exponentially boost up end to end performance.
3. We need to know on different hardware infrastructure (Ex: CPU with ONEDNN, GPU with NVIDIA CUDA and cuDNN) how different operators performs. With these details, we can plan the optimization work at operator level, which could exponentially boost up end to end performance.
4. You want to have nightly performance tests across all operators in a deep learning framework to catch regressions early.
5. We can integrate this framework with a CI/CD system to run per operator performance tests for PRs. Example: When a PR modifies the kernel of TransposeConv2D, we can run benchmarks of TransposeConv2D operator to verify performance.

Expand Down
8 changes: 4 additions & 4 deletions cd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@

## Introduction

MXNet aims to support a variety of frontends, e.g. Python, Java, Perl, R, etc. as well as environments (Windows, Linux, Mac, with or without GPU, with or without MKL-DNN support, etc.). This package contains a small continuous delivery (CD) framework used to automate the delivery nightly and release builds across our delivery channels.
MXNet aims to support a variety of frontends, e.g. Python, Java, Perl, R, etc. as well as environments (Windows, Linux, Mac, with or without GPU, with or without ONEDNN support, etc.). This package contains a small continuous delivery (CD) framework used to automate the delivery nightly and release builds across our delivery channels.

<!-- TODO: Add links to the actual jobs, once this is live on PROD -->

The CD process is driven by the [CD pipeline job](Jenkinsfile_cd_pipeline), which orchestrates the order in which the artifacts are delivered. For instance, first publish the libmxnet library before publishing the pip package. It does this by triggering the [release job](Jenkinsfile_release_job) with a specific set of parameters for each delivery channel. The release job executes the specific release pipeline for a delivery channel across all MXNet *variants*.

A variant is a specific environment or features for which MXNet is compiled. For instance CPU, GPU with CUDA v10.1, CUDA v10.2 with MKL-DNN support, etc.
A variant is a specific environment or features for which MXNet is compiled. For instance CPU, GPU with CUDA v10.1, CUDA v10.2 with ONEDNN support, etc.

Currently, below variants are supported. All of these variants except native have MKL-DNN backend enabled.
Currently, below variants are supported. All of these variants except native have ONEDNN backend enabled.

* *cpu*: CPU
* *native*: CPU without MKL-DNN
* *native*: CPU without ONEDNN
* *cu101*: CUDA 10.1
* *cu102*: CUDA 10.2
* *cu110*: CUDA 11.0
Expand Down
2 changes: 1 addition & 1 deletion cd/mxnet_lib/Jenkins_pipeline.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ licenses = 'licenses/*'

// libmxnet dependencies
mx_native_deps = 'lib/libgfortran.so.*, lib/libopenblas.so.0'
mx_deps = 'lib/libgfortran.so.*, lib/libopenblas.so.0, include/mkldnn/oneapi/dnnl/dnnl_version.h, include/mkldnn/oneapi/dnnl/dnnl_config.h'
mx_deps = 'lib/libgfortran.so.*, lib/libopenblas.so.0, include/onednn/oneapi/dnnl/dnnl_version.h, include/onednn/oneapi/dnnl/dnnl_config.h'

// library type
// either static or dynamic - depending on how it links to its dependencies
Expand Down
8 changes: 4 additions & 4 deletions cd/python/pypi/pypi_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export mxnet_variant=${1:?"Please specify the mxnet variant"}

# Due to this PR: https://github.com/apache/incubator-mxnet/pull/14899
# The setup.py expects that mkldnn_version.h be present in
# mxnet-build/3rdparty/mkldnn/build/install/include
# mxnet-build/3rdparty/onednn/build/install/include
# The artifact repository stores this file in the dependencies
# and CD unpacks it to a directory called cd_misc
# Nov. 2019 Update: With v1.1, MKL-DNN is renaming to DNNL. Hence changing the prefix of file name.
if [ -f "cd_misc/dnnl_version.h" ]; then
mkdir -p 3rdparty/mkldnn/include/oneapi/dnnl
cp cd_misc/dnnl_version.h 3rdparty/mkldnn/include/oneapi/dnnl/.
cp cd_misc/dnnl_config.h 3rdparty/mkldnn/include/oneapi/dnnl/.
mkdir -p 3rdparty/onednn/include/oneapi/dnnl
cp cd_misc/dnnl_version.h 3rdparty/onednn/include/oneapi/dnnl/.
cp cd_misc/dnnl_config.h 3rdparty/onednn/include/oneapi/dnnl/.
fi

# Create wheel workspace
Expand Down
4 changes: 2 additions & 2 deletions cd/utils/artifact_repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ If not set, derived through the value of sys.platform (https://docs.python.org/3

Manually configured through the --variant argument. The current variants are: cpu, native, cu101, cu102, cu110, cu112.

As long as the tool is being run from the MXNet code base, the runtime feature detection tool (https://github.com/larroy/mxnet/blob/dd432b7f241c9da2c96bcb877c2dc84e6a1f74d4/docs/api/python/libinfo/libinfo.md) can be used to detect whether the library has been compiled with MKL (library has MKL-DNN feature enabled) and/or CUDA support (compiled with CUDA feature enabled).
As long as the tool is being run from the MXNet code base, the runtime feature detection tool (https://github.com/larroy/mxnet/blob/dd432b7f241c9da2c96bcb877c2dc84e6a1f74d4/docs/api/python/libinfo/libinfo.md) can be used to detect whether the library has been compiled with MKL (library has ONEDNN feature enabled) and/or CUDA support (compiled with CUDA feature enabled).

If it has been compiled with CUDA support, the output of /usr/local/cuda/bin/nvcc --version can be mined for the exact CUDA version (eg. 8.0, 9.0, etc.).

By knowing which features are enabled on the binary, and if necessary, which CUDA version is installed on the machine, the value for the variant argument can be calculated. Eg. if CUDA features are enabled, and nvcc reports cuda version 10.2, then the variant would be cu102. If neither MKL-DNN nor CUDA features are enabled, the variant would be native.
By knowing which features are enabled on the binary, and if necessary, which CUDA version is installed on the machine, the value for the variant argument can be calculated. Eg. if CUDA features are enabled, and nvcc reports cuda version 10.2, then the variant would be cu102. If neither ONEDNN nor CUDA features are enabled, the variant would be native.

**Dependency Linking**

Expand Down
2 changes: 1 addition & 1 deletion cd/utils/artifact_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def probe_gpu_variant(mxnet_features: Dict[str, bool]) -> Optional[str]:
if cuda_version:
variant = 'cu{}'.format(cuda_version)
if not mxnet_features['MKLDNN']:
RuntimeError('Error determining mxnet variant: MKL-DNN should be enabled for cuda variants')
RuntimeError('Error determining mxnet variant: ONEDNN should be enabled for cuda variants')
logger.debug('variant is: {}'.format(variant))
return variant

Expand Down
8 changes: 4 additions & 4 deletions ci/build_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class BuildFlavour(Enum):
'-DUSE_BLAS=open '
'-DUSE_LAPACK=ON '
'-DUSE_DIST_KVSTORE=OFF '
'-DUSE_MKLDNN=ON '
'-DUSE_ONEDNN=ON '
'-DCMAKE_BUILD_TYPE=Release')

, 'WIN_CPU_MKLDNN_MKL': (
Expand All @@ -92,7 +92,7 @@ class BuildFlavour(Enum):
'-DUSE_BLAS=mkl '
'-DUSE_LAPACK=ON '
'-DUSE_DIST_KVSTORE=OFF '
'-DUSE_MKLDNN=ON '
'-DUSE_ONEDNN=ON '
'-DCMAKE_BUILD_TYPE=Release')

, 'WIN_CPU_MKL': (
Expand All @@ -105,7 +105,7 @@ class BuildFlavour(Enum):
'-DUSE_BLAS=mkl '
'-DUSE_LAPACK=ON '
'-DUSE_DIST_KVSTORE=OFF '
'-DUSE_MKLDNN=OFF '
'-DUSE_ONEDNN=OFF '
'-DCMAKE_BUILD_TYPE=Release')

, 'WIN_GPU': (
Expand All @@ -132,7 +132,7 @@ class BuildFlavour(Enum):
'-DUSE_LAPACK=ON '
'-DUSE_DIST_KVSTORE=OFF '
'-DMXNET_CUDA_ARCH="5.2" '
'-DUSE_MKLDNN=ON '
'-DUSE_ONEDNN=ON '
'-DCMAKE_BUILD_TYPE=Release')

}
Expand Down
Loading

0 comments on commit aa92db0

Please sign in to comment.