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

[Bug] The LLVM default host target in Mac m1 is x86_64, can't pass the python test #9648

Open
zhen8838 opened this issue Dec 3, 2021 · 0 comments

Comments

@zhen8838
Copy link

zhen8838 commented Dec 3, 2021

Thanks for participating in the TVM community! We use https://discuss.tvm.ai for any general usage questions and discussions. The issue tracker is used for actionable items such as feature proposals discussion, roadmaps, and bug tracking. You are always welcomed to post on the forum first 😸

Issues that are inactive for a period of time may get closed. We adopt this policy so that we won't lose track of actionable issues that may fall at the bottom of the pile. Feel free to reopen a new one if you feel there is an additional problem that needs attention when an old one gets closed.

Expected behavior

pass the tir pytest

Actual behavior

got the error like target not support

Environment

Mac m1, llvm 12, tvm 0.9 dev.

I find my llvm target-host is x86_64🤣 so maybe can't use llvm::TargetMachine::getTargetTriple for get current arch.

截屏2021-12-03 20 48 51

Steps to reproduce

the python code

def test_nearbyint():
    m = te.var(
        "m",
    )
    A = te.placeholder((m,), name="A")
    A_rounded = te.compute((m,), lambda *i: tvm.tir.nearbyint(A(*i)), name="A")
    s = te.create_schedule(A_rounded.op)
    f = tvm.build(s, [A, A_rounded], tvm.target.Target("llvm -device=arm_cpu -mtriple=arm64-apple-darwin21.1.0"))
    dev = tvm.cpu(0)
    n = 10
    a = tvm.nd.array(np.random.uniform(high=100, size=n).astype(A.dtype), dev)
    a_rounded = tvm.nd.array(np.random.uniform(size=n).astype(A_rounded.dtype), dev)
    f(a, a_rounded)
    # Note that numpys rint rounds to nearest integer with
    # ties to halfway is broken by rounding to even.
    # So that 1.5 and 2.5 will round 2.
    # This is the default rounding mode with libc as well.
    # However one can set a different rounding mode and in that
    # case numpy result might differ.
    tvm.testing.assert_allclose(a_rounded.numpy(), np.rint(a.numpy()))
./tests/python/unittest/test_tir_intrin.py::test_nearbyint Failed: [undefined]tvm._ffi.base.TVMError: Traceback (most recent call last):
  [bt] (8) 9   libffi.dylib                        0x00000001b9608050 ffi_call_SYSV + 80
  [bt] (7) 8   libtvm.dylib                        0x00000002836360b4 TVMModGetFunction + 108
  [bt] (6) 7   libtvm.dylib                        0x00000002836c56a4 tvm::runtime::ModuleNode::GetFunction(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) + 132
  [bt] (5) 6   libtvm.dylib                        0x00000002835c5f44 tvm::codegen::LLVMModuleNode::GetFunction(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, tvm::runtime::ObjectPtr<tvm::runtime::Object> const&) + 1176
  [bt] (4) 5   libtvm.dylib                        0x00000002835c8b64 tvm::codegen::LLVMModuleNode::LazyInitJIT() + 1096
  [bt] (3) 4   libtvm.dylib                        0x0000000280003e08 tvm::runtime::detail::LogFatal::~LogFatal() + 28
  [bt] (2) 3   libtvm.dylib                        0x0000000280005e60 tvm::runtime::detail::LogFatal::~LogFatal() + 40
  [bt] (1) 2   libtvm.dylib                        0x0000000280005ee8 tvm::runtime::detail::LogFatal::Entry::Finalize() + 112
  [bt] (0) 1   libtvm.dylib                        0x00000002836a4f6c tvm::runtime::Backtrace() + 28
  File "/Users/lisa/Documents/tvm/src/target/llvm/llvm_module.cc", line 399
TVMError: Cannot run module, architecture mismatch  module=arm64-apple-darwin21.1.0 system=x86_64-apple-darwin21.1.0
def test_nearbyint():
        m = te.var(
            "m",
        )
        A = te.placeholder((m,), name="A")
        A_rounded = te.compute((m,), lambda *i: tvm.tir.nearbyint(A(*i)), name="A")
        s = te.create_schedule(A_rounded.op)
        f = tvm.build(s, [A, A_rounded], tvm.target.Target("llvm -device=arm_cpu -mtriple=arm64-apple-darwin21.1.0"))
        dev = tvm.cpu(0)
        n = 10
        a = tvm.nd.array(np.random.uniform(high=100, size=n).astype(A.dtype), dev)
        a_rounded = tvm.nd.array(np.random.uniform(size=n).astype(A_rounded.dtype), dev)
>       f(a, a_rounded)

tests/python/unittest/test_tir_intrin.py:42: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
python/tvm/runtime/module.py:178: in __call__
    return self.entry_func(*args)
python/tvm/runtime/module.py:127: in entry_func
    self._entry = self.get_function(self.entry_name)
python/tvm/runtime/module.py:147: in get_function
    check_call(
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

ret = -1

    def check_call(ret):
        """Check the return value of C API call
    
        This function will raise exception when error occurs.
        Wrap every API call with this function
    
        Parameters
        ----------
        ret : int
            return value from API calls
        """
        if ret != 0:
>           raise get_last_ffi_error()
E           tvm._ffi.base.TVMError: Traceback (most recent call last):
E             [bt] (8) 9   libffi.dylib                        0x00000001b9608050 ffi_call_SYSV + 80
E             [bt] (7) 8   libtvm.dylib                        0x00000002836360b4 TVMModGetFunction + 108
E             [bt] (6) 7   libtvm.dylib                        0x00000002836c56a4 tvm::runtime::ModuleNode::GetFunction(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, bool) + 132
E             [bt] (5) 6   libtvm.dylib                        0x00000002835c5f44 tvm::codegen::LLVMModuleNode::GetFunction(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, tvm::runtime::ObjectPtr<tvm::runtime::Object> const&) + 1176
E             [bt] (4) 5   libtvm.dylib                        0x00000002835c8b64 tvm::codegen::LLVMModuleNode::LazyInitJIT() + 1096
E             [bt] (3) 4   libtvm.dylib                        0x0000000280003e08 tvm::runtime::detail::LogFatal::~LogFatal() + 28
E             [bt] (2) 3   libtvm.dylib                        0x0000000280005e60 tvm::runtime::detail::LogFatal::~LogFatal() + 40
E             [bt] (1) 2   libtvm.dylib                        0x0000000280005ee8 tvm::runtime::detail::LogFatal::Entry::Finalize() + 112
E             [bt] (0) 1   libtvm.dylib                        0x00000002836a4f6c tvm::runtime::Backtrace() + 28
E             File "/Users/lisa/Documents/tvm/src/target/llvm/llvm_module.cc", line 399
E           TVMError: Cannot run module, architecture mismatch  module=arm64-apple-darwin21.1.0 system=x86_64-apple-darwin21.1.0

python/tvm/_ffi/base.py:348: TVMError
@zhen8838 zhen8838 changed the title [Bug] [Bug] The LLVM default host target in Mac m1 is x86_64, can't pass the python test Dec 3, 2021
@areusch areusch added the needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it label Oct 19, 2022
@hpanda-naut hpanda-naut added backend:llvm and removed needs-triage PRs or issues that need to be investigated by maintainers to find the right assignees to address it labels Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants