code: def test_conv2d():
      in_channel = 3
      out_channel = 64
      filter_h = 3
      filter_w = 3
      pad_h = 1
      pad_w = 1
      stride_h = 1
      stride_w = 1
      dilation_h = 1
      dilation_w = 1
  
      xshape = [1, in_channel, 128, 128]
      wshape = (out_channel, in_channel, filter_h, filter_w)
  
      X = te.placeholder(xshape, name="X")
      W = te.placeholder(wshape, name="W")
      Y = miopen.conv2d_forward(
          X,
          W,
          stride_h,
          stride_w,
          pad_h,
          pad_w,
          dilation_h,
          dilation_w,
          conv_mode=0,
          data_type=1,
      )
  
      yshape = [x.value for x in Y.shape]
      from tvm import topi
  
      s = te.create_schedule(Y.op)
  
      def verify():
          dev = tvm.rocm(0)
          f = tvm.build(s, [X, W, Y], "rocm --host=llvm", name="conv2d")
          x = tvm.nd.array(
              np.random.uniform(-1, 1, xshape).astype(np.float32), dev
          )
          w = tvm.nd.array(
              np.random.uniform(-1, 1, wshape).astype(np.float32), dev
          )
          y = tvm.nd.array(
              np.random.uniform(-1, 1, yshape).astype(np.float32), dev
          )
          f(x, w, y)
  
          Y_ref = topi.nn.conv2d_nchw(
              X,
              W,
              (stride_h, stride_w),
              (pad_h, pad_w),
              (dilation_h, dilation_w),
          )
          s_ref = te.create_schedule(Y_ref.op)
          f_ref = tvm.build(s_ref, [X, W, Y_ref], "rocm --host=llvm")
          y_ref = tvm.nd.array(
              np.random.uniform(-1, 1, yshape).astype(np.float32), dev
          )
          f_ref(x, w, y_ref)
          print(
              "Max abs diff:", np.max(np.abs(y.numpy() - y_ref.numpy()))
          )
          tvm.testing.assert_allclose(
              y.numpy(), y_ref.numpy(), atol=1e-3
          )
  
      verify()
  
file_path: tvm/tests/python/contrib/test_miopen.py
imports: import tvm
  import tvm.testing
  from tvm import te
  from tvm.contrib import miopen
  import numpy
  import pytest
label_desc: Use image node_id 1 for calling a global function with example usage: test_conv2d() without return types