anko-intel commented on a change in pull request #20816:
URL: https://github.com/apache/incubator-mxnet/pull/20816#discussion_r794366643



##########
File path: src/operator/subgraph/dnnl/dnnl_conv.cc
##########
@@ -266,6 +264,9 @@ void SgDNNLConvOperator::Forward(const OpContext& ctx,
         post_requantize_         = true;
         weight_channelwise_scale = true;
       }
+      if (dnnl_param.enable_float_output) {
+        weight_channelwise_scale = true;

Review comment:
       It looks like when float output is enabled it enforces channel wise 
quantization - it seems to be wrong at the first view. Any comment?

##########
File path: src/operator/subgraph/dnnl/dnnl_conv.cc
##########
@@ -522,10 +528,14 @@ static std::vector<std::string> 
SgDNNLConvListInputNames(const NodeAttrs& attrs)
 
 static std::vector<std::string> SgDNNLConvListOutputNames(const NodeAttrs& 
attrs) {
   auto const& param = nnvm::get<DNNLConvFusionParam>(attrs.parsed);
-  if (param.full_conv_param.dnnl_param.quantized)
-    return std::vector<std::string>{"output", "output_min", "output_max"};
-  else
+  if (param.full_conv_param.dnnl_param.quantized) {
+    if (param.full_conv_param.dnnl_param.enable_float_output)
+      return std::vector<std::string>{"output"};
+    else
+      return std::vector<std::string>{"output", "output_min", "output_max"};
+  } else {
     return std::vector<std::string>{"output"};
+  }

Review comment:
       It could be simplfied:
   ```suggestion
      if (param.full_conv_param.dnnl_param.quantized && 
        !param.full_conv_param.dnnl_param.enable_float_output ) {
         return std::vector<std::string>{"output", "output_min", "output_max"};
     } else {
       return std::vector<std::string>{"output"};
     }
   ```

##########
File path: tests/python/dnnl/subgraphs/test_conv_subgraph.py
##########
@@ -115,6 +115,45 @@ def forward(self, x):
   check_fusion(net, data_shape, attr)
 
 
[email protected]_np
[email protected]('data_shape', DATA_SHAPE)
[email protected]('no_bias', [True, False])
[email protected]('out_type', ['int8', 'auto'])
+def test_pos_conv_add3(no_bias, data_shape, out_type):
+  # conv + add fusion case 3
+  class ConvAdd(nn.HybridBlock):
+    def __init__(self, use_bias, **kwargs):
+        super(ConvAdd, self).__init__(**kwargs)
+        self.conv0 = nn.Conv2D(channels=data_shape[1], kernel_size=(1, 1), 
strides=1, use_bias=use_bias)
+
+    def forward(self, x):
+      out = x + self.conv0(x)
+      return out
+
+  net = ConvAdd(use_bias=True)
+  check_quantize(net, data_shape, out_type)
+
+
[email protected]_np
[email protected]('data_shape', DATA_SHAPE)
[email protected]('no_bias', [True, False])
[email protected]('out_type', ['int8', 'auto'])
+def test_pos_conv_add4(no_bias, data_shape, out_type):
+  # conv + add fusion case 4
+  class ConvAdd(nn.HybridBlock):
+    def __init__(self, use_bias, **kwargs):
+        super(ConvAdd, self).__init__(**kwargs)
+        self.conv0 = nn.Conv2D(channels=data_shape[1], kernel_size=(1, 1), 
strides=1, use_bias=use_bias)
+        self.conv1 = nn.Conv2D(channels=64, kernel_size=(3, 3), strides=1, 
use_bias=use_bias)
+
+    def forward(self, x):
+      out = self.conv1(x + self.conv0(x))
+      return out
+
+  net = ConvAdd(use_bias=True)
+  check_quantize(net, data_shape, out_type)
+
+

Review comment:
       What about test witch convolution, activation and sum ?

##########
File path: src/operator/subgraph/dnnl/dnnl_conv.cc
##########
@@ -130,10 +130,9 @@ void SgDNNLConvOperator::Forward(const OpContext& ctx,
   auto& dnnl_param      = param_.full_conv_param.dnnl_param;
   auto& conv_param      = param_.full_conv_param.conv_param;
   auto bn_param         = param_.bn_param.get();
-  size_t input_size =
-      2 + (conv_param.no_bias ? 0 : 1) + (dnnl_param.with_bn ? 4 : 0) +
-      (dnnl_param.with_sum ? 1 : 0) +
-      (dnnl_param.quantized ? 2 + (full_conv_param.dnnl_param.with_sum ? 2 : 
0) : 0);
+  size_t input_size     = 2 + (conv_param.no_bias ? 0 : 1) + 
(dnnl_param.with_bn ? 4 : 0) +

Review comment:
       I think we can skip this calculation and use only calculated from idx 
below. If we wish to double check it, it will be enough to do it in the assert. 
so we can replace CHECK_EQ in line 167 with assert with calculation from here.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to