You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2022/01/14 13:08:27 UTC
[GitHub] [incubator-mxnet] anko-intel opened a new pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
anko-intel opened a new pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821
## Description ##
This change fuses FullyConnected operator with elemwise_add after it if possible. It is done for both float and quantized path.
The change well optimize calculation on quantized graph with full quantization mode. Below are the measured results of the following benchmark :
benchmark/python/dnnl/run.sh benchmark/python/dnnl/fc_add.py
run before and after this PR. Measurements are done on AWS EC2 instance c6i.16xlarge (Xeon(R) Platinum 8375C CPU).
elemwise_add, float
| Shape | Hidden | Before [ms] | After [ms] | Improvment |
|------------:|-------:|------------:|------------:|-----------:|
| ( 1, 224) | 512 | 1.010 | 1.016 | -1% |
| ( 1, 224) | 4096 | 1.053 | 1.011 | 4% |
| ( 16,1024) | 1024 | 1.191 | 1.155 | 3% |
| ( 32,4096) | 1024 | 1.814 | 1.793 | 1% |
| ( 32,4096) | 4096 | 3.764 | 3.650 | 3% |
| ( 512, 512) | 4096 | 3.753 | 3.054 | 19% |
Quantized:
elemwise_add, mode = smart, granularity = tensor-wise
| Shape | Hidden | Before [ms] | After [ms] | Improvment |
|------------:|-------:|------------:|------------:|-----------:|
| ( 1, 224) | 512 | 1.091 | 1.268 | -16% |
| ( 1, 224) | 4096 | 1.263 | 1.263 | 0% |
| ( 16,1024) | 1024 | 1.280 | 1.459 | -14% |
| ( 32,4096) | 1024 | 1.508 | 1.635 | -8% |
| ( 32,4096) | 4096 | 1.857 | 1.998 | -8% |
| ( 512, 512) | 4096 | 3.003 | 2.563 | 15% |
elemwise_add, mode = smart, granularity = channel-wise
| Shape | Hidden | Before [ms] | After [ms] | Improvment |
|------------:|-------:|------------:|------------:|-----------:|
| ( 1, 224) | 512 | 1.154 | 1.192 | -3% |
| ( 1, 224) | 4096 | 1.079 | 1.239 | -15% |
| ( 16,1024) | 1024 | 1.173 | 1.424 | -21% |
| ( 32,4096) | 1024 | 1.449 | 1.575 | -9% |
| ( 32,4096) | 4096 | 1.806 | 1.921 | -6% |
| ( 512, 512) | 4096 | 2.969 | 2.507 | 16% |
elemwise_add, mode = full, granularity = tensor-wise
| Shape | Hidden | Before* [ms] | After [ms] | Improvment |
|------------:|-------:|------------:|------------:|-----------:|
| ( 1, 224) | 512 | 1.185 | 0.969 | 18% |
| ( 1, 224) | 4096 | 1.183 | 0.985 | 17% |
| ( 16,1024) | 1024 | 1.214 | 1.043 | 14% |
| ( 32,4096) | 1024 | 1.546 | 1.242 | 20% |
| ( 32,4096) | 4096 | 1.825 | 1.611 | 12% |
| ( 512, 512) | 4096 | 2.311 | 1.745 | 24% |
elemwise_add, mode = full, granularity = channel-wise
| Shape | Hidden | Before* [ms] | After [ms] | Improvment |
|------------:|-------:|------------:|------------:|-----------:|
| ( 1, 224) | 512 | 1.090 | 0.915 | 16% |
| ( 1, 224) | 4096 | 1.082 | 0.878 | 19% |
| ( 16,1024) | 1024 | 1.150 | 0.934 | 19% |
| ( 32,4096) | 1024 | 1.490 | 1.149 | 23% |
| ( 32,4096) | 4096 | 1.784 | 1.553 | 13% |
| ( 512, 512) | 4096 | 2.265 | 1.729 | 24% |
\* - before this PR fuzing FC with add in full quantize mode is broken, so results are taken from the first commit of this PR which fix the issue
## Checklist ##
### Essentials ###
- [ ] PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
- [ ] Changes are complete (i.e. I finished coding on this PR)
- [ ] All changes have test coverage
- [ ] Code is well-documented
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1021175637
Jenkins CI successfully triggered : [unix-cpu, unix-gpu, edge, windows-gpu, website, windows-cpu, centos-gpu, centos-cpu, sanity, miscellaneous, clang]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20821: [WIP] [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1014896650
Jenkins CI successfully triggered : [windows-gpu, unix-cpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] anko-intel commented on a change in pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
anko-intel commented on a change in pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#discussion_r790530664
##########
File path: src/operator/subgraph/dnnl/dnnl_fc.cc
##########
@@ -72,83 +75,123 @@ class SgDNNLFCOp {
std::shared_ptr<dnnl::memory> cached_out_mem_;
NDArray cached_weight_;
NDArray cached_bias_;
- float cached_min_data_;
- float cached_max_data_;
- float cached_min_weight_;
- float cached_max_weight_;
- float cached_min_bias_;
- float cached_max_bias_;
+ float cached_data_min_;
+ float cached_data_max_;
+ float cached_weight_min_;
+ float cached_weight_max_;
+ float cached_sum_min_;
+ float cached_sum_max_;
+ float cached_bias_min_;
+ float cached_bias_max_;
size_t weight_ver_;
size_t bias_ver_;
- float cached_min_output_;
- float cached_max_output_;
+ float cached_output_min_;
+ float cached_output_max_;
float data_scale_{0.0f};
std::vector<float> weight_scales_;
- size_t total_num_inputs_;
- size_t total_num_outputs_;
};
void SgDNNLFCOp::Forward(const OpContext& ctx,
const std::vector<NDArray>& in_data,
const std::vector<OpReqType>& req,
const std::vector<NDArray>& out_data) {
- auto& dnnl_param = full_param_.dnnl_param;
- auto& default_param = full_param_.default_param;
- bool has_bias = !default_param.no_bias;
- size_t base_num_inputs = has_bias ? 3 : 2;
- size_t base_num_outputs = 1;
-
- float min_data = 0.0f;
- float max_data = 0.0f;
- float min_weight = 0.0f;
- float max_weight = 0.0f;
- float min_bias = 0.0f;
- float max_bias = 0.0f;
-
- if (!initialized_) {
- if (dnnl_param.channel_wise_quantize.has_value() && dnnl_param.channel_wise_quantize) {
- channel_wise_runtime_ = true;
+ auto& dnnl_param = full_param_.dnnl_param;
+ auto& default_param = full_param_.default_param;
+ const bool has_bias = !default_param.no_bias;
+ const bool quantized = dnnl_param.quantized;
+ const bool out_quantized = dnnl_param.quantized && !dnnl_param.enable_float_output;
+ const bool channel_wise = quantized && dnnl_param.channel_wise_quantize.has_value() &&
+ dnnl_param.channel_wise_quantize.value();
+
+ const FCInputIndex idx(full_param_);
+
+ CHECK_EQ(in_data.size(), idx.GetTotal());
+
+ int index = 0;
+ const int out_index = index++;
+ const int out_min_index = out_quantized ? index++ : 0;
+ const int out_max_index = out_quantized ? index++ : 0;
+ CHECK_EQ(out_data.size(), index); // index is equal to total number of outputs
+
+ float data_min = 0.0f;
+ float data_max = 0.0f;
+ float weight_min = 0.0f;
+ float weight_max = 0.0f;
+ float bias_min = 0.0f;
+ float bias_max = 0.0f;
+
+ const float sum_min = idx.sum_min ? in_data[idx.sum_min].data().dptr<float>()[0] : 0.0;
+ const float sum_max = idx.sum_max ? in_data[idx.sum_max].data().dptr<float>()[0] : 0.0;
+ NDArray data = in_data[idx.data];
+ const NDArray& weight = in_data[idx.weight];
+ NDArray output;
+
+ if (dnnl_param.with_sum) {
+ if (!initialized_) {
+ // TODO(zhennan): Currently, dnnl fallback mechanism will break inplace option,
+ // which make check (req[out_index] == kWriteInplace) useless.
+ auto in_dnnl_mem = static_cast<const dnnl::memory*>(in_data[idx.sum].GetDNNLData());
+ auto out_dnnl_mem = static_cast<const dnnl::memory*>(out_data[out_index].GetDNNLData());
+ if (in_dnnl_mem->get_data_handle() == out_dnnl_mem->get_data_handle()) {
+ inplace_ = true;
+ }
}
-
- total_num_inputs_ = base_num_inputs;
- total_num_outputs_ = base_num_outputs;
- if (dnnl_param.quantized) {
- total_num_inputs_ = channel_wise_runtime_ ? (base_num_inputs + 2) : (base_num_inputs * 3);
- total_num_outputs_ =
- dnnl_param.enable_float_output ? base_num_outputs : (base_num_outputs * 3);
+ if (inplace_) {
+ output = in_data[idx.sum];
+ } else {
+ // Not in place: copy in_data[idx.sum] into outputs[out_index].
+ auto in_dnnl_mem = static_cast<const dnnl::memory*>(in_data[idx.sum].GetDNNLData());
+ auto out_dnnl_mem = static_cast<const dnnl::memory*>(out_data[out_index].GetDNNLData());
+ if (out_data[out_index].dtype() == mshadow::kInt32) {
Review comment:
For now such configuration doesn't exist. For 'full' quantization mode input and output are int8 and for 'smart' quantization both are float
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1022119718
Jenkins CI successfully triggered : [windows-gpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] bgawrych commented on pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
bgawrych commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1021175487
@mxnet-bot run ci[all]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1015366869
Jenkins CI successfully triggered : [centos-cpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] PawelGlomski-Intel commented on a change in pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
PawelGlomski-Intel commented on a change in pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#discussion_r787673431
##########
File path: src/operator/subgraph/build_subgraph.cc
##########
@@ -749,6 +749,17 @@ void CreateSubgraphNode(nnvm::Graph* g,
for (BiDirectedNode* dest_node : subgraph_nodes) {
sn->outputs.erase(dest_node->node);
}
+ }
+ }
+
+ // Set outputs according to current inputs
+ for (size_t i = 0; i < n->inputs.size(); ++i) {
+ auto& e = n->inputs[i];
+ // update input entries' source simple nodes' outputs map
+ nnvm::Node* node = e.node.get();
+ if (indexed_graph.exist(node)) {
+ const auto nid = indexed_graph.node_id(node);
+ BiDirectedNode* sn = simple_nodes[nid].get();
Review comment:
Do these changes here actually do anything? `sn` is not used anywhere.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1021919780
Jenkins CI successfully triggered : [windows-gpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] anko-intel commented on a change in pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
anko-intel commented on a change in pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#discussion_r787689923
##########
File path: src/operator/subgraph/build_subgraph.cc
##########
@@ -749,6 +749,17 @@ void CreateSubgraphNode(nnvm::Graph* g,
for (BiDirectedNode* dest_node : subgraph_nodes) {
sn->outputs.erase(dest_node->node);
}
+ }
+ }
+
+ // Set outputs according to current inputs
+ for (size_t i = 0; i < n->inputs.size(); ++i) {
+ auto& e = n->inputs[i];
+ // update input entries' source simple nodes' outputs map
+ nnvm::Node* node = e.node.get();
+ if (indexed_graph.exist(node)) {
+ const auto nid = indexed_graph.node_id(node);
+ BiDirectedNode* sn = simple_nodes[nid].get();
Review comment:
Yes, ouput is add in line 763 using `sn`.
The difference between previous version is that first all nodes which should be removed are removed in line 750
and later all node which should be added are added in line 763.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] PawelGlomski-Intel commented on a change in pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
PawelGlomski-Intel commented on a change in pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#discussion_r787697084
##########
File path: src/operator/subgraph/build_subgraph.cc
##########
@@ -749,6 +749,17 @@ void CreateSubgraphNode(nnvm::Graph* g,
for (BiDirectedNode* dest_node : subgraph_nodes) {
sn->outputs.erase(dest_node->node);
}
+ }
+ }
+
+ // Set outputs according to current inputs
+ for (size_t i = 0; i < n->inputs.size(); ++i) {
+ auto& e = n->inputs[i];
+ // update input entries' source simple nodes' outputs map
+ nnvm::Node* node = e.node.get();
+ if (indexed_graph.exist(node)) {
+ const auto nid = indexed_graph.node_id(node);
+ BiDirectedNode* sn = simple_nodes[nid].get();
Review comment:
Oh, right... Somehow I completely missed that 🤣 Thanks for the clarification.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] anko-intel commented on a change in pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
anko-intel commented on a change in pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#discussion_r787689923
##########
File path: src/operator/subgraph/build_subgraph.cc
##########
@@ -749,6 +749,17 @@ void CreateSubgraphNode(nnvm::Graph* g,
for (BiDirectedNode* dest_node : subgraph_nodes) {
sn->outputs.erase(dest_node->node);
}
+ }
+ }
+
+ // Set outputs according to current inputs
+ for (size_t i = 0; i < n->inputs.size(); ++i) {
+ auto& e = n->inputs[i];
+ // update input entries' source simple nodes' outputs map
+ nnvm::Node* node = e.node.get();
+ if (indexed_graph.exist(node)) {
+ const auto nid = indexed_graph.node_id(node);
+ BiDirectedNode* sn = simple_nodes[nid].get();
Review comment:
Yes, ouput is add in line 763 using `sn`.
The differense between porevious version is that first all nodes which should be removed are removed in line 750
and later all node which sould be added are added in line 763.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] bgawrych commented on pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
bgawrych commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1021175487
@mxnet-bot run ci[all]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] anko-intel commented on pull request #20821: [WIP] [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
anko-intel commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1015182611
@mxnet-bot run ci [windows-gpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] DominikaJedynak commented on a change in pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
DominikaJedynak commented on a change in pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#discussion_r789827171
##########
File path: src/operator/subgraph/dnnl/dnnl_fc.cc
##########
@@ -72,83 +75,123 @@ class SgDNNLFCOp {
std::shared_ptr<dnnl::memory> cached_out_mem_;
NDArray cached_weight_;
NDArray cached_bias_;
- float cached_min_data_;
- float cached_max_data_;
- float cached_min_weight_;
- float cached_max_weight_;
- float cached_min_bias_;
- float cached_max_bias_;
+ float cached_data_min_;
+ float cached_data_max_;
+ float cached_weight_min_;
+ float cached_weight_max_;
+ float cached_sum_min_;
+ float cached_sum_max_;
+ float cached_bias_min_;
+ float cached_bias_max_;
size_t weight_ver_;
size_t bias_ver_;
- float cached_min_output_;
- float cached_max_output_;
+ float cached_output_min_;
+ float cached_output_max_;
float data_scale_{0.0f};
std::vector<float> weight_scales_;
- size_t total_num_inputs_;
- size_t total_num_outputs_;
};
void SgDNNLFCOp::Forward(const OpContext& ctx,
const std::vector<NDArray>& in_data,
const std::vector<OpReqType>& req,
const std::vector<NDArray>& out_data) {
- auto& dnnl_param = full_param_.dnnl_param;
- auto& default_param = full_param_.default_param;
- bool has_bias = !default_param.no_bias;
- size_t base_num_inputs = has_bias ? 3 : 2;
- size_t base_num_outputs = 1;
-
- float min_data = 0.0f;
- float max_data = 0.0f;
- float min_weight = 0.0f;
- float max_weight = 0.0f;
- float min_bias = 0.0f;
- float max_bias = 0.0f;
-
- if (!initialized_) {
- if (dnnl_param.channel_wise_quantize.has_value() && dnnl_param.channel_wise_quantize) {
- channel_wise_runtime_ = true;
+ auto& dnnl_param = full_param_.dnnl_param;
+ auto& default_param = full_param_.default_param;
+ const bool has_bias = !default_param.no_bias;
+ const bool quantized = dnnl_param.quantized;
+ const bool out_quantized = dnnl_param.quantized && !dnnl_param.enable_float_output;
+ const bool channel_wise = quantized && dnnl_param.channel_wise_quantize.has_value() &&
+ dnnl_param.channel_wise_quantize.value();
+
+ const FCInputIndex idx(full_param_);
+
+ CHECK_EQ(in_data.size(), idx.GetTotal());
+
+ int index = 0;
+ const int out_index = index++;
+ const int out_min_index = out_quantized ? index++ : 0;
+ const int out_max_index = out_quantized ? index++ : 0;
+ CHECK_EQ(out_data.size(), index); // index is equal to total number of outputs
+
+ float data_min = 0.0f;
+ float data_max = 0.0f;
+ float weight_min = 0.0f;
+ float weight_max = 0.0f;
+ float bias_min = 0.0f;
+ float bias_max = 0.0f;
+
+ const float sum_min = idx.sum_min ? in_data[idx.sum_min].data().dptr<float>()[0] : 0.0;
+ const float sum_max = idx.sum_max ? in_data[idx.sum_max].data().dptr<float>()[0] : 0.0;
+ NDArray data = in_data[idx.data];
+ const NDArray& weight = in_data[idx.weight];
+ NDArray output;
+
+ if (dnnl_param.with_sum) {
+ if (!initialized_) {
+ // TODO(zhennan): Currently, dnnl fallback mechanism will break inplace option,
+ // which make check (req[out_index] == kWriteInplace) useless.
+ auto in_dnnl_mem = static_cast<const dnnl::memory*>(in_data[idx.sum].GetDNNLData());
+ auto out_dnnl_mem = static_cast<const dnnl::memory*>(out_data[out_index].GetDNNLData());
+ if (in_dnnl_mem->get_data_handle() == out_dnnl_mem->get_data_handle()) {
+ inplace_ = true;
+ }
}
-
- total_num_inputs_ = base_num_inputs;
- total_num_outputs_ = base_num_outputs;
- if (dnnl_param.quantized) {
- total_num_inputs_ = channel_wise_runtime_ ? (base_num_inputs + 2) : (base_num_inputs * 3);
- total_num_outputs_ =
- dnnl_param.enable_float_output ? base_num_outputs : (base_num_outputs * 3);
+ if (inplace_) {
+ output = in_data[idx.sum];
+ } else {
+ // Not in place: copy in_data[idx.sum] into outputs[out_index].
+ auto in_dnnl_mem = static_cast<const dnnl::memory*>(in_data[idx.sum].GetDNNLData());
+ auto out_dnnl_mem = static_cast<const dnnl::memory*>(out_data[out_index].GetDNNLData());
+ if (out_data[out_index].dtype() == mshadow::kInt32) {
Review comment:
Is it taken under consideration what if the output of the fc is a float and the data to sum with is an integer? Shouldn't there also be a check for mshadow::Float32 or isn't it a proper scenario?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1013102565
Hey @anko-intel , Thanks for submitting the PR
All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands:
- To trigger all jobs: @mxnet-bot run ci [all]
- To trigger specific jobs: @mxnet-bot run ci [job1, job2]
***
**CI supported jobs**: [windows-gpu, unix-gpu, centos-gpu, clang, miscellaneous, unix-cpu, windows-cpu, website, sanity, centos-cpu, edge]
***
_Note_:
Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin.
All CI tests must pass before the PR can be merged.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] anko-intel commented on pull request #20821: [WIP] [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
anko-intel commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1014896574
@mxnet-bot run ci [unix-cpu, windows-gpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] anko-intel commented on pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
anko-intel commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1015366775
@mxnet-bot run ci [centos-cpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] bgawrych commented on pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
bgawrych commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1021919739
@mxnet-bot run ci[windows-gpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] bgawrych merged pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
bgawrych merged pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] anko-intel commented on pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
anko-intel commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1015492228
@DominikaJedynak , @PawelGlomski-Intel please review
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20821: [WIP] [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1015182679
Jenkins CI successfully triggered : [windows-gpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] anko-intel commented on a change in pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
anko-intel commented on a change in pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#discussion_r787689923
##########
File path: src/operator/subgraph/build_subgraph.cc
##########
@@ -749,6 +749,17 @@ void CreateSubgraphNode(nnvm::Graph* g,
for (BiDirectedNode* dest_node : subgraph_nodes) {
sn->outputs.erase(dest_node->node);
}
+ }
+ }
+
+ // Set outputs according to current inputs
+ for (size_t i = 0; i < n->inputs.size(); ++i) {
+ auto& e = n->inputs[i];
+ // update input entries' source simple nodes' outputs map
+ nnvm::Node* node = e.node.get();
+ if (indexed_graph.exist(node)) {
+ const auto nid = indexed_graph.node_id(node);
+ BiDirectedNode* sn = simple_nodes[nid].get();
Review comment:
Yes, ouput is add in line 763 using `sn`.
The difference between previous version is that first all nodes which should be removed are removed in line 750
and later all node which ssould be added are added in line 763.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] anko-intel commented on pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
anko-intel commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1022119645
@mxnet-bot run ci[windows-gpu]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #20821: [FEAUTURE] Fuses FC + elemwise_add operators for oneDNN
Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20821:
URL: https://github.com/apache/incubator-mxnet/pull/20821#issuecomment-1021175637
Jenkins CI successfully triggered : [unix-cpu, unix-gpu, edge, windows-gpu, website, windows-cpu, centos-gpu, centos-cpu, sanity, miscellaneous, clang]
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@mxnet.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org