code: def test_matmul(executor_kind):
      for dtype in ["float16", "float32"]:
          # Matmul accuracy for float16 is poor
          if dtype == "float16":
              continue
          n, c, h, w = (
              te.size_var("n"),
              te.size_var("c"),
              te.size_var("h"),
              te.size_var("w"),
          )
          x = relay.var("x", relay.TensorType((n, c, h, w), dtype))
          w = relay.var("w", relay.TensorType((2, w), dtype))
          y = relay.nn.matmul(x, w, units=2, transpose_b=True)
          assert "units=2" in y.astext()
          yy = run_infer_type(y)
          assert yy.checked_type == relay.TensorType(
              (n, c, h, 2), dtype
          )
  
          n, c, h, w = (
              te.size_var("n"),
              te.size_var("c"),
              te.size_var("h"),
              2,
          )
          x = relay.var("x", relay.TensorType((n, c, w, h), dtype))
          wh, ww = te.size_var("wh"), te.size_var("ww")
          w = relay.var("w", relay.TensorType((wh, ww), dtype))
          y = relay.nn.matmul(x, w, transpose_a=True)
          yy = run_infer_type(y)
          assert yy.checked_type == relay.TensorType(
              (n, c, h, ww), dtype
          )
  
          n, c, h, w = (
              te.size_var("n"),
              te.size_var("c"),
              te.size_var("h"),
              2,
          )
          x = relay.var("x", relay.TensorType((n, c, h, w), dtype))
          w = relay.var("w", relay.IncompleteType())
          y = relay.nn.matmul(x, w, units=2)
          yy = run_infer_type(y)
          assert yy.checked_type == relay.TensorType(
              (n, c, h, 2), dtype
          )
  
          x = relay.var("x", shape=(5, 10), dtype=dtype)
          w = relay.var("w", shape=(5, 2), dtype=dtype)
          z = relay.nn.matmul(x, w, transpose_a=True)
  
          # Check result.
          func = relay.Function([x, w], z)
          x_data = np.random.rand(5, 10).astype(dtype)
          w_data = np.random.rand(5, 2).astype(dtype)
          ref_res = np.dot(x_data.transpose(), w_data)
  
          for target, dev in tvm.testing.enabled_targets():
              op_res = relay.create_executor(
                  executor_kind, device=dev, target=target
              ).evaluate(func)(x_data, w_data)
              tvm.testing.assert_allclose(
                  op_res.numpy(), ref_res, rtol=1e-5
              )
  
imports: import numpy
  import pytest
  import tvm
  from tvm import te
  import scipy
  from tvm import relay
  import pytest
  from tvm.relay.testing import run_infer_type
  import tvm.topi.testing
  from tvm.contrib.nvcc import have_fp16
  import tvm.testing
  from tvm.topi.utils import get_const_tuple
label_desc: Use image node_id 21 for calling a global function with example usage: test_matmul(executor_kind) without return types