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

[v1.x][Feature] Add flag for disabling oneDNN BRGEMM implementation of FC #20450

Merged
merged 3 commits into from
Jul 16, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
4 changes: 4 additions & 0 deletions docs/static_site/src/pages/api/faq/env_var.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ If ctypes is used, it must be `mxnet._ctypes.ndarray.NDArrayBase`.
- Values: Int ```(default=-1)```
- Flag to set num of elements that MKLDNN cache can hold. Default is -1 which means cache size is unbounded. Should only be set if your model has variable input shapes, as cache size may grow unbounded. The number represents the number of items in the cache and is proportional to the number of layers that use MKLDNN and different input shape.

* MXNET_MKLDNN_DISABLE_BRGEMM_FC
- Values: Int ```(default=-1)```
- Flag which enables BRGEMM kernels in FullyConnected executed with MKLDNN support - Should only be set if your model has constant input shapes or FullyConnected is calculated with large tensors. Supported on machines with AVX512-VNNI.

* MXNET_ENFORCE_DETERMINISM
- Values: 0(false) or 1(true) ```(default=0)```
- If set to true, MXNet will only use deterministic algorithms in forward and backward computation.
Expand Down
3 changes: 2 additions & 1 deletion src/operator/nn/mkldnn/mkldnn_base-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ inline static mkldnn::memory::desc GetFCWeightDesc(const NDArray &arr, int dtype
for (size_t i = 0; i < dims.size(); i++) dims[i] = arr.shape()[i];
auto format = mkldnn::memory::format_tag::any;
// for batch 256 alexnet benchmark test
if (dims.size() == 2) {
const bool brgemm_disabled = dmlc::GetEnv("MXNET_MKLDNN_DISABLE_BRGEMM_FC", true);
if (dims.size() == 2 && brgemm_disabled) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you please provide more benchmarking data with different m/n/k and formats?

BTW, actually brgemm_disabled looks misleading to me. According to the code change, i would rather call the flag force_plain_format or force_ab_format.

format = mkldnn::memory::format_tag::ab;
}

Expand Down