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/13 22:17:02 UTC

[GitHub] [incubator-mxnet] RafLit opened a new pull request #20817: quantized transpose operator

RafLit opened a new pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817


   ## Description ##
   added quantized transpose operator


-- 
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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1045978023


   @mxnet-bot run ci [website]


-- 
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 #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1054111556


   Jenkins CI successfully triggered : [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] bgawrych commented on a change in pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
bgawrych commented on a change in pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#discussion_r804426557



##########
File path: src/operator/quantization/dnnl/dnnl_quantized_transpose.cc
##########
@@ -0,0 +1,93 @@
+
+/*
+ * 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.
+ */
+
+/*!
+ * \file dnnl_quantized_transpose.cc
+ * \author: Rafal Litka, rafal.litka@intel.com
+ */
+#if MXNET_USE_ONEDNN == 1
+#include "../../nn/dnnl/dnnl_transpose-inl.h"
+#include "../../tensor/matrix_op-inl.h"
+
+namespace mxnet {
+namespace op {
+
+inline static bool QuantizedTransposeStorageType(const nnvm::NodeAttrs& attrs,
+                                                 const int dev_mask,
+                                                 DispatchMode* dispatch_mode,
+                                                 std::vector<int>* in_attrs,
+                                                 std::vector<int>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  return DNNLStorageType(attrs, dev_mask, true, dispatch_mode, in_attrs, out_attrs);
+}
+
+bool SupportDNNLQuantizedTranspose(const NDArray& data) {
+  auto data_ndim = data.shape().ndim();
+
+  if (data_ndim > 4 || data_ndim == 0 || data.shape().Size() == 0)
+    return false;
+
+  return true;
+}
+template<class ParamType>
+static void DNNLQuantizedTransposeForward(const nnvm::NodeAttrs& attrs,
+                                          const OpContext& ctx,
+                                          const std::vector<NDArray>& inputs,
+                                          const std::vector<OpReqType>& req,
+                                          const std::vector<NDArray>& outputs) {
+  CHECK(inputs[0].dtype() == mshadow::kUint8 || inputs[0].dtype() == mshadow::kInt8)
+      << "dnnl_quantized_transpose only supports uint8 and int8 as input type";
+  if (req[0] == kNullOp) {
+    return;
+  }
+  CHECK_EQ(inputs.size(), 3U);
+  CHECK_EQ(outputs.size(), 3U);
+  if (SupportDNNLQuantizedTranspose(inputs[0])) {
+    DNNLRun(DNNLTransposeForward<ParamType>, attrs, ctx, inputs[0], req[0], outputs[0]);
+  } else {
+    FallBackCompute(UnaryOp::IdentityCompute<cpu>, attrs, ctx, inputs, req, outputs);

Review comment:
       Why it is fallback to IdentityCompute - I think it should be fallback to NumpyTranspose<cpu> / Transpose<cpu>

##########
File path: tests/python/dnnl/subgraphs/test_conv_subgraph.py
##########
@@ -72,6 +72,26 @@ def forward(self, x):
   net = Conv()
   check_fusion(net, data_shape, attr)
 
+@mx.util.use_np
+@pytest.mark.parametrize('data_shape', DATA_SHAPE)
+@pytest.mark.parametrize('use_bias', [True, False])
+def test_conv_transpose_conv(use_bias, data_shape):
+
+  class Conv_Transpose_Conv(nn.HybridBlock):
+    def __init__(self, **kwargs):
+        super(Conv_Transpose_Conv, self).__init__(**kwargs)
+        self.conv0 = nn.Conv2D(channels=64, kernel_size=(3, 3), strides=1, use_bias=use_bias)
+        self.conv1 = nn.Conv2D(channels=32, kernel_size=(5, 5), strides=1, use_bias=use_bias)
+
+    def forward(self, x):
+      out = self.conv0(x)
+      out = mx.np.transpose(out, axes=[0,1,3,2])
+      out = self.conv1(out)
+      return out
+
+  attr = {'conv': []}
+  net = Conv_Transpose_Conv()
+  check_fusion(net, data_shape, attr)

Review comment:
       I think in this case check_quantize call should be used - probably you can check if transpose was quantized by adding it's name to attr dict




-- 
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 #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1045974032


   Jenkins CI successfully triggered : [website]


-- 
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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1045966752


   @mxnet-bot run ci [website]


-- 
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] agrabows commented on a change in pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
agrabows commented on a change in pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#discussion_r787685862



##########
File path: src/operator/quantization/quantized_transpose.cc
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+/*!
+ * \file quantized_transpose.cc
+ */
+#include <mxnet/op_attr_types.h>
+#include "../tensor/matrix_op-inl.h"
+
+namespace mxnet {
+namespace op {
+
+inline bool QuantizedTransposeType(const nnvm::NodeAttrs& attrs,
+                                   std::vector<int>* in_attrs,
+                                   std::vector<int>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  TYPE_ASSIGN_CHECK(*in_attrs, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*in_attrs, 2, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_attrs, 0, (*in_attrs)[0]);
+  TYPE_ASSIGN_CHECK(*out_attrs, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_attrs, 2, mshadow::kFloat32);
+  return (*in_attrs)[0] != -1;
+}
+
+inline bool QuantizedTransposeShape(const nnvm::NodeAttrs& attrs,
+                                    mxnet::ShapeVector* in_attrs,
+                                    mxnet::ShapeVector* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  mxnet::ShapeVector qin_attrs(1);
+  mxnet::ShapeVector qout_attrs(1);
+  SHAPE_ASSIGN_CHECK(qin_attrs, 0, (*in_attrs)[0]);
+  SHAPE_ASSIGN_CHECK(qout_attrs, 0, (*out_attrs)[0]);
+  TransposeShape(attrs, &qin_attrs, &qout_attrs);
+  SHAPE_ASSIGN_CHECK(*in_attrs, 0, qin_attrs[0]);
+  SHAPE_ASSIGN_CHECK(*out_attrs, 0, qout_attrs[0]);
+  SHAPE_ASSIGN_CHECK(*in_attrs, 1, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*in_attrs, 2, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*out_attrs, 1, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*out_attrs, 2, mxnet::TShape{1});
+  return shape_is_known(qout_attrs[0]);
+}
+
+NNVM_REGISTER_OP(_contrib_quantized_transpose)
+    .add_alias("_npx_quantized_transpose")
+    .set_num_inputs(3)
+    .set_num_outputs(3)
+    .set_attr_parser(ParamParser<TransposeParam>)
+    .set_attr<mxnet::FInferShape>("FInferShape", QuantizedTransposeShape)
+    .set_attr<nnvm::FInferType>("FInferType", QuantizedTransposeType)
+    // TODO(Xinyu): a temp solution to enable GluonCV INT8 flow,
+    // will be reverted after the improvement of CachedOP is done.
+    .set_attr<nnvm::FGradient>("FGradient", MakeZeroGradNodes)
+    .set_attr<nnvm::FListInputNames>(
+        "FListInputNames",
+        [](const NodeAttrs& attrs) {
+          return std::vector<std::string>{"data", "min_data", "max_data"};
+        })
+    .set_attr<nnvm::FListOutputNames>(
+        "FListOutputNames",
+        [](const NodeAttrs& attrs) {
+          return std::vector<std::string>{"output", "min_output", "max_output"};
+        })
+    .set_attr<nnvm::FInplaceOption>(
+        "FInplaceOption",
+        [](const NodeAttrs& attrs) {
+          return std::vector<std::pair<int, int> >{{0, 0}, {1, 1}, {2, 2}};

Review comment:
       Do we use inplace of inputs[0] and outputs[0] for Transpose operator? 




-- 
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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1055438831


   @mxnet-bot run ci [website]


-- 
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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1054197425


   @mxnet-bot run ci [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] mxnet-bot commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1054085564


   Jenkins CI successfully triggered : [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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1044423690


   @mxnet-bot run ci [website]


-- 
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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1045974015


   @mxnet-bot run ci [website]


-- 
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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1045244702


   @mxnet-bot run ci [windows-gpu, website]


-- 
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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1046105329


   @mxnet-bot run ci [website]


-- 
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] bartekkuncer commented on a change in pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
bartekkuncer commented on a change in pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#discussion_r787700675



##########
File path: src/operator/quantization/dnnl/dnnl_quantized_transpose.cc
##########
@@ -0,0 +1,70 @@
+
+/*
+ * 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.
+ */
+
+/*!
+ * \file dnnl_quantized_transpose.cc
+ */
+#if MXNET_USE_ONEDNN == 1
+#include "../../nn/dnnl/dnnl_transpose-inl.h"
+#include "../../tensor/matrix_op-inl.h"
+
+namespace mxnet {
+namespace op {
+
+inline static bool QuantizedTransposeStorageType(const nnvm::NodeAttrs& attrs,
+                                                 const int dev_mask,
+                                                 DispatchMode* dispatch_mode,
+                                                 std::vector<int>* in_attrs,
+                                                 std::vector<int>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  return DNNLStorageType(attrs, dev_mask, true, dispatch_mode, in_attrs, out_attrs);
+}
+
+static void DNNLQuantizedTransposeForward(const nnvm::NodeAttrs& attrs,
+                                          const OpContext& ctx,
+                                          const std::vector<NDArray>& inputs,
+                                          const std::vector<OpReqType>& req,
+                                          const std::vector<NDArray>& outputs) {
+  CHECK(inputs[0].dtype() == mshadow::kUint8 || inputs[0].dtype() == mshadow::kInt8)
+      << "dnnl_quantized_pooling op only supports uint8 and int8 as input type";
+  if (req[0] == kNullOp) {
+    return;
+  }
+  CHECK_EQ(inputs.size(), 3U);
+  CHECK_EQ(outputs.size(), 3U);
+  DNNLRun(DNNLTransposeForward<TransposeParam>, attrs, ctx, inputs[0], req[0], outputs[0]);

Review comment:
       I believe Rafał wrote the checks here as they are different than the ones in SupportDNNLTranspose function. I agree that they could be moved to a function.

##########
File path: src/operator/quantization/quantized_transpose.cc
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+/*!
+ * \file quantized_transpose.cc
+ */
+#include <mxnet/op_attr_types.h>
+#include "../tensor/matrix_op-inl.h"
+
+namespace mxnet {
+namespace op {
+
+inline bool QuantizedTransposeType(const nnvm::NodeAttrs& attrs,
+                                   std::vector<int>* in_attrs,
+                                   std::vector<int>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  TYPE_ASSIGN_CHECK(*in_attrs, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*in_attrs, 2, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_attrs, 0, (*in_attrs)[0]);
+  TYPE_ASSIGN_CHECK(*out_attrs, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_attrs, 2, mshadow::kFloat32);
+  return (*in_attrs)[0] != -1;
+}
+
+inline bool QuantizedTransposeShape(const nnvm::NodeAttrs& attrs,
+                                    mxnet::ShapeVector* in_attrs,
+                                    mxnet::ShapeVector* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  mxnet::ShapeVector qin_attrs(1);
+  mxnet::ShapeVector qout_attrs(1);
+  SHAPE_ASSIGN_CHECK(qin_attrs, 0, (*in_attrs)[0]);
+  SHAPE_ASSIGN_CHECK(qout_attrs, 0, (*out_attrs)[0]);
+  TransposeShape(attrs, &qin_attrs, &qout_attrs);
+  SHAPE_ASSIGN_CHECK(*in_attrs, 0, qin_attrs[0]);
+  SHAPE_ASSIGN_CHECK(*out_attrs, 0, qout_attrs[0]);
+  SHAPE_ASSIGN_CHECK(*in_attrs, 1, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*in_attrs, 2, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*out_attrs, 1, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*out_attrs, 2, mxnet::TShape{1});
+  return shape_is_known(qout_attrs[0]);
+}
+
+NNVM_REGISTER_OP(_contrib_quantized_transpose)
+    .add_alias("_npx_quantized_transpose")
+    .set_num_inputs(3)
+    .set_num_outputs(3)
+    .set_attr_parser(ParamParser<TransposeParam>)
+    .set_attr<mxnet::FInferShape>("FInferShape", QuantizedTransposeShape)
+    .set_attr<nnvm::FInferType>("FInferType", QuantizedTransposeType)
+    // TODO(Xinyu): a temp solution to enable GluonCV INT8 flow,

Review comment:
       I believe this comment is taken from another operator and as its scope is bigger than just transpose op, checking whether it is still valid could be done in a separate task.




-- 
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 #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1054186207


   Jenkins CI successfully triggered : [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] mxnet-bot commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1054047385


   Jenkins CI successfully triggered : [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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1054047275


   @mxnet-bot run ci [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] mxnet-bot commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1046566144


   Jenkins CI successfully triggered : [website]


-- 
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 #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1046299513


   Jenkins CI successfully triggered : [website]


-- 
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 #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1046105345


   Jenkins CI successfully triggered : [website]


-- 
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] agrabows commented on a change in pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
agrabows commented on a change in pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#discussion_r787686361



##########
File path: src/operator/quantization/quantized_transpose.cc
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+/*!
+ * \file quantized_transpose.cc
+ */
+#include <mxnet/op_attr_types.h>
+#include "../tensor/matrix_op-inl.h"
+
+namespace mxnet {
+namespace op {
+
+inline bool QuantizedTransposeType(const nnvm::NodeAttrs& attrs,
+                                   std::vector<int>* in_attrs,
+                                   std::vector<int>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  TYPE_ASSIGN_CHECK(*in_attrs, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*in_attrs, 2, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_attrs, 0, (*in_attrs)[0]);
+  TYPE_ASSIGN_CHECK(*out_attrs, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_attrs, 2, mshadow::kFloat32);
+  return (*in_attrs)[0] != -1;
+}
+
+inline bool QuantizedTransposeShape(const nnvm::NodeAttrs& attrs,
+                                    mxnet::ShapeVector* in_attrs,
+                                    mxnet::ShapeVector* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  mxnet::ShapeVector qin_attrs(1);
+  mxnet::ShapeVector qout_attrs(1);
+  SHAPE_ASSIGN_CHECK(qin_attrs, 0, (*in_attrs)[0]);
+  SHAPE_ASSIGN_CHECK(qout_attrs, 0, (*out_attrs)[0]);
+  TransposeShape(attrs, &qin_attrs, &qout_attrs);
+  SHAPE_ASSIGN_CHECK(*in_attrs, 0, qin_attrs[0]);
+  SHAPE_ASSIGN_CHECK(*out_attrs, 0, qout_attrs[0]);
+  SHAPE_ASSIGN_CHECK(*in_attrs, 1, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*in_attrs, 2, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*out_attrs, 1, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*out_attrs, 2, mxnet::TShape{1});
+  return shape_is_known(qout_attrs[0]);
+}
+
+NNVM_REGISTER_OP(_contrib_quantized_transpose)
+    .add_alias("_npx_quantized_transpose")
+    .set_num_inputs(3)
+    .set_num_outputs(3)
+    .set_attr_parser(ParamParser<TransposeParam>)
+    .set_attr<mxnet::FInferShape>("FInferShape", QuantizedTransposeShape)
+    .set_attr<nnvm::FInferType>("FInferType", QuantizedTransposeType)
+    // TODO(Xinyu): a temp solution to enable GluonCV INT8 flow,
+    // will be reverted after the improvement of CachedOP is done.
+    .set_attr<nnvm::FGradient>("FGradient", MakeZeroGradNodes)
+    .set_attr<nnvm::FListInputNames>(
+        "FListInputNames",
+        [](const NodeAttrs& attrs) {
+          return std::vector<std::string>{"data", "min_data", "max_data"};
+        })
+    .set_attr<nnvm::FListOutputNames>(
+        "FListOutputNames",
+        [](const NodeAttrs& attrs) {
+          return std::vector<std::string>{"output", "min_output", "max_output"};
+        })
+    .set_attr<nnvm::FInplaceOption>(
+        "FInplaceOption",
+        [](const NodeAttrs& attrs) {
+          return std::vector<std::pair<int, int> >{{0, 0}, {1, 1}, {2, 2}};
+        })
+    .add_argument("data", "NDArray-or-Symbol", "A ndarray/symbol of type `float32`")

Review comment:
       Isn't data for this operator only int8 and uint8?




-- 
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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1046566079


   @mxnet-bot run ci [website]


-- 
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 a change in pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
bgawrych commented on a change in pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#discussion_r810908640



##########
File path: src/operator/quantization/quantized_transpose.cc
##########
@@ -0,0 +1,130 @@
+/*
+ * 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.
+ */
+
+/*!
+ * \file quantized_transpose.cc
+ * \author: Rafal Litka, rafal.litka@intel.com
+ */
+#include <mxnet/op_attr_types.h>
+#include "../tensor/matrix_op-inl.h"
+#include "../numpy/np_matrix_op-inl.h"
+
+namespace mxnet {
+namespace op {
+
+inline bool QuantizedTransposeType(const nnvm::NodeAttrs& attrs,
+                                   std::vector<int>* in_attrs,
+                                   std::vector<int>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  TYPE_ASSIGN_CHECK(*in_attrs, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*in_attrs, 2, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_attrs, 0, (*in_attrs)[0]);
+  TYPE_ASSIGN_CHECK(*out_attrs, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_attrs, 2, mshadow::kFloat32);
+  return (*in_attrs)[0] != -1;
+}
+
+typedef bool (*TransposeShapeFunAny)(const nnvm::NodeAttrs&,
+                                     mxnet::ShapeVector*,
+                                     mxnet::ShapeVector*);
+
+template <TransposeShapeFunAny TransposeShapeFun>
+inline bool QuantizedTransposeShape(const nnvm::NodeAttrs& attrs,
+                                    mxnet::ShapeVector* in_attrs,
+                                    mxnet::ShapeVector* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  mxnet::ShapeVector qin_attrs(1);
+  mxnet::ShapeVector qout_attrs(1);
+  SHAPE_ASSIGN_CHECK(qin_attrs, 0, (*in_attrs)[0]);
+  SHAPE_ASSIGN_CHECK(qout_attrs, 0, (*out_attrs)[0]);
+  bool ret = TransposeShapeFun(attrs, &qin_attrs, &qout_attrs);
+  SHAPE_ASSIGN_CHECK(*in_attrs, 0, qin_attrs[0]);
+  SHAPE_ASSIGN_CHECK(*out_attrs, 0, qout_attrs[0]);
+  SHAPE_ASSIGN_CHECK(*in_attrs, 1, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*in_attrs, 2, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*out_attrs, 1, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*out_attrs, 2, mxnet::TShape{1});
+  return ret;
+}
+
+#define MXNET_OPERATOR_REGISTER_QUANTIZED_TRANSPOSE(name)                                    \
+  NNVM_REGISTER_OP(name)                                                                     \
+      .set_num_inputs(3)                                                                     \
+      .set_num_outputs(3)                                                                    \
+      .set_attr<nnvm::FInferType>("FInferType", QuantizedTransposeType)                      \
+      .set_attr<nnvm::FGradient>("FGradient", MakeZeroGradNodes)                             \
+      .set_attr<nnvm::FListInputNames>(                                                      \
+          "FListInputNames",                                                                 \
+          [](const NodeAttrs& attrs) {                                                       \
+            return std::vector<std::string>{"data", "min_data", "max_data"};                 \
+          })                                                                                 \
+      .set_attr<nnvm::FListOutputNames>(                                                     \
+          "FListOutputNames",                                                                \
+          [](const NodeAttrs& attrs) {                                                       \
+            return std::vector<std::string>{"output", "min_output", "max_output"};           \
+          })                                                                                 \
+      .set_attr<FQuantizable>("FQuantizable",                                                \
+                              [](const NodeAttrs& attrs) { return QuantizeType::kSupport; }) \
+      .add_argument("data", "NDArray-or-Symbol", "Array to be reshaped.")                    \

Review comment:
       ```suggestion
         .add_argument("data", "NDArray-or-Symbol", "Array to be transposed.")                    \
   ```




-- 
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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1054186103


   @mxnet-bot run ci [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] mxnet-bot commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1054197511


   Jenkins CI successfully triggered : [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] mxnet-bot commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1045966771


   Jenkins CI successfully triggered : [website]


-- 
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 #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1044423841


   Jenkins CI successfully triggered : [website]


-- 
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 #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1055438929


   Jenkins CI successfully triggered : [website]


-- 
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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1046299495


   @mxnet-bot run ci [website]


-- 
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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1054111466


   @mxnet-bot run ci [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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1054130950


   @mxnet-bot run ci [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] mxnet-bot commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1045244861


   Jenkins CI successfully triggered : [website, 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 #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1045978032


   Jenkins CI successfully triggered : [website]


-- 
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 #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1012560724


   Hey @RafLit , 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**: [unix-gpu, windows-cpu, unix-cpu, edge, clang, centos-cpu, windows-gpu, sanity, website, centos-gpu, miscellaneous]
   *** 
   _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] agrabows commented on a change in pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
agrabows commented on a change in pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#discussion_r787634366



##########
File path: src/operator/quantization/dnnl/dnnl_quantized_transpose.cc
##########
@@ -0,0 +1,70 @@
+
+/*
+ * 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.
+ */
+
+/*!
+ * \file dnnl_quantized_transpose.cc
+ */
+#if MXNET_USE_ONEDNN == 1
+#include "../../nn/dnnl/dnnl_transpose-inl.h"
+#include "../../tensor/matrix_op-inl.h"
+
+namespace mxnet {
+namespace op {
+
+inline static bool QuantizedTransposeStorageType(const nnvm::NodeAttrs& attrs,
+                                                 const int dev_mask,
+                                                 DispatchMode* dispatch_mode,
+                                                 std::vector<int>* in_attrs,
+                                                 std::vector<int>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  return DNNLStorageType(attrs, dev_mask, true, dispatch_mode, in_attrs, out_attrs);
+}
+
+static void DNNLQuantizedTransposeForward(const nnvm::NodeAttrs& attrs,
+                                          const OpContext& ctx,
+                                          const std::vector<NDArray>& inputs,
+                                          const std::vector<OpReqType>& req,
+                                          const std::vector<NDArray>& outputs) {
+  CHECK(inputs[0].dtype() == mshadow::kUint8 || inputs[0].dtype() == mshadow::kInt8)
+      << "dnnl_quantized_pooling op only supports uint8 and int8 as input type";

Review comment:
       This comment (dnnl_quantized_pooling) does not fit in here. 

##########
File path: tests/python/quantization/test_quantization.py
##########
@@ -713,6 +713,32 @@ def forward(self, x):
         check_quantized_fc((256, 2048, 2, 2), 800, False, qdtype)
         check_quantized_fc((256, 111, 2, 2), 800, False, qdtype)
 
+@use_np
+def test_quantized_transpose():

Review comment:
       Maybye add some test for quantized transpose after some other quantizable operator e.g. conv, fc.

##########
File path: src/operator/quantization/quantized_transpose.cc
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+/*!
+ * \file quantized_transpose.cc
+ */
+#include <mxnet/op_attr_types.h>
+#include "../tensor/matrix_op-inl.h"
+
+namespace mxnet {
+namespace op {
+
+inline bool QuantizedTransposeType(const nnvm::NodeAttrs& attrs,
+                                   std::vector<int>* in_attrs,
+                                   std::vector<int>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  TYPE_ASSIGN_CHECK(*in_attrs, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*in_attrs, 2, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_attrs, 0, (*in_attrs)[0]);
+  TYPE_ASSIGN_CHECK(*out_attrs, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_attrs, 2, mshadow::kFloat32);
+  return (*in_attrs)[0] != -1;
+}
+
+inline bool QuantizedTransposeShape(const nnvm::NodeAttrs& attrs,
+                                    mxnet::ShapeVector* in_attrs,
+                                    mxnet::ShapeVector* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  mxnet::ShapeVector qin_attrs(1);
+  mxnet::ShapeVector qout_attrs(1);
+  SHAPE_ASSIGN_CHECK(qin_attrs, 0, (*in_attrs)[0]);
+  SHAPE_ASSIGN_CHECK(qout_attrs, 0, (*out_attrs)[0]);
+  TransposeShape(attrs, &qin_attrs, &qout_attrs);
+  SHAPE_ASSIGN_CHECK(*in_attrs, 0, qin_attrs[0]);
+  SHAPE_ASSIGN_CHECK(*out_attrs, 0, qout_attrs[0]);
+  SHAPE_ASSIGN_CHECK(*in_attrs, 1, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*in_attrs, 2, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*out_attrs, 1, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*out_attrs, 2, mxnet::TShape{1});
+  return shape_is_known(qout_attrs[0]);
+}
+
+NNVM_REGISTER_OP(_contrib_quantized_transpose)
+    .add_alias("_npx_quantized_transpose")
+    .set_num_inputs(3)
+    .set_num_outputs(3)
+    .set_attr_parser(ParamParser<TransposeParam>)
+    .set_attr<mxnet::FInferShape>("FInferShape", QuantizedTransposeShape)
+    .set_attr<nnvm::FInferType>("FInferType", QuantizedTransposeType)
+    // TODO(Xinyu): a temp solution to enable GluonCV INT8 flow,
+    // will be reverted after the improvement of CachedOP is done.
+    .set_attr<nnvm::FGradient>("FGradient", MakeZeroGradNodes)
+    .set_attr<nnvm::FListInputNames>(
+        "FListInputNames",
+        [](const NodeAttrs& attrs) {
+          return std::vector<std::string>{"data", "min_data", "max_data"};
+        })
+    .set_attr<nnvm::FListOutputNames>(
+        "FListOutputNames",
+        [](const NodeAttrs& attrs) {
+          return std::vector<std::string>{"output", "min_output", "max_output"};
+        })
+    .set_attr<nnvm::FInplaceOption>(
+        "FInplaceOption",
+        [](const NodeAttrs& attrs) {
+          return std::vector<std::pair<int, int> >{{0, 0}, {1, 1}, {2, 2}};
+        })
+    .add_argument("data", "NDArray-or-Symbol", "A ndarray/symbol of type `float32`")
+    .add_argument("min_data",
+                  "NDArray-or-Symbol",
+                  "The minimum scalar value "
+                  "possibly produced for the data")
+    .add_argument("max_data",
+                  "NDArray-or-Symbol",
+                  "The maximum scalar value "
+                  "possibly produced for the data")
+    .add_arguments(TransposeParam::__FIELDS__());

Review comment:
       Did you consider adding FQuantizable attribute with _return QuantizeType::kSupport;_ ? 

##########
File path: src/operator/quantization/dnnl/dnnl_quantized_transpose.cc
##########
@@ -0,0 +1,70 @@
+
+/*
+ * 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.
+ */
+
+/*!
+ * \file dnnl_quantized_transpose.cc
+ */
+#if MXNET_USE_ONEDNN == 1
+#include "../../nn/dnnl/dnnl_transpose-inl.h"
+#include "../../tensor/matrix_op-inl.h"
+
+namespace mxnet {
+namespace op {
+
+inline static bool QuantizedTransposeStorageType(const nnvm::NodeAttrs& attrs,
+                                                 const int dev_mask,
+                                                 DispatchMode* dispatch_mode,
+                                                 std::vector<int>* in_attrs,
+                                                 std::vector<int>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  return DNNLStorageType(attrs, dev_mask, true, dispatch_mode, in_attrs, out_attrs);
+}
+
+static void DNNLQuantizedTransposeForward(const nnvm::NodeAttrs& attrs,
+                                          const OpContext& ctx,
+                                          const std::vector<NDArray>& inputs,
+                                          const std::vector<OpReqType>& req,
+                                          const std::vector<NDArray>& outputs) {
+  CHECK(inputs[0].dtype() == mshadow::kUint8 || inputs[0].dtype() == mshadow::kInt8)
+      << "dnnl_quantized_pooling op only supports uint8 and int8 as input type";
+  if (req[0] == kNullOp) {
+    return;
+  }
+  CHECK_EQ(inputs.size(), 3U);
+  CHECK_EQ(outputs.size(), 3U);
+  DNNLRun(DNNLTransposeForward<TransposeParam>, attrs, ctx, inputs[0], req[0], outputs[0]);

Review comment:
       Shouldn't we check if inputs pass through _SupportDNNLTranspose_ functions' conditions before calling _DNNLTransposeForward_?

##########
File path: src/operator/quantization/quantized_transpose.cc
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+/*!
+ * \file quantized_transpose.cc
+ */
+#include <mxnet/op_attr_types.h>
+#include "../tensor/matrix_op-inl.h"
+
+namespace mxnet {
+namespace op {
+
+inline bool QuantizedTransposeType(const nnvm::NodeAttrs& attrs,
+                                   std::vector<int>* in_attrs,
+                                   std::vector<int>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  TYPE_ASSIGN_CHECK(*in_attrs, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*in_attrs, 2, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_attrs, 0, (*in_attrs)[0]);
+  TYPE_ASSIGN_CHECK(*out_attrs, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_attrs, 2, mshadow::kFloat32);
+  return (*in_attrs)[0] != -1;
+}
+
+inline bool QuantizedTransposeShape(const nnvm::NodeAttrs& attrs,
+                                    mxnet::ShapeVector* in_attrs,
+                                    mxnet::ShapeVector* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  mxnet::ShapeVector qin_attrs(1);
+  mxnet::ShapeVector qout_attrs(1);
+  SHAPE_ASSIGN_CHECK(qin_attrs, 0, (*in_attrs)[0]);
+  SHAPE_ASSIGN_CHECK(qout_attrs, 0, (*out_attrs)[0]);
+  TransposeShape(attrs, &qin_attrs, &qout_attrs);
+  SHAPE_ASSIGN_CHECK(*in_attrs, 0, qin_attrs[0]);
+  SHAPE_ASSIGN_CHECK(*out_attrs, 0, qout_attrs[0]);
+  SHAPE_ASSIGN_CHECK(*in_attrs, 1, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*in_attrs, 2, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*out_attrs, 1, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*out_attrs, 2, mxnet::TShape{1});
+  return shape_is_known(qout_attrs[0]);
+}
+
+NNVM_REGISTER_OP(_contrib_quantized_transpose)
+    .add_alias("_npx_quantized_transpose")
+    .set_num_inputs(3)
+    .set_num_outputs(3)
+    .set_attr_parser(ParamParser<TransposeParam>)
+    .set_attr<mxnet::FInferShape>("FInferShape", QuantizedTransposeShape)
+    .set_attr<nnvm::FInferType>("FInferType", QuantizedTransposeType)
+    // TODO(Xinyu): a temp solution to enable GluonCV INT8 flow,

Review comment:
       Is this comment valid for this change?




-- 
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] agrabows commented on a change in pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
agrabows commented on a change in pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#discussion_r787736155



##########
File path: src/operator/quantization/quantized_transpose.cc
##########
@@ -0,0 +1,109 @@
+/*
+ * 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.
+ */
+
+/*!
+ * \file quantized_transpose.cc
+ */
+#include <mxnet/op_attr_types.h>
+#include "../tensor/matrix_op-inl.h"
+
+namespace mxnet {
+namespace op {
+
+inline bool QuantizedTransposeType(const nnvm::NodeAttrs& attrs,
+                                   std::vector<int>* in_attrs,
+                                   std::vector<int>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  TYPE_ASSIGN_CHECK(*in_attrs, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*in_attrs, 2, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_attrs, 0, (*in_attrs)[0]);
+  TYPE_ASSIGN_CHECK(*out_attrs, 1, mshadow::kFloat32);
+  TYPE_ASSIGN_CHECK(*out_attrs, 2, mshadow::kFloat32);
+  return (*in_attrs)[0] != -1;
+}
+
+inline bool QuantizedTransposeShape(const nnvm::NodeAttrs& attrs,
+                                    mxnet::ShapeVector* in_attrs,
+                                    mxnet::ShapeVector* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  mxnet::ShapeVector qin_attrs(1);
+  mxnet::ShapeVector qout_attrs(1);
+  SHAPE_ASSIGN_CHECK(qin_attrs, 0, (*in_attrs)[0]);
+  SHAPE_ASSIGN_CHECK(qout_attrs, 0, (*out_attrs)[0]);
+  TransposeShape(attrs, &qin_attrs, &qout_attrs);
+  SHAPE_ASSIGN_CHECK(*in_attrs, 0, qin_attrs[0]);
+  SHAPE_ASSIGN_CHECK(*out_attrs, 0, qout_attrs[0]);
+  SHAPE_ASSIGN_CHECK(*in_attrs, 1, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*in_attrs, 2, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*out_attrs, 1, mxnet::TShape{1});
+  SHAPE_ASSIGN_CHECK(*out_attrs, 2, mxnet::TShape{1});
+  return shape_is_known(qout_attrs[0]);
+}
+
+NNVM_REGISTER_OP(_contrib_quantized_transpose)
+    .add_alias("_npx_quantized_transpose")
+    .set_num_inputs(3)
+    .set_num_outputs(3)
+    .set_attr_parser(ParamParser<TransposeParam>)
+    .set_attr<mxnet::FInferShape>("FInferShape", QuantizedTransposeShape)
+    .set_attr<nnvm::FInferType>("FInferType", QuantizedTransposeType)
+    // TODO(Xinyu): a temp solution to enable GluonCV INT8 flow,

Review comment:
       If so I think this issue can be resolved.

##########
File path: src/operator/quantization/dnnl/dnnl_quantized_transpose.cc
##########
@@ -0,0 +1,70 @@
+
+/*
+ * 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.
+ */
+
+/*!
+ * \file dnnl_quantized_transpose.cc
+ */
+#if MXNET_USE_ONEDNN == 1
+#include "../../nn/dnnl/dnnl_transpose-inl.h"
+#include "../../tensor/matrix_op-inl.h"
+
+namespace mxnet {
+namespace op {
+
+inline static bool QuantizedTransposeStorageType(const nnvm::NodeAttrs& attrs,
+                                                 const int dev_mask,
+                                                 DispatchMode* dispatch_mode,
+                                                 std::vector<int>* in_attrs,
+                                                 std::vector<int>* out_attrs) {
+  CHECK_EQ(in_attrs->size(), 3U);
+  CHECK_EQ(out_attrs->size(), 3U);
+  return DNNLStorageType(attrs, dev_mask, true, dispatch_mode, in_attrs, out_attrs);
+}
+
+static void DNNLQuantizedTransposeForward(const nnvm::NodeAttrs& attrs,
+                                          const OpContext& ctx,
+                                          const std::vector<NDArray>& inputs,
+                                          const std::vector<OpReqType>& req,
+                                          const std::vector<NDArray>& outputs) {
+  CHECK(inputs[0].dtype() == mshadow::kUint8 || inputs[0].dtype() == mshadow::kInt8)
+      << "dnnl_quantized_pooling op only supports uint8 and int8 as input type";
+  if (req[0] == kNullOp) {
+    return;
+  }
+  CHECK_EQ(inputs.size(), 3U);
+  CHECK_EQ(outputs.size(), 3U);
+  DNNLRun(DNNLTransposeForward<TransposeParam>, attrs, ctx, inputs[0], req[0], outputs[0]);

Review comment:
       Fair point. To be precise it concerns me that in similar function _TransposeComputeExCPU()_ we call _SupportDNNLTranspose()_ function with e.g. _data.shape().Size() == 0_ condition before calling _DNNLRun_. If this and other checks are necessary I believe we should include them here as well. If not probably we should exclude them from _SupportDNNLTranspose()_ in other PR.




-- 
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 #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
bgawrych merged pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817


   


-- 
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 #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1054130997


   Jenkins CI successfully triggered : [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] RafLit commented on pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
RafLit commented on pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#issuecomment-1054085485


   @mxnet-bot run ci [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] bgawrych commented on a change in pull request #20817: quantized transpose operator

Posted by GitBox <gi...@apache.org>.
bgawrych commented on a change in pull request #20817:
URL: https://github.com/apache/incubator-mxnet/pull/20817#discussion_r815842078



##########
File path: src/operator/quantization/dnnl/dnnl_quantized_transpose.cc
##########
@@ -0,0 +1,102 @@
+
+/*
+ * 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.
+ */
+
+/*!
+ * \file dnnl_quantized_transpose.cc
+ * \author: Rafal Litka, rafal.litka@intel.com
+ */
+#if MXNET_USE_ONEDNN == 1
+#include "../../numpy/np_matrix_op-inl.h"
+#include "../../tensor/matrix_op-inl.h"
+#include "../../nn/dnnl/dnnl_transpose-inl.h"

Review comment:
       ```suggestion
   #include "operator/numpy/np_matrix_op-inl.h"
   #include "operator/tensor/matrix_op-inl.h"
   #include "operator/nn/dnnl/dnnl_transpose-inl.h"
   ```
   
   some time ago PR was merged to replace relative paths in dnnl files




-- 
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