尝试构建torchscript扩展将导致无效类型:只有int64_t和bool被支持为整型参数类型错误 我在Python中公开我的C++ DLL。我目前掌握的大部分代码如下: #包括 #包括 #包括 结构PyManager:torch::CustomClassHolder{ PyManager(标准::字符串模型_路径, std::字符串img\u bank\u folder\u root, std::字符串缓存\u文件夹, 字符串pnet, std::字符串rnet, std::字符串onet, 布尔重建(CACHE){ std::cout

尝试构建torchscript扩展将导致无效类型:只有int64_t和bool被支持为整型参数类型错误 我在Python中公开我的C++ DLL。我目前掌握的大部分代码如下: #包括 #包括 #包括 结构PyManager:torch::CustomClassHolder{ PyManager(标准::字符串模型_路径, std::字符串img\u bank\u folder\u root, std::字符串缓存\u文件夹, 字符串pnet, std::字符串rnet, std::字符串onet, 布尔重建(CACHE){ std::cout,c++,torch,libtorch,torchscript,C++,Torch,Libtorch,Torchscript,这个错误有点误导人!只需将所有返回类型从int转换为int64\t,就这样。现在所有的编译都很好 cmake_minimum_required(VERSION 3.1 FATAL_ERROR) project(custom_class) find_package(Torch REQUIRED) # Define our library target add_library(custom_class SHARED class1.cpp) #define our c++ standard se

这个错误有点误导人!只需将所有返回类型从
int
转换为
int64\t
,就这样。现在所有的编译都很好

cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(custom_class)

find_package(Torch REQUIRED)

# Define our library target
add_library(custom_class SHARED class1.cpp)

#define our c++ standard
set(CMAKE_CXX_STANDARD 17)
# Link against LibTorch
target_link_libraries(custom_class "${TORCH_LIBRARIES}")
cmake -DCMAKE_PREFIX_PATH="$(python -c 'import torch.utils; print(torch.utils.cmake_prefix_path)')" ..
Severity    Code    Description Project File    Line    Suppression State
Error   C2338   INVALID TYPE: Only int64_t and bool are supported as an integral argument type  custom_class    ...\libtorch-debug-latest\libtorch\include\ATen\core\op_registration\infer_schema.h 39