cconvey commented on a change in pull request #8952:
URL: https://github.com/apache/tvm/pull/8952#discussion_r704465027



##########
File path: python/tvm/relay/frontend/onnx.py
##########
@@ -3333,6 +3333,44 @@ def get_scalar(x, dtype="float32"):
         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."""
+
+    @classmethod
+    def _impl_v10(cls, inputs, attr, params):
+        def get_scalar(x, dtype="float32"):
+            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))
+            assert rank <= 1, "QLinearMatMul scale and zero_point input must 
be scalars"
+            if rank == 1:
+                x = _op.squeeze(x, [0])
+            return _op.cast(x, dtype)
+
+        a = inputs[0]
+        a_scale = get_scalar(inputs[1])
+        a_zero_point = get_scalar(inputs[2], "int32")
+
+        b = inputs[3]
+        b_scale = get_scalar(inputs[4])
+        b_zero_point = get_scalar(inputs[5], "int32")
+
+        y_scale = fold_constant(get_scalar(inputs[6]))
+        y_zero_point = get_scalar(inputs[7], "int32")
+
+        dtype = infer_type(a).checked_type.dtype
+
+        a_rank = len(infer_shape(a))
+        b_rank = len(infer_shape(b))
+
+        assert ((a_rank == 2) and (b_rank == 2)), "QLinearMatMul importer 
currently requires both 'a' and 'b' tensors to be 2D, but rank(a)={}, 
rank(b)={}".format(a_rank, b_rank)

Review comment:
       I'm developing in a native Pop_OS! (Ubuntu 20.04 -based) environment, 
and `make pylint` hits a bunch of internal(?) errors:
   ```
   [snip]
       result = _cache[func, node] = list(func(*args, **kwargs))
     File 
"/home/cconvey/.local/lib/python3.8/site-packages/astroid/brain/brain_typing.py",
 line 302, in infer_typing_alias
       maybe_type_var = node.args[1]
   IndexError: list index out of range
   """
   
   The above exception was the direct cause of the following exception:
   
   Traceback (most recent call last):
     File "/usr/lib/python3.8/runpy.py", line 194, in _run_module_as_main
       return _run_code(code, main_globals, None,
     File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
       exec(code, run_globals)
     File 
"/home/cconvey/.local/lib/python3.8/site-packages/pylint/__main__.py", line 9, 
in <module>
       pylint.run_pylint()
     File 
"/home/cconvey/.local/lib/python3.8/site-packages/pylint/__init__.py", line 24, 
in run_pylint
       PylintRun(sys.argv[1:])
     File 
"/home/cconvey/.local/lib/python3.8/site-packages/pylint/lint/run.py", line 
385, in __init__
       linter.check(args)
     File 
"/home/cconvey/.local/lib/python3.8/site-packages/pylint/lint/pylinter.py", 
line 993, in check
       check_parallel(
     File 
"/home/cconvey/.local/lib/python3.8/site-packages/pylint/lint/parallel.py", 
line 140, in check_parallel
       for (
     File "/usr/lib/python3.8/multiprocessing/pool.py", line 868, in next
       raise value
   IndexError: list index out of range
   make: *** [Makefile:105: pylint] Error 1
   ```
   
   Is this expected?




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