Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[µTVM] Remove need for -mcpu=native #7276

Merged
merged 1 commit into from
Jan 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions python/tvm/micro/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ def _target_from_sources(cls, sources):
}

def _autodetect_toolchain_prefix(self, target):
# Treat absence of -mcpu as if -mcpu=native is specified. The gcc shipped with OS X
# complains if -mcpu=native is given, so this approach allows model targets to avoid
# specifying this flag e.g. for tutorials.
if "mcpu" not in target.attrs:
return self.TOOLCHAIN_PREFIX_BY_CPU_REGEX["native"]

matches = []
for regex, prefix in self.TOOLCHAIN_PREFIX_BY_CPU_REGEX.items():
if re.match(regex, target.attrs["mcpu"]):
Expand Down
2 changes: 1 addition & 1 deletion python/tvm/target/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def micro(model="unknown", options=None):
Additional options
"""
trans_table = {
"host": ["-mcpu=native"],
"host": [],
"stm32f746xx": ["-mcpu=cortex-m7", "-march=armv7e-m"],
}
opts = _merge_opts(
Expand Down
2 changes: 1 addition & 1 deletion tests/python/unittest/test_link_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def test_crt_link_params():
mod, param_init = _make_mod_and_params(dtype)
rand_input = _make_random_tensor(dtype, INPUT_SHAPE)
main_func = mod["main"]
target = "c -mcpu=native --system-lib --runtime=c --link-params"
target = "c --system-lib --runtime=c --link-params"
with tvm.transform.PassContext(opt_level=3, config={"tir.disable_vectorize": True}):
graph_json, lib, params = tvm.relay.build(mod, target, params=param_init)
assert set(params.keys()) == {"p0", "p1"} # NOTE: op folded
Expand Down