class_docstr: Test Quantized Conv2d Intrin class
docstr: Test quantized conv2d intrinsic implementation
code: def test_conv2d_quant(
      self, act_shape, wgt_shape, inp_stride, hexagon_session
  ):
      """Test quantized conv2d intrinsic implementation"""
      assert act_shape[3] == wgt_shape[2]
  
      # Currently, input offset does not affect the output shape
      def get_out_shape(ash, wsh, inp_stride):
          assert ash[3] == wsh[2]
          osh = (
              ash[0],
              (ash[1] - wsh[0]) // inp_stride[0] + 1,
              (ash[2] - wsh[1]) // inp_stride[1] + 1,
              wsh[3],
          )
          assert tvm.tir.all([x > 0 for x in osh])
          return osh
  
      act_f = np.random.uniform(-1.5, 1.0, size=act_shape).astype(
          "float32"
      )
      wgt_f = np.random.uniform(-1.5, 1.0, size=wgt_shape).astype(
          "float32"
      )
  
      # Quanize activations using onnxruntime
      act_q, act_scale, act_zp = quantize_np(act_f, dtype="uint8")
      act_q = act_q.reshape(act_f.shape)
  
      # Quanize weights using onnxruntime
      wgt_q, wgt_scale, wgt_zp = quantize_np(wgt_f, dtype="int8")
      wgt_q = wgt_q.reshape(wgt_f.shape)
  
      # Generate reference output
      ref_out = conv2d_nhwc_python(
          act_f, wgt_f, stride=inp_stride, padding="VALID"
      )
  
      ref_out_q, out_scale, out_zp = quantize_np(ref_out, dtype="uint8")
      ref_out_q = ref_out_q.reshape(ref_out.shape)
  
      final_scale = act_scale * wgt_scale / out_scale
      fixed_final_scale, scale_factor = get_fixed_point_value(
          final_scale
      )
  
      module = build_conv2d(get_hexagon_target("v69"))
      mod = hexagon_session.load_module(module)
  
      output_shape = get_out_shape(act_shape, wgt_shape, inp_stride)
  
      output = tvm.nd.array(
          np.zeros(output_shape, dtype="uint8"),
          device=hexagon_session.device,
      )
      mod(
          tvm.nd.array(act_q, device=hexagon_session.device),
          tvm.nd.array(wgt_q, device=hexagon_session.device),
          act_scale,
          act_zp,
          wgt_scale,
          wgt_zp,
          out_scale,
          out_zp,
          inp_stride[0],  # stride_height
          inp_stride[1],  # stride_width
          fixed_final_scale,
          scale_factor,
          output,
      )
  
      out_q = output.numpy()
  
      tvm.testing.assert_allclose(out_q, ref_out_q, rtol=0, atol=2)
  
file_path: tvm/tests/python/contrib/test_hexagon/topi/test_conv2d_quant_intrin.py
imports: import numpy
  import tvm
  import tvm.contrib.hexagon
  from tvm.topi.hexagon.utils import get_fixed_point_value
  from tvm.topi.testing import conv2d_nhwc_python
  from ..infrastructure import get_hexagon_target, quantize_np
label_desc: Use image node_id 1 for calling the TestQuantConv2dIntrin obj's underlying member method code with example usage: obj.test_conv2d_quant(act_shape, wgt_shape, inp_stride, hexagon_session) and returns: osh