-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[aot] AOT compat test in workflow (#7033)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: PENGUINLIONG <admin@penguinliong.moe>
- Loading branch information
1 parent
ea0c0c4
commit ea9299c
Showing
3 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Generate AOT modules with Taichi nightly (which is definitely an older version | ||
from this currently building one in development branch) for | ||
`run_c_api_compat_test.py` to consume. | ||
""" | ||
import glob | ||
import os | ||
import pathlib | ||
import subprocess | ||
|
||
curr_dir = os.path.dirname(os.path.abspath(__file__)) | ||
curr_dir = os.path.dirname(curr_dir) | ||
build_dir = os.path.join(curr_dir, 'build') | ||
cpp_test_filename = 'taichi_cpp_tests' | ||
capi_test_filename = 'taichi_c_api_tests' | ||
cpp_tests_path = os.path.join(build_dir, capi_test_filename) | ||
c_api_tests_path = os.path.join(build_dir, cpp_test_filename) | ||
|
||
|
||
def generate(): | ||
aot_files = glob.glob("tests/cpp/aot/python_scripts/*.py") | ||
for x in aot_files: | ||
path_name = pathlib.Path(x).name[:-3] | ||
os.mkdir('tests/cpp/aot/python_scripts/' + path_name) | ||
os.environ[ | ||
"TAICHI_AOT_FOLDER_PATH"] = curr_dir + '/tests/cpp/aot/python_scripts/' + path_name | ||
try: | ||
subprocess.check_call(["python", x, "--arch=vulkan"]) | ||
except subprocess.CalledProcessError: | ||
continue | ||
|
||
|
||
if __name__ == "__main__": | ||
generate() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
""" | ||
Ensure AOT modules compiled by old versions of Taichi is compatible with the | ||
latest Taichi Runtime. | ||
""" | ||
import glob | ||
import json | ||
import os | ||
import pathlib | ||
import subprocess | ||
|
||
curr_dir = os.path.dirname(os.path.abspath(__file__)) | ||
curr_dir = os.path.dirname(curr_dir) | ||
build_dir = os.path.join(curr_dir, 'build') | ||
cpp_test_filename = 'taichi_cpp_tests' | ||
capi_test_filename = 'taichi_c_api_tests' | ||
cpp_tests_path = os.path.join(build_dir, capi_test_filename) | ||
c_api_tests_path = os.path.join(build_dir, cpp_test_filename) | ||
|
||
run_dict = {} | ||
|
||
|
||
def init_dict(run_dict, aot_files): | ||
curr_dir = os.path.dirname(os.path.abspath(__file__)) | ||
test_config_path = os.path.join(curr_dir, 'test_config.json') | ||
with open(test_config_path, 'r') as f: | ||
test_config = json.loads(f.read()) | ||
|
||
assert ("aot_test_cases" in test_config.keys()) | ||
assert ("capi_aot_test_cases" in test_config.keys()) | ||
|
||
for x in aot_files: | ||
path_name = pathlib.Path(x).name[:-3] | ||
run_dict[path_name] = [] | ||
for cpp_test_name, value in test_config["aot_test_cases"].items(): | ||
if value[1] != "--arch=vulkan": | ||
continue | ||
test_command = [] | ||
test_command.append(cpp_tests_path) | ||
test_command.append(f"--gtest_filter={cpp_test_name}") | ||
run_dict[value[0][3][:-3]].append(test_command) | ||
|
||
for cpp_test_name, value in test_config["capi_aot_test_cases"].items(): | ||
if value[1] != "--arch=vulkan": | ||
continue | ||
test_command = [] | ||
test_command.append(cpp_tests_path) | ||
test_command.append(f"--gtest_filter={cpp_test_name}") | ||
run_dict[value[0][3][:-3]].append(test_command) | ||
|
||
|
||
def run(): | ||
aot_files = glob.glob('tests/cpp/aot/python_scripts/*.py') | ||
init_dict(run_dict, aot_files) | ||
print(run_dict) | ||
for x in aot_files: | ||
path_name = pathlib.Path(x).name[:-3] | ||
os.environ[ | ||
"TAICHI_AOT_FOLDER_PATH"] = curr_dir + '/tests/cpp/aot/python_scripts/' + path_name | ||
if len(os.listdir('tests/cpp/aot/python_scripts/' + path_name)) == 0: | ||
continue | ||
for i in run_dict[path_name]: | ||
print(i) | ||
try: | ||
subprocess.check_call(i, env=os.environ.copy(), cwd=build_dir) | ||
except subprocess.SubprocessError: | ||
print(os.environ["TAICHI_AOT_FOLDER_PATH"]) | ||
print(path_name) | ||
print(os.listdir(os.environ["TAICHI_AOT_FOLDER_PATH"])) | ||
continue | ||
except FileNotFoundError: | ||
continue | ||
|
||
|
||
if __name__ == "__main__": | ||
run() |