class_docstr: QNN Quantize test class.
docstr: Test qnn.quantize
docstr_tok: ["Test","qnn.quantize"]
code: def test_qnn_quantize(
      self, hexagon_session: Session, odtype, input_shape
  ):
      """Test qnn.quantize"""
  
      def gen_relay_expr_qnn(output_scale, output_zero_point):
          data = relay.var("data", shape=input_shape, dtype="float32")
          qnn_quantize = relay.qnn.quantize(
              data,
              output_scale=relay.const(output_scale),
              output_zero_point=relay.const(output_zero_point),
              axis=-1,
              out_dtype=odtype,
          )
          return qnn_quantize
  
      inputs = {"data": np.random.random(input_shape)}
      # Use quantize_np to obtain reasonable quantization parameters.
      ref_out, scale, zero_point = quantize_np(inputs["data"], odtype)
  
      relay_mod = tvm.IRModule.from_expr(
          gen_relay_expr_qnn(scale, zero_point)
      )
  
      hexagon_mod = build_hexagon_module(relay_mod)
      hexagon_outs = execute_on_hexagon(
          hexagon_session, hexagon_mod, inputs
      )
      assert_allclose(hexagon_outs, [ref_out], atol=1)
  
imports: import numpy
  import tvm.testing
  import tvm.topi.testing
  from tvm import relay
  from tvm.contrib.hexagon.session import Session
  from tvm.contrib.hexagon.pytest_plugin import HEXAGON_AOT_LLVM_TARGET
  from tvm.relay.backend import Executor
  from tvm.relay.testing import run_opt_pass, run_infer_type
  from .infrastructure import quantize_np
label_desc: Use image node_id 1 for calling the TestQnnQuantize obj's underlying member method code with example usage: obj.test_qnn_quantize(hexagon_session, odtype, input_shape) and returns: qnn_quantize