areusch commented on code in PR #11191:
URL: https://github.com/apache/tvm/pull/11191#discussion_r862129047
##########
tests/python/relay/aot/test_cpp_aot.py:
##########
@@ -145,6 +145,26 @@ def test_mobilenet(enable_usmp, target_kind):
assert (runner.get_output(0).asnumpy() ==
list(ref_outputs.values())[0]).all()
+def test_module_list():
+ x = tvm.relay.var("x", tvm.relay.TensorType([1], dtype="float32"))
+ expr = tvm.relay.add(x, tvm.relay.Constant(tvm.nd.array(np.array([1],
dtype="float32"))))
+ mod = tvm.relay.build(
+ tvm.IRModule.from_expr(tvm.relay.Function([x], expr)),
+ target="c",
+ executor=tvm.relay.backend.Executor("aot", {"interface-api":
"packed"}),
+ )
+ temp_dir = tvm.contrib.utils.TempDirectory()
+ test_so_path = temp_dir / "test.so"
+ mod.export_library(test_so_path, cc="gcc", options=["-std=c11"])
+ loaded_mod = tvm.runtime.load_module(test_so_path)
+ module_list = loaded_mod.get_function("module_list")
+ # At the moment, relay produces a single module with the name "default".
+ names_expected = ["default"]
+ names_obtained = sorted(module_list())
+ assert len(names_obtained) == len(names_expected)
+ assert all([x == y for (x, y) in zip(names_obtained, names_expected)])
Review Comment:
i think these two could just be
`assert names_expected = list(sorted(module_list())`
and then it'd be easier to debug if it broke
##########
tests/python/relay/aot/test_cpp_aot.py:
##########
@@ -145,6 +145,26 @@ def test_mobilenet(enable_usmp, target_kind):
assert (runner.get_output(0).asnumpy() ==
list(ref_outputs.values())[0]).all()
+def test_module_list():
+ x = tvm.relay.var("x", tvm.relay.TensorType([1], dtype="float32"))
+ expr = tvm.relay.add(x, tvm.relay.Constant(tvm.nd.array(np.array([1],
dtype="float32"))))
+ mod = tvm.relay.build(
Review Comment:
nit: could pass mod_name = 'foo' here and then test that to verify the knob
works
##########
src/runtime/aot_executor/aot_executor_factory.cc:
##########
@@ -52,6 +52,11 @@ PackedFunc AotExecutorFactory::GetFunction(
}
*rv = this->ExecutorCreate(devices);
});
+ } else if (name == "module_list") {
Review Comment:
to follow convention of other functions here, shall we say list_module_names?
--
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]