cconvey commented on a change in pull request #8952:
URL: https://github.com/apache/tvm/pull/8952#discussion_r723681676
##########
File path: python/tvm/relay/frontend/onnx.py
##########
@@ -3506,6 +3506,155 @@ def _impl_v10(cls, inputs, attr, params):
return _qnn.op.quantize(out, c_scale, c_zero_point, out_dtype=dtype)
+class QLinearMatMul(OnnxOpConverter):
+ """
+ Operator converter for QLinearMatMul from Microsoft onnxruntime contrib
opset.
+
+ Limitations:
+ - Only supports 2D input tensors.
+ - Not guaranteed to meet the integer-overflow behavior stipulated in the
+ ONNX documentation for this operator.
+ """
+
+ @classmethod
+ def _impl_v10(cls, inputs, attr, params):
+
+ # This function has two goals, both of which are to satisfy the input
requirements
+ # various Relay ops used below:
+ #
+ # (1) If a values that's conceptually a scalar is represented as a
tensor,
+ # squeeze it down to just a scalar. This will always be possible
for values
+ # meeting the shape requirements.
+ #
+ # (2) When possible, simplify an expression down to a simple Relay
Const node.
+ def try_convert_to_Constant(x, dtype_override=None):
+ if isinstance(x, _expr.Var) and x.name_hint in params:
+ return _op.const(params[x.name_hint].numpy(), dtype)
+
+ rank = len(infer_shape(x))
+ if rank == 0:
+ x_scalar = x
+ return x
+ elif rank == 1:
+ x_scalar = _op.squeeze(x, [0])
Review comment:
This is copy-pasta from the `get_scalar` function, defined above by
someone else. I'm not sure if I can omit this without causing problems for the
Relay ops I used further down. Maybe this func should be named
`try_convert_to_scalar_constant` instead.
--
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]