在mlc-llm的3rdparty/tvm/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc文件中,第574行和第595行出现了编译错误。错误原因是在std命名空间中找不到名为'is_base_of_v'的模板,应该使用'is_base_of'。为了解决这个问题,可以将这两个地方的代码修改为:
template <typename ObjectType, typename = std::enable_if_t<std::is_base_of_v<Object, ObjectType>>>
~~~~~^~~~~~~~~~~~
is_base_of
/home/hhg/android-sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/type_traits:1725:29: note: 'is_base_of' declared here
struct _LIBCPP_TEMPLATE_VIS is_base_of
^
template <typename ObjectType, typename = std::enable_if_t<std::is_base_of_v<ObjectRef, ObjectRefType>>>
~~~~~^~~~~~~~~~~~
is_base_of
/home/hhg/android-sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/type_traits:1725:29: note: 'is_base_of' declared here
struct _LIBCPP_TEMPLATE_VIS is_base_of
将这两处代码中的'is_base_of'替换为'is_base_of'即可解决问题。
翻译结果为:在文件中包含以下内容:
# include <tvm/runtime/container/string.h>
inline const ObjectType* ObjectRef::as() const {
return reinterpret_cast<const ObjectType*>(reinterpret_cast<uintptr_t>(this) & ~kTvmObjectFlagMask);
}
inline Optional ObjectRef::as() const {
if (!isNull()) {
return *reinterpret_cast<const ObjectType*>(reinterpret_cast<uintptr_t>(this) & ~kTvmObjectFlagMask);
} else {
return nullopt;
}
}
翻译结果为:在文件 /home/hhg/android-sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/type_traits:459:1: note: '_BoolConstant' 在命名空间 'std' 中声明;你是否想用 'is_base_of'?
使用 _BoolConstant _LIBCPP_NODEBUG_TYPE = integral_constant<bool, _Val>;
在文件 /home/hhg/mlc-llm/3rdparty/tvm/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc:25 中包含以下错误:
在文件 /home/hhg/mlc-llm/android/mlc4j/src/cpp/tvm_runtime.h:9 中包含以下错误:
在文件 /home/hhg/mlc-llm/android/mlc4j/../../3rdparty/tvm/src/runtime/c_runtime_api.cc:27 中包含以下错误:
在文件 /home/hhg/mlc-llm/android/mlc4j/../../3rdparty/tvm/include/tvm/runtime/device_api.h:29 中包含以下错误:
在文件 /home/hhg/mlc-llm/android/mlc4j/../../3rdparty/tvm/include/tvm/runtime/packed_func.h:28 中包含以下错误:
在文件 /home/hhg/mlc-llm/android/mlc4j/../../3rdparty/tvm/include/tvm/runtime/container/array.h:261:31 中包含以下错误:no template named 'is_base_of_v' in namespace 'std'; did you mean 'is_base'?
在文件 /home/hhg/mlc-llm/3rdparty/tvm/jvm/native/src/main/native/org_apache_tvm_native_c_api.cc:25 中包含以下错误:
在文件 /home/hhg/mlc-llm/android/mlc4j/src/cpp/tvm_runtime.h:9 中包含以下错误:
在文件 /home/hhg/mlc-llm/android/mlc4j/../../3rdparty/tvm/src/runtime/c_runtime_api.cc:27 中包含以下错误:
在文件 /home/hhg//mlc-llm//android//mlc4j//..//..//3rdparty//tvm//include//tvm//runtime//device_api.h:29 中包含以下错误:
在文件 ~/hhg//mlc-llm//android//mlc4j//..//..//3rdparty//tvm//include//tvm//runtime//packed_func.h:28 中包含以下错误:
在文件 ~/hhg//mlc-llm//android//mlc4j//..//..//3rdparty//tvm//include//tvm//runtime//container//array.h:261:26 中包含以下错误:template argument for non-type template parameter must be an expression
在文件 ~/hhg//mlc-llm//android//mlc4j//..//..//3rdparty//tvm//include//tvm//runtime//container//array.h:458:16 中包含以下警告:inline variables are a C++17 extension [-Wc++17-extensions]
在文件 ~/hhg//mlc-llm//android//mlc4j//..//..//3rdparty//tvm//include//tvm//runtime//container//array.h:650:43 中包含以下错误:no template named 'invoke_result_t' in namespace 'std'; did you mean 'invoke_result'?
在文件 ~/hhg//mlc-llm//android//mlc4j//..//..//3rdparty//tvm//include//tvm//runtime//container//array.h:661:58 中包含以下错误:no template named 'is_same_v' in namespace 'std'; did you mean 'is_same'?
翻译结果为:在文件 "/home/hhg/mlc-llm/android/mlc4j/../../3rdparty/tvm/include/tvm/runtime/container/array.h" 的第661行,出现了错误:在声明说明符之后缺少成员名称或 ';'。
在文件 "/home/hhg/mlc-llm/android/mlc4j/../../3rdparty/tvm/include/tvm/runtime/container/array.h" 的第784行,找不到名为 "invoke_result_t" 的模板名称,在命名空间 "std" 中没有找到该名称;您是否想使用 "invoke_result"?
在文件 "/home/hhg/mlc-llm/android/mlc4j/../../3rdparty/tvm/include/tvm/runtime/container/array.h" 的第792行,找不到名为 "is_same_v" 的模板名称,在命名空间 "std" 中没有找到该名称;您是否想使用 "is_same"?
在文件 "/home/hhg/mlc-llm/android/mlc4j/../../3rdparty/tvm/include/tvm/runtime/container/array.h" 的第794行,存在一个 constexpr if 语句的条件不是常量表达式;如果条件是 constexpr if 的条件,则需要确保它是常量表达式。
在文件 "/home/hhg/mlc-llm/android/mlc4j/../../3rdparty/tvm/include/tvm/runtime/container/array.h" 的第814行,存在一个 constexpr if 语句的条件不是常量表达式;如果条件是 constexpr if 的条件,则需要确保它是常量表达式。
在文件 "/home/hhg/mlc-llm/android/mlc4j/../../3rdparty/tvm/include/tvm/runtime/container/array.h" 的第876行,存在一个 inline 变量,这是 C17 的扩展;请确保您的编译器支持 C17。
构建Android绑定(mlc_llm_source_dir, output)
文件 "/home/hhg/mlc-llm/python/mlc_llm/interface/package.py",第275行,在build_android_binding中
subprocess.run([sys.executable, mlc4j_path / "prepare_libs.py"], check=True, env=os.environ)
文件 "/home/pwb/miniforge3/envs/mlc-chat-venv/lib/python3.10/subprocess.py",第526行,在run中
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError:命令 '['/home/pwb/miniforge3/envs/mlc-chat-venv/bin/python', PosixPath('/home/hhg/mlc-llm/android/mlc4j/prepare_libs.py')]'返回非零退出状态1。
重现行为
重现行为的步骤:
预期行为
环境
- 平台(例如WebGPU/Vulkan/IOS/Android/CUDA):
- 操作系统(例如Ubuntu/Windows/MacOS/...):
- 设备(例如iPhone 12 Pro,PC+RTX 3090, ...)
- 如何安装MLC-LLM(
conda
,源代码): - 如何安装TVM-Unity(
pip
,源代码): - Python版本(例如3.10):
- GPU驱动程序版本(如果适用):
- CUDA/cuDNN版本(如果适用):
- TVM Unity哈希标签(
python -c "import tvm; print('\n'.join(f'{k}: {v}' for k, v in tvm.support.libinfo().items()))"
,如果您编译模型则适用): - 其他相关信息:
其他上下文
gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.3) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.
这是免费软件;请参阅源代码的复制条件。没有
保证;甚至对于适销性或特定用途的适用性都没有保证。
5条答案
按热度按时间nmpmafwu1#
@haohenggang
is_base_of_v
是一个自C17起可用的功能。鉴于我们使用Android NDK中的clang编译源文件,请问您在您的Android NDK中的clang是否支持C17?例如,假设您已按照我们的文档设置了环境变量
TVM_NDK_CC
,那么您可以运行来检查clang版本。
jm2pwxwz2#
请使用NDK 27。
11dmarpk3#
你好,
我和你遇到了同样的问题,你解决了这个问题吗?
hts6caw34#
我遇到了同样的问题,更新NDK到27对我来说是有效的。
23c0lvtd5#
请使用最新的NDK。