class_docstr: Provides the test_conv2d test function, to be used by other test classes.
  
  Test parameter sets are split out into different classes for
  readability (e.g. used for mobilenet), and for restrictions
  (e.g. implemented only for llvm).
class_docstr_tok: ["Provides","the","test_conv2d","test","function",",","to","be","used","by","other","test","classes",".","Test","parameter","sets","are","split","out","into","different","classes","for","readability","(","e.g",".","used","for","mobilenet",")",",","and","for","restrictions","(","e.g",".","implemented","only","for","llvm",")","."]
docstr: Generate reference data.
docstr_tok: ["Generate","reference","data","."]
code: def ref_data(
      self,
      random_seed,
      in_dtype,
      out_dtype,
      layout,
      input_shape,
      filter_shape,
      dilation,
      stride,
      padding,
      scale_shape,
      shift_shape,
      use_scale_shift,
      apply_relu,
  ):
      """Generate reference data."""
      np.random.seed(random_seed)
  
      # scipy.signal.convolve2d does not support float16 data types, and
      # the python fallback is too slow for general use.  Computing
      # ref_data in float32 will have fewer rounding errors than the TVM
      # float16 compute, but those vary based on schedule anyways.
      conv_dtype = "float32" if in_dtype == "float16" else in_dtype
  
      input_np = np.random.uniform(size=input_shape).astype(in_dtype)
      filter_np = np.random.uniform(size=filter_shape).astype(in_dtype)
      scale_np = np.random.uniform(size=scale_shape).astype(out_dtype)
      shift_np = np.random.uniform(size=shift_shape).astype(out_dtype)
      if layout == "NCHW":
          np_depthwise_conv2d = (
              tvm.topi.testing.depthwise_conv2d_python_nchw
          )
          dilation = (1, 1, dilation, dilation)
          reshape = (1, -1, 1, 1)
      elif layout == "NHWC":
          np_depthwise_conv2d = (
              tvm.topi.testing.depthwise_conv2d_python_nhwc
          )
          dilation = (dilation, dilation, 1, 1)
          reshape = (1, 1, 1, -1)
      elif layout == "NCHWc":
          np_depthwise_conv2d = (
              tvm.topi.testing.depthwise_conv2d_python_nchwc
          )
          dilation = (1, 1, dilation, dilation, 1, 1)
          reshape = (1, scale_shape[0], 1, 1, scale_shape[1])
  
      dilated_filter_np = tvm.topi.testing.dilate_python(
          filter_np, dilation
      )
      output_np = np_depthwise_conv2d(
          input_np.astype(conv_dtype),
          dilated_filter_np.astype(conv_dtype),
          stride,
          padding,
      ).astype(out_dtype)
  
      if use_scale_shift:
          output_np = output_np * scale_np.reshape(
              reshape
          ) + shift_np.reshape(reshape)
      if apply_relu:
          output_np = np.maximum(output_np, 0)
  
      return (
          input_np,
          filter_np,
          scale_np,
          shift_np,
          output_np,
      )
  
file_path: tvm/tests/python/contrib/test_hexagon/topi/test_depthwise_conv2d.py
imports: import numpy
  import tvm
  from tvm.contrib.hexagon.session import Session
  import tvm.testing
  import tvm.topi.testing
  from tvm import te, topi
  from tvm.topi.utils import get_const_tuple
  from tvm.topi.nn.utils import get_pad_tuple
  from ..infrastructure import get_hexagon_target
label_desc: Use image node_id 5 for calling the BaseDepthwiseConv2D obj's underlying member method code with example usage: obj.ref_data(random_seed, in_dtype, out_dtype, layout, input_shape, filter_shape, dilation, stride, padding, scale_shape, shift_shape, use_scale_shift, apply_relu) and returns: input_np,  filter_np,  scale_np,  shift_np,  output_np