[TVM BYOC] compilation error while compiling CUSTOM codegen generated C file

hi , I am facing some compilation errors when trying to compile the C code generated by CUSTOM codegen using BYOC feature.
below is the headers included in the C file:

#include <cstdint>  
#include <cstdlib>  
#include <cstring>  
#include <vector>  
#include <tvm/runtime/c_runtime_api.h>  
#include <tvm/runtime/packed_func.h>  
#include <dlpack/dlpack.h>  
using namespace tvm::runtime;  
using namespace tvm::runtime::contrib;  

raw_function_call : which contains some external library calls.
tvm_wrapper(dlTensor args ...)
tvm_compatible_function(...)

Among all the other compilation error , i am interested in these two errors:

/tmp/tmpghux2_6o/lib0.c:9:31: error: ‘contrib’ is not a namespace-name
    9 | using namespace tvm::runtime::contrib;
/home/user/sait-ubuntu-workspace/tvm-workspace/tvm/include/tvm/runtime/object.h:570:67: error: ‘is_base_of_v’ is not a member of ‘std’; did you mean ‘is_base_of’?
  570 |   template <typename ObjectType, typename = std::enable_if_t<std::is_base_of_v<Object, ObjectType>>>

Any help would greatly appreciated.

EDIT : was able to solve the second error by giving c++17 flag in update lib function . However first error disappeared when i included the header file which ad the custom tvm_dll function calls declared. which was a bit strange to me.

For the second error, I think it might be because of c++17 requirement, if you’re not using a compiler that supports c++17. There was a discussion last year about possibly downgrading runtime c++ version required, but I think the conclusion was that c++17 requirement for TVM runtime was acceptable, so it was kept that way.

For the first error, I don’t think the core runtime defines a contrib namespace, but I do see that in many of the target specific runtime implementations. So perhaps you might have to check which target you’re using and whether contrib namespace is defined for that.

thanks for the quick reply , i was able to resolve both the errors:

  1. was able to resolve it by including my codegen headers which had contrib defined. I wasnt aware of the fact that core runtime doesnt define a contrib namesapce. makes total sense now.
  2. was able to reslove by compiling with c++17 flag instead of 14 which had compatibility issues in some functions. thank you for the explanation @sanirudh
1 Like