From 4a00b233bc115a0e37c5a8667c690b50d96d5f7d Mon Sep 17 00:00:00 2001 From: Siva Date: Tue, 19 Sep 2023 13:50:54 +0530 Subject: [PATCH 1/2] [TVMC] enable dumping imported modules too Now we can dump the imported modules source too like device code. --- python/tvm/driver/tvmc/compiler.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/python/tvm/driver/tvmc/compiler.py b/python/tvm/driver/tvmc/compiler.py index 349613647032..97f0016beb42 100644 --- a/python/tvm/driver/tvmc/compiler.py +++ b/python/tvm/driver/tvmc/compiler.py @@ -445,6 +445,9 @@ def compile_model( # TODO lib.get_source call have inconsistent behavior for unsupported # formats (@leandron). dumps[source_type] = lib.get_source(source_type) + for smod in lib.imported_modules: + dumps[smod.type_key] = smod.get_source() + # Create a new tvmc model package object from the graph definition. package_path = tvmc_model.export_package( From 0ddeea1ca9436156ea97fe7b382d8f4d9edabdbb Mon Sep 17 00:00:00 2001 From: Siva Date: Mon, 25 Sep 2023 13:48:07 +0530 Subject: [PATCH 2/2] * review comments and test case --- python/tvm/driver/tvmc/compiler.py | 1 - tests/python/driver/tvmc/test_compiler.py | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/python/tvm/driver/tvmc/compiler.py b/python/tvm/driver/tvmc/compiler.py index 97f0016beb42..42736741803e 100644 --- a/python/tvm/driver/tvmc/compiler.py +++ b/python/tvm/driver/tvmc/compiler.py @@ -448,7 +448,6 @@ def compile_model( for smod in lib.imported_modules: dumps[smod.type_key] = smod.get_source() - # Create a new tvmc model package object from the graph definition. package_path = tvmc_model.export_package( graph_module, package_path, cross, cross_options, output_format diff --git a/tests/python/driver/tvmc/test_compiler.py b/tests/python/driver/tvmc/test_compiler.py index 616509955889..ca56172cb702 100644 --- a/tests/python/driver/tvmc/test_compiler.py +++ b/tests/python/driver/tvmc/test_compiler.py @@ -798,6 +798,7 @@ def test_compile_opencl(tflite_mobilenet_v1_0_25_128): assert type(tvmc_package.lib_path) is str assert type(tvmc_package.params) is bytearray assert os.path.exists(dumps_path) + assert path.exists("{}.{}".format(tvmc_package.package_path, "opencl")) @tvm.testing.requires_cmsisnn