Skip to content

Commit

Permalink
rebasing
Browse files Browse the repository at this point in the history
Change-Id: I25e43d426f650e7ed9faa08023a4b59598c502b3
  • Loading branch information
Giuseppe Rossini committed May 18, 2021
1 parent 852511a commit 18fadc8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
27 changes: 18 additions & 9 deletions tests/python/relay/aot/aot_test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,13 @@ def extract_main_workspace_sizebytes(extract_dir):


def compile_and_run(
mod, input_list, output_list, use_calculated_workspaces, params=None, workspace_byte_alignment=8, mod_name=None
mod,
input_list,
output_list,
use_calculated_workspaces,
params=None,
workspace_byte_alignment=8,
mod_name=None,
):
"""
This method verifies the generated source
Expand All @@ -231,6 +237,7 @@ def compile_and_run(

tmp_path = utils.tempdir()
tmp_dir = tmp_path.temp_dir
tmp_dir = "."

base_path = os.path.join(tmp_dir, "test")
build_path = os.path.join(base_path, "build")
Expand Down Expand Up @@ -258,12 +265,18 @@ def compile_and_run(
(f'{mangle_name(mod_name, "expected_output_data")}{i}'), output_list[i], build_path
)

create_main("test.c", {mod_name: input_list}, {mod_name: output_list}, build_path, workspace_bytes)
create_main(
"test.c", {mod_name: input_list}, {mod_name: output_list}, build_path, workspace_bytes
)

# Verify that compiles fine
file_dir = os.path.dirname(os.path.abspath(__file__))
makefile = os.path.join(file_dir, "aot_test.mk")
make_cmd = f"make -f {makefile} build_dir=" + build_path + f" TVM_ROOT={file_dir}/../../../.."
make_cmd = (
f"make CFLAGS='{cflags}' -f {makefile} build_dir="
+ build_path
+ f" TVM_ROOT={file_dir}/../../../.."
)

compile_log_path = os.path.join(build_path, "test_compile.log")
ret = subprocess_with_stdout_and_log(make_cmd, ".", compile_log_path, False)
Expand Down Expand Up @@ -317,16 +330,12 @@ def compile_and_run_multiple_models(mod_map, input_list_map, output_list_map, pa
(f'{mangle_name(mod_name,"expected_output_data")}{i}'), output_list[i], build_path
)

create_main("test.c", input_list_map, output_list_map, build_path)
create_main("test.c", input_list_map, output_list_map, build_path, workspace_bytes=16384 * 1024)

# Verify that compiles fine
file_dir = os.path.dirname(os.path.abspath(__file__))
makefile = os.path.join(file_dir, "aot_test.mk")
make_cmd = (
f"make CFLAGS='{cflags}' -f {makefile} build_dir="
+ build_path
+ f" TVM_ROOT={file_dir}/../../../.."
)
make_cmd = f"make -f {makefile} build_dir=" + build_path + f" TVM_ROOT={file_dir}/../../../.."

compile_log_path = os.path.join(build_path, "test_compile.log")
ret = subprocess_with_stdout_and_log(make_cmd, ".", compile_log_path, False)
Expand Down
10 changes: 9 additions & 1 deletion tests/python/relay/aot/test_crt_aot.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,14 @@ def test_add_name_mangling_with_params():
output_list = generate_ref_data(func, inputs, params)

input_list = [y_in]
compile_and_run(func, input_list, output_list, params, "my_mod")
compile_and_run(
func,
input_list,
output_list,
use_calculated_workspaces=False,
params=params,
mod_name="my_mod",
)


def test_multiple_models():
Expand Down Expand Up @@ -429,5 +436,6 @@ def @main(%data : Tensor[(1, 3, 64, 64), uint8], %weight : Tensor[(8, 3, 5, 5),

compile_and_run_multiple_models(mod_map, input_list_map, output_list_map, param_map)


if __name__ == "__main__":
pytest.main([__file__])

0 comments on commit 18fadc8

Please sign in to comment.