You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2021/09/16 16:59:06 UTC

[GitHub] [tvm] anwang2009 commented on a change in pull request #9028: [ONNX][#8838] QLinearSigmoid contrib op and Bug Fix for DequantizeLinear

anwang2009 commented on a change in pull request #9028:
URL: https://github.com/apache/tvm/pull/9028#discussion_r710298764



##########
File path: python/tvm/relay/frontend/onnx.py
##########
@@ -3351,6 +3351,28 @@ def _impl_v10(cls, inputs, attr, params):
         return _qnn.op.quantize(out, y_scale, y_zero_point, out_dtype=dtype)
 
 
+class QLinearSigmoid(OnnxOpConverter):
+    """Operator converter for QLinearSigmoid from Microsoft onnxruntime contrib opset."""
+
+    @classmethod
+    def _impl_v10(cls, inputs, attr, params):
+        x = inputs[0]
+        x_scale = get_scalar(inputs[1], params)
+        x_zero_point = get_scalar(inputs[2], params, "int32")
+        y_scale = fold_constant(get_scalar(inputs[3], params))
+        y_zero_point = get_scalar(inputs[4], params, "int32")
+
+        dtype = infer_type(x).checked_type.dtype
+
+        ## Apparently, onnxruntime doesn't do this op in integer, they dequantize to fp32
+        ## and then requantize after:
+        ## https://github.com/microsoft/onnxruntime/blob/master/onnxruntime/core/
+        ## providers/dml/DmlExecutionProvider/src/GraphTransformer.cpp#L245
+        x = _qnn.op.dequantize(inputs[0], x_scale, x_zero_point)

Review comment:
       nit
   ```suggestion
           x = _qnn.op.dequantize(x, x_scale, x_zero_point)
   ```




-- 
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@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org