Skip to content

Commit

Permalink
Add warning on arch mismatches.
Browse files Browse the repository at this point in the history
  • Loading branch information
riga committed Mar 28, 2024
1 parent a9ee8f7 commit a03ccef
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cms_tfaot/scripts/tfaot_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from __future__ import annotations

import os
import re
import shutil
import platform
import collections
from typing import Any

Expand Down Expand Up @@ -187,6 +189,23 @@ def main() -> int:
)
args = parser.parse_args()

# check if the platform arch matches the "--target_triple" value in additional_flags
if args.dev:
m = re.match(r"^.*--target_triple(\s+|=)([^-]+)-.+$", args.additional_flags or "")
triple_arch = m.group(2) if m else "x86_64"
arch = platform.processor()
if triple_arch != arch:
msg = f"\nWARNING: your platform architecture is '{arch}'"
if m:
msg += f" which does not match the configured '--target_triple' of '{triple_arch}'"
else:
msg += " but the default compilation target is 'x86_64'"
msg += (
", which can lead to unexpected behavior in the compiled model, so please set the"
" correct target via --additional-flags=\"--target_triple=<arch>-unknown-linux\"\n"
)
print(msg)

tfaot_compile(
config_file=args.aot_config,
output_dir=args.output_directory,
Expand Down

0 comments on commit a03ccef

Please sign in to comment.