Uh oh!
There was an error while loading. Please reload this page.
[BYOC][DNNL] Enable layer normalization in DNNL byoc. - #11508
Conversation
crazydemo
commented
May 31, 2022
Thanks for your contribution for BYOC-DNNL. And my suggestions are listed below:
|
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| dnnl::memory::dims data_shape = nodes_[data_entry.id_].GetOpShape()[data_entry.index_]; | ||
| float epsilon = std::stof(node.GetAttr<std::vector<std::string>>("epsilon")[0]); |
There was a problem hiding this comment.
original "nn.layer_norm" has not only epsilon argument. At least axis, center and scale. By this code you assume that they always equal axis = -1, center=true and scale=true.
Could you please add support of all attributes or verify their values on codegen stage.
There was a problem hiding this comment.
I add ICHECK to this case. And will update later for supporting all other attributes.
Uh oh!
There was an error while loading. Please reload this page.
apeskov
commented
Jun 1, 2022
@crazydemo Answering your question about performance.
Yes, there is performance benefit. At least they use different memory access approach. Consecutive ops with llvm codegen will produce sequence of fused kernel like next:
Totally we have 6 times traversing through data tensor for TVM codegen. DNNL implement it as single kernel and do only 4 passes through memory buffers (or 3 in case of in place memory). In case of multi core system(xeon servers and other) normalise op is memory bound. And reduction of memory access becomes more important. |
billishyahao
commented
Jun 3, 2022
Hi @apeskov , please take a look at the latest version here. Feel free to comment more. |
355766e to
4c34e00Comparebillishyahao
commented
Jun 6, 2022
Hi @masahi Please take a look. |
billishyahao
commented
Jun 8, 2022
masahi
commented
Jun 8, 2022
billishyahao
commented
Jun 8, 2022
* Enable layer normalization in DNNL byoc. * Added unittest for layer norm and make code compatible after introducing TensorRequisite(PR-11345) * Fix lint issue * Fix clang format issue
This patch is to enable layer normalization in DNNL BYOC by providing an out-of-box rewrite pattern for combining the operators into a single relay layer normalization operator as well as its implementation in dnnl json codegen.
After applying the rewrite pattern, we will observe the following dnnl function:
Once you enable DNNL_VERBOSE flag, more informations are shown in log file as below:
With this patch, I benchmarked the inference performance of a kind of vision-tranformer called PCPVT (https://arxiv.org/abs/2104.13840) on ICX-8352Y. It gains up to 1.18X boost. Here is some boost data:
Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.