class_docstr: Conv2D transpose base class.
class_docstr_tok: ["Conv2D","transpose","base","class","."]
docstr: Test conv2D.
docstr_tok: ["Test","conv2D","."]
code: def test_conv2d(
      self,
      hexagon_session: Session,
      batch,
      in_channel,
      in_size,
      num_filter,
      stride,
      padding,
      output_padding,
      random_seed,
  ):
      """Test conv2D."""
      in_height, in_width = in_size
      kernel_height, kernel_width = (1, 1)
      stride_height, stride_width = stride
      pad_top, pad_left, pad_bottom, pad_right = padding
  
      a_tensor = te.placeholder(
          (batch, in_channel, in_height, in_width), name="a_tensor"
      )
      w_tensor = te.placeholder(
          (in_channel, num_filter, kernel_height, kernel_width),
          name="w_tensor",
      )
  
      a_shape = get_const_tuple(a_tensor.shape)
      w_shape = get_const_tuple(w_tensor.shape)
      dtype = a_tensor.dtype
  
      def get_ref_data():
          np.random.seed(random_seed)
          a_np = np.random.uniform(size=a_shape).astype(dtype)
          w_np = np.random.uniform(size=w_shape).astype(dtype)
          b_np = tvm.topi.testing.conv2d_transpose_nchw_python(
              a_np, w_np, stride, padding, output_padding
          )
          c_np = np.maximum(b_np, 0)
          return a_np, w_np, b_np, c_np
  
      a_np, w_np, b_np, c_np = get_ref_data()
  
      fcompute_args = (
          a_tensor,
          w_tensor,
          [stride_height, stride_width],
          [pad_top, pad_left, pad_bottom, pad_right],
          a_tensor.dtype,
          output_padding,
      )
  
      with tvm.target.Target(get_hexagon_target("v68")):
          fcompute = topi.nn.conv2d_transpose_nchw
          fschedule = topi.hexagon.schedule_conv2d_transpose_nchw
          b_tensor = fcompute(*fcompute_args)
          c_tensor = topi.nn.relu(b_tensor)
          schedule_1 = fschedule([b_tensor])
          schedule_2 = fschedule([c_tensor])
  
          dev = hexagon_session.device
  
          a_data = tvm.nd.array(a_np, dev)
          weight = tvm.nd.array(w_np, dev)
          b = tvm.nd.array(
              np.zeros(
                  get_const_tuple(b_tensor.shape), dtype=b_tensor.dtype
              ),
              dev,
          )
          c = tvm.nd.array(
              np.zeros(
                  get_const_tuple(c_tensor.shape), dtype=c_tensor.dtype
              ),
              dev,
          )
  
          func1 = tvm.build(
              schedule_1,
              [a_tensor, w_tensor, b_tensor],
              get_hexagon_target("v68"),
          )
          func2 = tvm.build(
              schedule_2,
              [a_tensor, w_tensor, c_tensor],
              get_hexagon_target("v68"),
          )
  
          mod1 = hexagon_session.load_module(func1)
          mod2 = hexagon_session.load_module(func2)
  
          mod1(a_data, weight, b)
          mod2(a_data, weight, c)
          tvm.testing.assert_allclose(b.numpy(), b_np, rtol=1e-5)
          tvm.testing.assert_allclose(c.numpy(), c_np, rtol=1e-5)
  
file_path: tvm/tests/python/contrib/test_hexagon/topi/test_conv2d_transpose.py
imports: import numpy
  import tvm
  from tvm.contrib.hexagon.session import Session
  import tvm.testing
  from tvm import te
  from tvm import topi
  import tvm.topi.testing
  from tvm.topi.utils import get_const_tuple
  from ..infrastructure import get_hexagon_target
label_desc: Use image node_id 1 for calling the BaseConv2DTransposeTests obj's underlying member method code with example usage: obj.test_conv2d(hexagon_session, batch, in_channel, in_size, num_filter, stride, padding, output_padding, random_seed) and returns: a_np,  w_np,  b_np,  c_np