code: def test_get_tensor_halfwords():
      """Tests the _get_tensor_halfwords helper function in tensordot.py.
  
      This function loads the logical indices of the data that will be stored in memory at the tensor
      pointer. See the function docstring for more details.
      """
  
      # fmt: off
      # A simple 3x3 depthwise convolution computing one output and with in_stride = 1. Note that each
      # row is padded with None at the end to make the rows word-aligned.
      assert _get_tensor_halfwords((48, 3, 3), 0, 1, 1) == [
          (0, 0), (0, 1), (0, 2), None,
          (1, 0), (1, 1), (1, 2), None,
          (2, 0), (2, 1), (2, 2), None
      ]
  
      # If the tensor width is odd, padding alternates before/after every row.
      assert _get_tensor_halfwords((49, 3, 3), 0, 1, 1) == [
          (0, 0), (0, 1), (0, 2), None,
          None, (1, 0), (1, 1), (1, 2),
          (2, 0), (2, 1), (2, 2), None
      ]
  
      # If we are computing multiple outputs, more tensor data becomes relevant.
      assert _get_tensor_halfwords((48, 3, 3), 0, 2, 1) == [
          (0, 0), (0, 1), (0, 2), (0, 3),
          (1, 0), (1, 1), (1, 2), (1, 3),
          (2, 0), (2, 1), (2, 2), (2, 3)
      ]
  
      # If offset=1, relevant data starts one halfword after the kernel pointer.
      assert _get_tensor_halfwords((48, 3, 3), 1, 1, 1) == [
          None, (0, 0), (0, 1), (0, 2),
          None, (1, 0), (1, 1), (1, 2),
          None, (2, 0), (2, 1), (2, 2)
      ]
  
      # These adjustments can be (and often are) used together.
      assert _get_tensor_halfwords((49, 3, 3), 1, 2, 2) == [
          None, (0, 0), (0, 1), (0, 2), (0, 3), (0, 4),
          (1, 0), (1, 1), (1, 2), (1, 3), (1, 4), None,
          None, (2, 0), (2, 1), (2, 2), (2, 3), (2, 4)
      ]
  
file_path: tvm/tests/python/topi/test_topi_conv2d_tensordot_opts.py
imports: import textwrap
  from tvm.topi.arm_cpu.mprofile.dsp.micro_kernel.tensordot import _get_tensor_halfwords, _get_kernel_halfwords, tensordot_int16_impl
label_desc: Use image node_id 1 for calling a global function with example usage: test_get_tensor_halfwords() without return types