code: def test_dense_slice(
      self,
      dtype,
      bias_np,
      layout,
      output_shape,
      input_shape,
      input_np,
      input_quant,
      transformed_input_np,
      transformed_input_quant,
      weight_np,
      # transformed_weight_np,
      weight_quant,
      # transformed_weight_quant,
      transformed_expected_output_np,
      expected_output_np,
      quant_arr,
      hexagon_session: Session,
  ):
      target_hexagon = tvm.target.hexagon("v69")
      A = te.placeholder(input_shape, name="A", dtype=dtype)
      W = te.placeholder(
          (output_shape[-1], input_shape[-1]),
          name="W",
          dtype="int8" if dtype == "uint8" else dtype,
      )
      args = [A, W]
      tensors = [A, W]
  
      # If quantized, append the quantization params
      if "int" in dtype:
          args.append(quant_arr[0].astype("int32"))
          args.append(quant_arr[1])
          args.append(quant_arr[2].astype("int32"))
          args.append(quant_arr[3])
  
      if bias_np is not None:
          B = te.placeholder(
              (output_shape[-1],), name="B", dtype=str(bias_np.dtype)
          )
          args.append(B)
          tensors.append(B)
      else:
          B = None
  
      # Different compute and schedule for quant and float
      if "float" in dtype:
          M = sl.dense_compute(*args)
          tir_schedule = sl.dense_schedule([M], tensors, layout, layout)
      elif "int" in dtype:
          M = qnn.qdense_compute(*args, bias=B)
          tir_schedule = qnn.qdense_schedule(
              [M], tensors, layout, layout
          )
      else:
          print("Unsupported dtype {}".format(dtype))
          exit(-1)
  
      sch = tir_schedule.mod
  
      input_axis_separator = [2]
      output_axis_separator = [2]
  
      with tvm.transform.PassContext(opt_level=3):
          func = tvm.build(
              sch,
              args,
              target=tvm.target.Target(
                  target_hexagon, host=target_hexagon
              ),
              name="dense",
          )
          func.save("dense.s" if bias_np is None else "dense_bias.s")
  
      input_arr = allocate_hexagon_array(
          hexagon_session.device,
          data=transformed_input_np
          if "float" in dtype
          else transformed_input_quant["data"],
          axis_separators=input_axis_separator,
          mem_scope="global.vtcm",
      )
      weight_arr = allocate_hexagon_array(
          hexagon_session.device,
          data=weight_np if "float" in dtype else weight_quant["data"],
          axis_separators=None,
          mem_scope="global",
      )
      output_arr = allocate_hexagon_array(
          hexagon_session.device,
          transformed_expected_output_np.shape,
          "float32" if "int" in dtype else dtype,
          axis_separators=output_axis_separator,
          mem_scope="global.vtcm",
      )
      arrs = [input_arr, weight_arr]
  
      if bias_np is not None:
          bias_arr = allocate_hexagon_array(
              hexagon_session.device,
              data=bias_np,
              axis_separators=None,
              mem_scope="global.vtcm",
          )
          arrs.append(bias_arr)
  
      arrs.append(output_arr)
  
      mod = hexagon_session.load_module(func)
      mod(*arrs)
  
      # Reshape for comparison
      b, c = output_shape
      if layout == "nc-1024c-2d":
          output_np = output_arr.numpy().reshape([b, c // 1024, 1024])
      elif layout == "nc-2048c-2d":
          output_np = output_arr.numpy().reshape([b, c // 2048, 2048])
      else:
          raise RuntimeError(f"Unexpected layout '{layout}'")
  
      if "int" in dtype:
          np.testing.assert_allclose(
              output_np,
              transformed_expected_output_np,
              rtol=1e-2,
              atol=0,
          )
      elif "float" in dtype:
          np.testing.assert_allclose(
              output_np,
              transformed_expected_output_np,
              rtol=1e-1,
              atol=0,
          )
  
imports: import pytest
  import numpy
  from tvm import te, topi
  import tvm.testing
  from tvm.topi import testing
  from tvm.contrib.hexagon.build import HexagonLauncher
  from tvm.contrib.hexagon.session import Session
  import tvm.topi.hexagon.qnn
  import tvm.topi.hexagon.slice_ops
  from ...infrastructure import transform_numpy, quantize_np
  from tvm.contrib.hexagon import allocate_hexagon_array
label_desc: Use image node_id 4 for calling the TestDenseSlice obj's underlying member method code with example usage: obj.test_dense_slice(dtype, bias_np, layout, output_shape, input_shape, input_np, input_quant, transformed_input_np, transformed_input_quant, weight_np, weight_quant, transformed_expected_output_np, expected_output_np, quant_arr, hexagon_session) without return types