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

[Doc] Add MKL-DNN operator list #14891

Merged
merged 33 commits into from
May 18, 2019
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c202b36
improve mkldnn document
TaoLv May 6, 2019
6fbfe48
fix
TaoLv May 6, 2019
15446a8
enable fusion
TaoLv May 6, 2019
8a3b9b9
Merge branch 'master' of https://github.com/apache/incubator-mxnet in…
TaoLv May 6, 2019
70f3723
adjust table
TaoLv May 6, 2019
5b3f6db
fix comments
TaoLv May 6, 2019
58e8ac1
promote mxnet-mkl package
TaoLv May 7, 2019
ce82caa
Update docs/tutorials/mkldnn/MKLDNN_README.md
aaronmarkham May 8, 2019
dab9ddf
Update docs/install/index.md
aaronmarkham May 8, 2019
2a5e2cd
Update docs/install/index.md
aaronmarkham May 8, 2019
708edee
Update docs/install/index.md
aaronmarkham May 8, 2019
fb5fcc3
Update docs/install/index.md
aaronmarkham May 8, 2019
4a61c8e
Update docs/tutorials/mkldnn/operator_list.md
aaronmarkham May 8, 2019
4c897e8
Update docs/faq/perf.md
aaronmarkham May 8, 2019
eb36414
Update docs/faq/perf.md
aaronmarkham May 8, 2019
bfc5ac0
Update docs/tutorials/mkldnn/operator_list.md
aaronmarkham May 8, 2019
7e53e8d
Update docs/tutorials/mkldnn/operator_list.md
aaronmarkham May 8, 2019
b74f3f7
fix markdown table
TaoLv May 8, 2019
d1cf743
fix comments
TaoLv May 13, 2019
762945b
Merge branch 'master' of https://github.com/apache/incubator-mxnet in…
TaoLv May 13, 2019
6b01ce3
Merge branch 'master' of https://github.com/apache/incubator-mxnet in…
TaoLv May 14, 2019
5c3d067
Update docs/faq/env_var.md
TaoLv May 15, 2019
d9fcea4
Update docs/install/index.md
TaoLv May 15, 2019
b6de387
Update docs/tutorials/mkldnn/MKLDNN_README.md
TaoLv May 15, 2019
ad5e2c8
Merge branch 'master' of https://github.com/apache/incubator-mxnet in…
TaoLv May 15, 2019
2d8e4d8
Merge branch 'doc-op-list' of https://github.com/TaoLv/incubator-mxne…
TaoLv May 15, 2019
d7c7776
Merge branch 'master' of https://github.com/apache/incubator-mxnet in…
TaoLv May 16, 2019
e2f0d03
Merge branch 'master' of https://github.com/apache/incubator-mxnet in…
TaoLv May 17, 2019
bd49e9d
Merge branch 'master' of https://github.com/apache/incubator-mxnet in…
TaoLv May 17, 2019
b783f58
change name of env variable
TaoLv May 17, 2019
0f82b3b
retrigger ci
TaoLv May 17, 2019
dd4cfa5
Merge branch 'master' into doc-op-list
szha May 18, 2019
4d36bbf
Update env_var.md
szha May 18, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions docs/faq/perf.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,13 @@ Performance is mainly affected by the following 4 factors:

## Intel CPU

For using Intel Xeon CPUs for training and inference, we suggest enabling
`USE_MKLDNN = 1` in `config.mk`.
When using Intel Xeon CPUs for training and inference, the `mxnet-mkl` package is recommended. Adding `--pre` installs a nightly build from master. Without it you will install the latest patched release of MXNet:

```
$ pip install mxnet-mkl [--pre]
```

Or build MXNet from source code with `USE_MKLDNN=1`. For Linux users, `USE_MKLDNN=1` will be turned on by default.

We also find that setting the following environment variables can help:

Expand Down
26 changes: 25 additions & 1 deletion docs/install/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,20 +124,38 @@ Indicate your preferred configuration. Then, follow the customized commands to i
$ pip install mxnet
```

MKL-DNN enabled pip packages are optimized for Intel hardware. You can find performance numbers in the <a href="../..//faq/perf.md#intel-cpu">MXNet tuning guide</a>.
TaoLv marked this conversation as resolved.
Show resolved Hide resolved

```
$ pip install mxnet-mkl==1.4.0
```

</div> <!-- End of v1-4-0 -->
<div class="v1-3-1">

```
$ pip install mxnet==1.3.1
```

MKL-DNN enabled pip packages are optimized for Intel hardware. You can find performance numbers in the <a href="../../faq/perf.md#intel-cpu">MXNet tuning guide</a>.

```
$ pip install mxnet-mkl==1.3.1
```

</div> <!-- End of v1-3-1 -->
<div class="v1-2-1">

```
$ pip install mxnet==1.2.1
```

MKL-DNN enabled pip packages are optimized for Intel hardware. You can find performance numbers in the <a href="../../faq/perf.md#intel-cpu">MXNet tuning guide</a>.

```
$ pip install mxnet-mkl==1.2.1
```

</div> <!-- End of v1-2-1 -->

<div class="v1-1-0">
Expand Down Expand Up @@ -185,9 +203,15 @@ $ pip install mxnet==0.11.0
$ pip install mxnet --pre
```

MKL-DNN enabled pip packages are optimized for Intel hardware. You can find performance numbers in the <a href="../../faq/perf.md#intel-cpu">MXNet tuning guide</a>.

```
$ pip install mxnet-mkl --pre
```

</div> <!-- End of master-->
<hr> <!-- pip footer -->
MXNet offers MKL pip packages that will be much faster when running on Intel hardware.

Check the chart below for other options, refer to <a href="https://pypi.org/project/mxnet/">PyPI for other MXNet pip packages</a>, or <a href="validate_mxnet.html">validate your MXNet installation</a>.

<img src="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/install/pip-packages-1.4.0.png" alt="pip packages"/>
Expand Down
52 changes: 27 additions & 25 deletions docs/tutorials/mkldnn/MKLDNN_README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
<!--- Licensed to the Apache Software Foundation (ASF) under one -->
<!--- or more contributor license agreements. See the NOTICE file -->
<!--- distributed with this work for additional information -->
<!--- regarding copyright ownership. The ASF licenses this file -->
<!--- to you under the Apache License, Version 2.0 (the -->
<!--- "License"); you may not use this file except in compliance -->
<!--- with the License. You may obtain a copy of the License at -->

<!--- http://www.apache.org/licenses/LICENSE-2.0 -->

<!--- Unless required by applicable law or agreed to in writing, -->
<!--- software distributed under the License is distributed on an -->
<!--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -->
<!--- KIND, either express or implied. See the License for the -->
<!--- specific language governing permissions and limitations -->
<!--- under the License. -->

<!--- Licensed to the Apache Software Foundation (ASF) under one -->
<!--- or more contributor license agreements. See the NOTICE file -->
<!--- distributed with this work for additional information -->
<!--- regarding copyright ownership. The ASF licenses this file -->
<!--- to you under the Apache License, Version 2.0 (the -->
<!--- "License"); you may not use this file except in compliance -->
<!--- with the License. You may obtain a copy of the License at -->
<!--- http://www.apache.org/licenses/LICENSE-2.0 -->
<!--- Unless required by applicable law or agreed to in writing, -->
<!--- software distributed under the License is distributed on an -->
<!--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -->
<!--- KIND, either express or implied. See the License for the -->
<!--- specific language governing permissions and limitations -->
<!--- under the License. -->
# Build/Install MXNet with MKL-DNN

A better training and inference performance is expected to be achieved on Intel-Architecture CPUs with MXNet built with [Intel MKL-DNN](https://github.com/intel/mkl-dnn) on multiple operating system, including Linux, Windows and MacOS.
In the following sections, you will find build instructions for MXNet with Intel MKL-DNN on Linux, MacOS and Windows.

Please find MKL-DNN optimized operators and other features in [MKL-DNN operator list](../mkldnn/operator_list.md).
TaoLv marked this conversation as resolved.
Show resolved Hide resolved

The detailed performance data collected on Intel Xeon CPU with MXNet built with Intel MKL-DNN can be found [here](https://mxnet.incubator.apache.org/faq/perf.html#intel-cpu).


Expand Down Expand Up @@ -306,14 +308,14 @@ Graph optimization by subgraph feature are available in master branch. You can b
```
export MXNET_SUBGRAPH_BACKEND=MKLDNN
```

When `MKLDNN` backend is enabled, advanced control options are avaliable:

```
export MXNET_DISABLE_MKLDNN_CONV_OPT=1 # disable MKLDNN convolution optimization pass
export MXNET_DISABLE_MKLDNN_FC_OPT=1 # disable MKLDNN FullyConnected optimization pass
```

When `MKLDNN` backend is enabled, advanced control options are avaliable:
```
export MXNET_DISABLE_MKLDNN_CONV_OPT=1 # disable MKLDNN convolution optimization pass
export MXNET_DISABLE_MKLDNN_FC_OPT=1 # disable MKLDNN FullyConnected optimization pass
```

This limitations of this experimental feature are:

Expand Down
79 changes: 79 additions & 0 deletions docs/tutorials/mkldnn/operator_list.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!--- Licensed to the Apache Software Foundation (ASF) under one -->
<!--- or more contributor license agreements. See the NOTICE file -->
<!--- distributed with this work for additional information -->
<!--- regarding copyright ownership. The ASF licenses this file -->
<!--- to you under the Apache License, Version 2.0 (the -->
<!--- "License"); you may not use this file except in compliance -->
<!--- with the License. You may obtain a copy of the License at -->

<!--- http://www.apache.org/licenses/LICENSE-2.0 -->

<!--- Unless required by applicable law or agreed to in writing, -->
<!--- software distributed under the License is distributed on an -->
<!--- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -->
<!--- KIND, either express or implied. See the License for the -->
<!--- specific language governing permissions and limitations -->
<!--- under the License. -->

# MKL-DNN Operator list

MXNet MKL-DNN backend provides optimized implementations for various operators covering a broad range of applications including image classification, object detection, natural language processing.

To help users understanding MKL-DNN backend better, the following table summarizes the list of supported operators, data types and functionalities. A subset of operators support faster training and inference by using a lower precision version. Refer to the following table's `INT8 Inference` column to see which operators are supported.

| Operator | Function | FP32 Training (backward) | FP32 Inference | INT8 Inference |
TaoLv marked this conversation as resolved.
Show resolved Hide resolved
| -- | -- | -- | -- | -- |
| **Convolution** | 1D Convolution | Y | Y | N |
| | 2D Convolution | Y | Y | Y |
| | 3D Convolution | Y | Y | N |
| **Deconvolution** | 2D Deconvolution | Y | Y | N |
| | 3D Deconvolution | Y | Y | N |
| **FullyConnected** | 1D-4D input, flatten=True | N | Y | Y |
| | 1D-4D input, flatten=False | N | Y | Y |
| **Pooling** | 2D max Pooling | Y | Y | Y |
| | 2D avg pooling | Y | Y | Y |
| **BatchNorm** | 2D BatchNorm | Y | Y | N |
| **LRN** | 2D LRN | Y | Y | N |
| **Activation** | ReLU | Y | Y | Y |
| | Tanh | Y | Y | N |
| | SoftReLU | Y | Y | N |
| | Sigmoid | Y | Y | N |
| **softmax** | 1D-4D input | Y | Y | N |
| **Softmax_output** | 1D-4D input | N | Y | N |
| **Transpose** | 1D-4D input | N | Y | N |
| **elemwise_add** | 1D-4D input | Y | Y | Y |
| **Concat** | 1D-4D input | Y | Y | Y |
| **slice** | 1D-4D input | N | Y | N |
| **Quantization** | 1D-4D input | N | N | Y |
| **Dequantization** | 1D-4D input | N | N | Y |
| **Requantization** | 1D-4D input | N | N | Y |

Besides direct operator optimizations, we also provide graph fusion passes listed in the table below. Users can choose to enable or disable these fusion patterns through environmental variables.

For example, you can enable all fusion passes by:

```
export MXNET_SUBGRAPH_BACKEND=MKLDNN
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all fusion passes might not be accurate enough here.
MKLDNN backend is only applicable to the FP32 mode fusion, while MKLDNN_POST_QUANTIZE is applicable to the INT8 mode fusion (quantized_op +requantize/dequantize).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to know! How many subgraph backend options do we have now? What about INT8 convolution + relu fusion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, there're only two options as mentioned above.
There's no fusion pass for INT8 conv +relu, the current flow is doing the fusion of FP32 conv +relu firstly, and then quantizing FP32 sg_conv to INT8 sg_conv.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the information. I think we need to put them into this page: https://mxnet.incubator.apache.org/versions/master/faq/env_var.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the information. I think we need to put them into this page: https://mxnet.incubator.apache.org/versions/master/faq/env_var.html

Let's maintain them in one spot and then reference where appropriate. Either way some mention is needed in the env_var page.

```

And disable `Convolution + Activation(ReLU)` fusion by:

```
export MXNET_DISABLE_MKLDNN_FUSE_CONV_RELU=1
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also other options for end-use to choose, such as:
MXNET_DISABLE_MKLDNN_CONV_OPT to disable all MKLDNN convolution optimization pass.
MXNET_DISABLE_MKLDNN_FC_OPT to disable all MKLDNN FullyConnected optimization pass.


| Fusion pattern | Disable |
| -- | -- |
| Convolution + Activation(ReLU) | MXNET_DISABLE_MKLDNN_FUSE_CONV_RELU |
| Convolution + elemwise_add | MXNET_DISABLE_MKLDNN_FUSE_CONV_SUM |
| Convolution + BatchNorm | MXNET_DISABLE_MKLDNN_FUSE_CONV_BN |
| Convolution + Activation(ReLu) + elemwise_add | |
| Convolution + BatchNorm + Activation(ReLu) + elemwise_add | |
| FullyConnected + Activation(ReLU) | MXNET_DISABLE_MKLDNN_FUSE_FC_RELU |
| Convolution (INT8) + re-quantization | |
| FullyConnected (INT8) + re-quantization | |

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

miss a pattern here: FullyConnected (INT8) + re-quantization + de-quantization


To install MXNet MKL-DNN backend, please refer to [MKL-DNN backend readme](MKLDNN_README.md)

For performance numbers, please refer to [performance on Intel CPU](../../faq/perf.md#intel-cpu)
1 change: 1 addition & 0 deletions tests/tutorials/test_sanity_tutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
'gluon/index.md',
'mkldnn/index.md',
'mkldnn/MKLDNN_README.md',
'mkldnn/operator_list.md',
'nlp/index.md',
'onnx/index.md',
'python/index.md',
Expand Down