def METHOD_NAME(ndim, optype, data_formats):
  #TODO: same shape with different format, is this possible?
  if ndim == 1:
    return 0, 0
  if optype == NNDCT_OP.CONV2D:
    if data_formats[optype] == 'HWIO':
      in_idx, out_idx = 2, 3
    elif data_formats[optype] == 'OIHW':
      in_idx, out_idx = 1, 0
    else:
      raise Exception("data format of conv2d kernel {} is not supported".format(
          data_formats[NNDCT_OP.CONV2D]))
  elif optype == NNDCT_OP.DEPTHWISE_CONV2D:
    if data_formats[optype] == 'HWIO':
      in_idx, out_idx = 2, 2
    elif data_formats[optype] == 'OIHW':
      in_idx, out_idx = 1, 1
    else:
      raise Exception(
          "data format of depthwise_conv2d kernel {} is not supported".format(
              data_formats[NNDCT_OP.CONV2D]))
  elif optype in [NNDCT_OP.DENSE, NNDCT_OP.BASIC_LSTM]:
    if data_formats[optype] == 'IO':
      in_idx, out_idx = 0, 1
    elif data_formats[optype] == 'OI':
      in_idx, out_idx = 1, 0
    else:
      raise Exception("data format of 2 dim mat {} is not supported".format(
          data_formats[NNDCT_OP.CONV2D]))
  else:
    raise Exception("unexpected optype: " + str(optype))
  return in_idx, out_idx