class_docstr: Currently we only use it to infer caffe shape, we use tensorflow engine
  to infer tensorflow op shapes, since tensorflow has too many ops.
class_docstr_tok: ["Currently","we","only","use","it","to","infer","caffe","shape",",","we","use","tensorflow","engine","to","infer","tensorflow","op","shapes",",","since","tensorflow","has","too","many","ops","."]
code: def infer_shape_matmul(self, op):
      input_shape = self._output_shape_cache[op.input[0]]
      num_axes = len(input_shape)
      tranpose_a = ConverterUtil.get_arg(
          op, MaceKeyword.mace_transpose_a_str
      ).i
      tranpose_b = ConverterUtil.get_arg(
          op, MaceKeyword.mace_transpose_b_str
      ).i
      if tranpose_a:
          M = self._output_shape_cache[op.input[0]][num_axes - 1]
      else:
          M = self._output_shape_cache[op.input[0]][num_axes - 2]
      if tranpose_b:
          N = self._output_shape_cache[op.input[1]][num_axes - 2]
      else:
          N = self._output_shape_cache[op.input[1]][num_axes - 1]
      output_shape = input_shape
      output_shape[num_axes - 2] = M
      output_shape[num_axes - 1] = N
      self.add_output_shape(op, [output_shape])
  
imports: import math
  import numpy
  import six
  from transform.transformer import Transformer
  from transform.base_converter import DataFormat
  from transform.base_converter import MaceOp
  from transform.base_converter import MaceKeyword
  from transform.base_converter import ConverterUtil
  from utils.util import mace_check
label_desc: Use image node_id 21 for calling the ShapeInference obj's underlying member method code with example usage: obj.infer_shape_matmul(op) without return types