code: def test_gemm(self):
      # simple
      A = np.random.randn(3, 2).astype(np.float32)
      B = np.random.randn(2, 4).astype(np.float32)
      C = np.random.randn(3, 4).astype(np.float32)
      node_def = make_node("Gemm", ["A", "B", "C"], ["Y"])
      output = c2.run_node(node_def, [A, B, C])
      np.testing.assert_almost_equal(output["Y"], np.dot(A, B) + C)
  
      # transA
      A = np.transpose(A)
      node_def = make_node("Gemm", ["A", "B", "C"], ["Y"], transA=1)
      output = c2.run_node(node_def, [A, B, C])
      np.testing.assert_almost_equal(
          output["Y"], np.dot(np.transpose(A), B) + C
      )
      # revert A
      A = np.transpose(A)
  
      # transB
      B = np.transpose(B)
      node_def = make_node("Gemm", ["A", "B", "C"], ["Y"], transB=1)
      output = c2.run_node(node_def, [A, B, C])
      np.testing.assert_almost_equal(
          output["Y"], np.dot(A, np.transpose(B)) + C
      )
      # revert B
      B = np.transpose(B)
  
      # scale
      alpha = np.random.random()
      beta = np.random.random()
      node_def = make_node(
          "Gemm", ["A", "B", "C"], ["Y"], alpha=alpha, beta=beta
      )
      output = c2.run_node(node_def, [A, B, C])
      np.testing.assert_almost_equal(
          output["Y"], alpha * np.dot(A, B) + beta * C
      )
  
      # setup broadcastable C
      C = np.random.randn(4).astype(np.float32)
  
      # broadcast for opset7
      node_def = make_node(
          "Gemm", ["A", "B", "C"], ["Y"], alpha=alpha, beta=beta
      )
      output = c2.run_node(node_def, [A, B, C], opset_version=7)
      np.testing.assert_almost_equal(
          output["Y"], alpha * np.dot(A, B) + beta * C
      )
      # broadcast for opset3 and 6
      node_def = make_node(
          "Gemm",
          ["A", "B", "C"],
          ["Y"],
          alpha=alpha,
          beta=beta,
          broadcast=1,
      )
      output = c2.run_node(node_def, [A, B, C], opset_version=6)
      np.testing.assert_almost_equal(
          output["Y"], alpha * np.dot(A, B) + beta * C
      )
  
      # transB
      B = np.transpose(B)
  
      # transB and broadcast for opset7
      node_def = make_node(
          "Gemm",
          ["A", "B", "C"],
          ["Y"],
          alpha=alpha,
          beta=beta,
          transB=1,
      )
      output = c2.run_node(node_def, [A, B, C], opset_version=7)
      np.testing.assert_almost_equal(
          output["Y"], alpha * np.dot(A, np.transpose(B)) + beta * C
      )
      # transB and broadcast for opset3 and 6
      node_def = make_node(
          "Gemm",
          ["A", "B", "C"],
          ["Y"],
          alpha=alpha,
          beta=beta,
          broadcast=1,
          transB=1,
      )
      output = c2.run_node(node_def, [A, B, C], opset_version=6)
      np.testing.assert_almost_equal(
          output["Y"], alpha * np.dot(A, np.transpose(B)) + beta * C
      )
  
      # revert B
      B = np.transpose(B)
      # set a scalar to C
      C = np.random.randn(1).astype(np.float32)
  
      # scalar broadcast for opset7
      node_def = make_node(
          "Gemm", ["A", "B", "C"], ["Y"], alpha=alpha, beta=beta
      )
      output = c2.run_node(node_def, [A, B, C], opset_version=7)
      np.testing.assert_almost_equal(
          output["Y"], alpha * np.dot(A, B) + beta * C
      )
      # scalar broadcast for opset3 and 6
      node_def = make_node(
          "Gemm",
          ["A", "B", "C"],
          ["Y"],
          alpha=alpha,
          beta=beta,
          broadcast=1,
      )
      output = c2.run_node(node_def, [A, B, C], opset_version=6)
      np.testing.assert_almost_equal(
          output["Y"], alpha * np.dot(A, B) + beta * C
      )
  
imports: import os
  import unittest
  from caffe2.python import core
  from caffe2.proto import caffe2_pb2
  import onnx
  from onnx.helper import make_node, make_graph, make_tensor, make_tensor_value_info, make_model
  from caffe2.python.onnx.helper import c2_native_run_net, c2_native_run_op
  from onnx import mapping
  import caffe2.python.onnx.frontend
  import caffe2.python.onnx.backend
  import numpy
  from caffe2.python.models.download import ModelDownloader
  from caffe2.python.onnx.tests.test_utils import TestCase
  import caffe2.python._import_c_extension
label_desc: Use image node_id 11 for calling the TestCaffe2Basic obj's underlying member method code with example usage: obj.test_gemm() without return types