Skip to content

Commit

Permalink
fix mcpu on os x (apache#7276)
Browse files Browse the repository at this point in the history
  • Loading branch information
areusch authored and trevor-m committed Jan 21, 2021
1 parent 0893063 commit 346a79a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
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

0 comments on commit 346a79a

Please sign in to comment.