areusch commented on a change in pull request #10645:
URL: https://github.com/apache/tvm/pull/10645#discussion_r828538939
##########
File path: tests/python/relay/aot/test_crt_aot.py
##########
@@ -162,6 +168,69 @@ def test_conv2d(interface_api, use_unpacked_api,
test_runner, groups, weight_sha
)
+def test_packed_global_variables():
+ """Check packed global variables in codegen output."""
+ dtype = "float32"
+ ishape = (1, 32, 14, 14)
+ wshape = (32, 32, 3, 3)
+ interface_api = "packed"
+ use_unpacked_api = False
+
+ data0 = relay.var("data", shape=ishape, dtype=dtype)
+ weight0 = relay.var("weight", shape=wshape, dtype=dtype)
+ out = relay.nn.conv2d(data0, weight0, kernel_size=(3, 3), padding=(1, 1),
groups=1)
+ main_f = relay.Function([data0, weight0], out)
+ mod = tvm.IRModule()
+ mod["main"] = main_f
+ mod = transform.InferType()(mod)
+
+ i_data = np.random.uniform(0, 1, ishape).astype(dtype)
+ w1_data = np.random.uniform(0, 1, wshape).astype(dtype)
+
+ inputs = OrderedDict([("data", i_data), ("weight", w1_data)])
+
+ output_list = generate_ref_data(mod, inputs)
+ compiled_models_list = compile_models(
+ models=AOTTestModel(module=mod, inputs=inputs, outputs=output_list),
+ interface_api=interface_api,
+ use_unpacked_api=use_unpacked_api,
+ workspace_byte_alignment=8,
+ enable_op_fusion=True,
+ pass_config=AOT_DEFAULT_RUNNER.pass_config,
+ use_runtime_executor=True,
+ target=tvm.target.Target("c"),
+ )
+ compiled_model = compiled_models_list[0]
+
+ tmp_path = utils.tempdir()
+ base_path = tmp_path.temp_dir
+
+ model = compiled_model.model
+ tar_file = os.path.join(base_path, f"{model.name}.tar")
+ export_model_library_format(compiled_model.executor_factory, tar_file)
+ t = tarfile.open(tar_file)
+ t.extractall(base_path)
+
+ with open(
+ pathlib.Path(base_path) / "codegen" / "host" / "src" /
f"{model.name}_lib1.c", "r"
+ ) as lib1_f:
+ lib1 = lib1_f.readlines()
+
+ tvmgen_names = []
+ tvmgen_funcs = []
+ for line in lib1:
+ for item in line.split(" "):
+ if item.startswith("tvmgen_default"):
Review comment:
could you include a comment describing the form of the line you're
expecting to match?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]