code: def alter_conv2d_layout(attrs, inputs, _tinfos, _out_type):
      """Adjust a qnn.conv2d and preceeding ops to better fit on Cortex-M."""
      current_target = target.Target.current(allow_none=False)
      if not "cortex-m" in current_target.mcpu:
          return None
  
      # Always cast to int16 and pick a our desired kernel layout - this won't affect anything
      data_expr, kernel_expr = inputs[:2]
      is_depthwise = attrs.groups > 1
      new_kernel_layout = "IOHW" if is_depthwise else "OHWI"
  
      op = relay.qnn.op.conv2d(
          relay.cast(data_expr, dtype="int16"),
          relay.cast(kernel_expr, dtype="int16"),
          *inputs[2:],
          **edit_attrs(
              attrs, kernel_layout=new_kernel_layout, out_layout="NHWC"
          ),
      )
  
      # If possible, modify depthwise ops to take as input NCHW instead.
      if is_depthwise and prev_ops_match(
          op.args[0], ("cast", "qnn.requantize", "add", "qnn.conv2d")
      ):
          op = _alter_depthwise_conv2d_layout(op)
  
      return op
  
file_path: tvm/python/tvm/topi/arm_cpu/qnn_alter_op.py
imports: from typing import Iterable
  import numpy
  from tvm import nd, relay, target
  from ..utils import get_const_tuple
  from ..nn import qnn_conv2d_alter_layout, add_alter_layout, qnn_requantize_alter_layout
label_desc: Use image node_id 6 for calling a global function with example usage: alter_conv2d_layout(attrs, inputs, _tinfos, _out_type) and returns: op, None