code: def test_serializer():
      mod = tvm.IRModule({})
      a = relay.const(1.0, "float32")
      x = relay.var("x", shape=(10, 10), dtype="float32")
      f1 = relay.Function([x], x + a)
      glb_f1 = relay.GlobalVar("f1")
      mod[glb_f1] = f1
  
      # TODO(@jroesch): look into optimizing away the need to do this
      mod = transform.InferType()(mod)
  
      b = relay.const(2.0, "float32")
      y = relay.var("y", shape=(10, 10), dtype="float32")
      f2 = relay.Function([y], y - b)
      glb_f2 = relay.GlobalVar("f2")
      mod[glb_f2] = f2
  
      # TODO(@jroesch): look into optimizing away the need to do this
      mod = transform.InferType()(mod)
  
      x1 = relay.var("x1", shape=(10, 10), dtype="float32")
      y1 = relay.var("y1", shape=(10, 10), dtype="float32")
      main = relay.Function([x1, y1], glb_f1(x1) * glb_f2(y1))
      mod["main"] = main
  
      exe = create_exec(mod)
  
      glbs = exe.globals
      assert len(glbs) == 3
      assert "f1" in glbs
      assert "f2" in glbs
      assert "main" in glbs
  
      prim_ops = exe.primitive_ops
      assert any(
          item.startswith("vm_mod_fused_add") for item in prim_ops
      )
      assert any(
          item.startswith("vm_mod_fused_subtract") for item in prim_ops
      )
      assert any(
          item.startswith("vm_mod_fused_multiply") for item in prim_ops
      )
  
      code = exe.bytecode
      assert "main(x1, y1)" in code
      assert "f1(x)" in code
      assert "f2(y)" in code
  
      code, lib = exe.save()
      assert isinstance(code, bytearray)
      assert isinstance(lib, tvm.runtime.Module)
  
imports: import pytest
  import numpy
  import tvm
  from tvm.runtime import vm
  from tvm.relay import vm
  from tvm import relay
  from tvm.relay.scope_builder import ScopeBuilder
  from tvm.relay import transform
  from tvm.relay.prelude import Prelude
  from tvm.contrib import utils
  from tvm.relay import testing
label_desc: Use image node_id 4 for calling a global function with example usage: test_serializer() without return types