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_reshape(self, op):
      if (
          ConverterUtil.get_arg(op, MaceKeyword.mace_dim_str)
          is not None
      ):
          dim = ConverterUtil.get_arg(op, MaceKeyword.mace_dim_str).ints
          output_shape = list(dim)
          product = input_size = 1
          idx = -1
          for i in range(len(self._output_shape_cache[op.input[0]])):
              input_size *= self._output_shape_cache[op.input[0]][i]
          for i in range(len(dim)):
              if dim[i] == 0:
                  output_shape[i] = self._output_shape_cache[
                      op.input[0]
                  ][i]
                  product *= self._output_shape_cache[op.input[0]][i]
              elif dim[i] == -1:
                  idx = i
                  output_shape[i] = 1
              else:
                  output_shape[i] = dim[i]
                  product *= dim[i]
          if idx != -1:
              output_shape[idx] = int(input_size / product)
          self.add_output_shape(op, [output_shape])
      else:
          output_shape = []
          axis = ConverterUtil.get_arg(op, MaceKeyword.mace_axis_str).i
          end_axis = ConverterUtil.get_arg(
              op, MaceKeyword.mace_end_axis_str
          ).i
          end_axis = (
              end_axis
              if end_axis > 0
              else end_axis
              + len(list(self._output_shape_cache[op.input[0]]))
          )
          dim = 1
          for i in range(0, axis):
              output_shape.append(
                  self._output_shape_cache[op.input[0]][i]
              )
          for i in range(axis, end_axis + 1):
              dim *= self._output_shape_cache[op.input[0]][i]
          output_shape.append(-1)
          for i in range(
              end_axis + 1,
              len(list(self._output_shape_cache[op.input[0]])),
          ):
              output_shape.append(
                  self._output_shape_cache[op.input[0]][i]
              )
          output_shape[axis] = dim
          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 15 for calling the ShapeInference obj's underlying member method code with example usage: obj.infer_shape_reshape(op) without return types