code: def test_reshape_nop():
      # test that reshape can be turned into nop
      x = relay.var("x", shape=(10, 4))
      xx = relay.abs(x)
      y = relay.expand_dims(xx, axis=1)
      t0 = relay.reshape(y, (1, 40))
      t1 = relay.abs(y)
  
      z0 = relay.reshape(t0, (2, 20))
      z1 = relay.sqrt(t1)
      z2 = relay.reshape(t1, (1, 40))
  
      func = relay.Function([x], relay.Tuple([z0, z1, z2]))
      x_data = np.random.rand(10, 4).astype("float32")
      graph = relay.build(tvm.IRModule.from_expr(func), "llvm")
      graph_json_str = graph.get_graph_json()
  
      graph_json = json.loads(graph_json_str)
  
      # reshape must force sharing memory
      storage_ids = graph_json["attrs"]["storage_id"][1]
      assert tuple(storage_ids) == (0, 1, 1, 2, 3, 2)
      assert graph_json["nodes"][2]["attrs"]["func_name"] == "__nop"
      assert graph_json["nodes"][5]["attrs"]["func_name"] == "__nop"
  
      gmod = graph_executor.GraphModule(graph["default"](tvm.cpu(0)))
  
      gmod.set_input(x=x_data)
      gmod.run()
      z0_np = x_data.reshape(2, 20)
      z1_np = np.sqrt(
          np.abs(
              x_data.reshape(
                  10,
                  1,
                  4,
              )
          )
      )
      z2_np = np.abs(x_data).reshape(1, 40)
      tvm.testing.assert_allclose(gmod.get_output(0).numpy(), z0_np)
      tvm.testing.assert_allclose(gmod.get_output(1).numpy(), z1_np)
      tvm.testing.assert_allclose(gmod.get_output(2).numpy(), z2_np)
  
imports: import numpy
  import pytest
  from unittest.mock import patch
  import tvm
  import json
  from tvm import relay
  from tvm.contrib import graph_executor
  from tvm.relay.op import add
  import tvm.testing
  from tvm.relay.testing import mlp
  from tvm import rpc
  from tvm.contrib import utils
label_desc: Use image node_id 9 for calling a global function with example usage: test_reshape_nop() without return types