Error import relay: compiling with INTEL OneAPI

Hello, I have compile TVM (git log 6a3d950ab84eeca82d73316d9c4101d05d353f50) with INTEL OneAPI on this INTEL CPU: Intel(R) Xeon(R) Gold 6230R CPU @ 2.10GHz with the OS: Linux 4.19.0-16-amd64 #1 SMP Debian 4.19.181-1 (2021-03-19) x86_64 GNU/Linux

Here some details about the final TVM shared library:

 >> ldd libtvm.so 
	linux-vdso.so.1 (0x00007ffc8e304000)
	libLLVM-10.so => /opt/intel/oneapi/intelpython/python3.7/lib/libLLVM-10.so (0x00007f2c91125000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2c9110b000)
	libiomp5.so => /opt/intel/oneapi/compiler/2021.3.0/linux/compiler/lib/intel64_lin/libiomp5.so (0x00007f2c90cf4000)
	libdnnl.so.2 => /opt/intel/oneapi/dnnl/2021.3.0/cpu_dpcpp_gpu_dpcpp/lib/libdnnl.so.2 (0x00007f2c8d29b000)
	libimf.so => /opt/intel/oneapi/compiler/2021.3.0/linux/compiler/lib/intel64_lin/libimf.so (0x00007f2c8cc13000)
	libsvml.so => /opt/intel/oneapi/compiler/2021.3.0/linux/compiler/lib/intel64_lin/libsvml.so (0x00007f2c8b092000)
	libirng.so => /opt/intel/oneapi/compiler/2021.3.0/linux/compiler/lib/intel64_lin/libirng.so (0x00007f2c8ad28000)
	libstdc++.so.6 => /opt/intel/oneapi/intelpython/python3.7/lib/libstdc++.so.6 (0x00007f2c8abb3000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2c8aa30000)
	libgcc_s.so.1 => /opt/intel/oneapi/intelpython/python3.7/lib/libgcc_s.so.1 (0x00007f2c8aa1c000)
	libintlc.so.5 => /opt/intel/oneapi/compiler/2021.3.0/linux/compiler/lib/intel64_lin/libintlc.so.5 (0x00007f2c8a7a4000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f2c8a783000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f2c8a5c2000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f2c99b36000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f2c8a5b8000)
	libsycl.so.5 => /opt/intel/oneapi/compiler/2021.3.0/linux/lib/libsycl.so.5 (0x00007f2c8a2ff000)
	libOpenCL.so.1 => /opt/intel/oneapi/compiler/2021.3.0/linux/lib/libOpenCL.so.1 (0x00007f2c8a2f0000)
	libtbb.so.12 => /opt/intel/oneapi/tbb/2021.3.0/env/../lib/intel64/gcc4.8/libtbb.so.12 (0x00007f2c8a077000)

But tvm throws an internal error when importing relay module:

 python test_tvm.py 
Traceback (most recent call last):
  File "test_tvm.py", line 26, in <module>
    from tvm import relay
  File "/home/hbrunie/tvm/python/tvm/relay/__init__.py", line 29, in <module>
    from . import prelude
  File "/home/hbrunie/tvm/python/tvm/relay/prelude.py", line 21, in <module>
    from tvm.relay.transform import ToANormalFormExpr
  File "/home/hbrunie/tvm/python/tvm/relay/transform/__init__.py", line 22, in <module>
    from . import fake_quantization_to_integer
  File "/home/hbrunie/tvm/python/tvm/relay/transform/fake_quantization_to_integer.py", line 20, in <module>
    from ..op import register_fake_quantization_to_integer
  File "/home/hbrunie/tvm/python/tvm/relay/op/__init__.py", line 34, in <module>
    from . import strategy
  File "/home/hbrunie/tvm/python/tvm/relay/op/strategy/__init__.py", line 22, in <module>
    from .generic import *
  File "/home/hbrunie/tvm/python/tvm/relay/op/strategy/generic.py", line 158, in <module>
    @override_native_generic_func("softmax_strategy")
  File "/home/hbrunie/tvm/python/tvm/target/generic_func.py", line 134, in override_native_generic_func
    generic_func_node = get_native_generic_func(func_name)
  File "/home/hbrunie/tvm/python/tvm/target/generic_func.py", line 95, in get_native_generic_func
    return _ffi_api.GenericFuncGetGlobal(name)
  File "/home/hbrunie/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 237, in __call__
    raise get_last_ffi_error()
tvm._ffi.base.TVMError: Traceback (most recent call last):
  3: TVMFuncCall
  2: _ZNSt17_Function_handlerIFvN3tvm7runtime7TVMArgs
  1: _INTERNAL21053217::tvm::__mk_TVM3::{lambda(_INTERNAL21053217::tvm::runtime::TVMArgs, _INTERNAL21053217::tvm::runtime::TVMRetValue*)#3}::operator()(_INTERNAL21053217::tvm::runtime::TVMArgs, _INTERNAL21053217::tvm::runtime::TVMRetValue*) const
  0: tvm::IRModule tvm::runtime::TVMPODValue_::AsObjectRef<tvm::IRModule>() const
  File "../include/tvm/runtime/packed_func.h", line 1611
TVMError: 
---------------------------------------------------------------
An error occurred during the execution of TVM.
For more information, please see: https://tvm.apache.org/docs/errors.html
---------------------------------------------------------------

  Check failed: type_code_ == kTVMObjectHandle (11 vs. 8) : expected Object but got str

I have try to compile with GNU (8.3.0), and test_tvm.py runs without any trouble.

 >> cat test_tvm.py 
import tvm
from tvm import relay

I need to be able to compile it with INTEL as I want to use the OneDNN (MKLDNN) backend. Thank you,

Best regards, Hugo Brunie

I just tried to compile with GNU 8.3.0 and MKLDNN (pointing to an install of OneDNN compiled from github). test_tvm.py runs fine. So my guess is that the error really comes from compiling tvm with INTEL Compiler:

 >> icc --version
icc (ICC) 2021.3.0 20210609
Copyright (C) 1985-2021 Intel Corporation.  All rights reserved.