Код: Выделить всё
undefined symbol: _Z15trilinear_fw_cuN2at6TensorES0_Полный исходный код CUDA находится здесь, исходный файл C++ в основном представляет собой просто модуль PYBIND.
Код: Выделить всё
#include
__global__ void trilinear_fw_kernel(
torch::PackedTensorAccessor feats,
torch::PackedTensorAccessor points,
torch::PackedTensorAccessor feat_interp
){
const int n = blockIdx.x * blockDim.x + threadIdx.x;
const int f = blockIdx.y * blockDim.y + threadIdx.y;
if (n>=feats.size(0) || f>=feats.size(2)) return;
// point -1~1
const scalar_t u = (points[n][0]+1)/2;
const scalar_t v = (points[n][1]+1)/2;
const scalar_t w = (points[n][2]+1)/2;
const scalar_t a = (1-v)*(1-w);
const scalar_t b = (1-v)*w;
const scalar_t c = v*(1-w);
const scalar_t d = 1-a-b-c;
feat_interp[n][f] = (1-u)*(a*feats[n][0][f] +
b*feats[n][1][f] +
c*feats[n][2][f] +
d*feats[n][3][f]) +
u*(a*feats[n][4][f] +
b*feats[n][5][f] +
c*feats[n][6][f] +
d*feats[n][7][f]);
}
torch::Tensor trilinear_fw_cu(
const torch::Tensor feats,
const torch::Tensor points
){
const int N = feats.size(0), F = feats.size(2);
torch::Tensor feat_interp = torch::empty({N, F}, feats.options());
const dim3 threads(16, 16);
const dim3 blocks((N+threads.x-1)/threads.x, (F+threads.y-1)/threads.y);
AT_DISPATCH_scalar_tING_TYPES(feats.type(), "trilinear_fw_cu",
([&] {
trilinear_fw_kernel(
feats.packed_accessor(),
points.packed_accessor(),
feat_interp.packed_accessor, size_t()
);
}));
return feat_interp;
}
Код: Выделить всё
Traceback (most recent call last):
File "/home/erik/tri_cuda/trilinear.py", line 4, in
trilinear_cpp = load(name = 'trilinear_cpp',
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/erik/miniconda3/envs/tri_cuda/lib/python3.12/site-packages/torch/utils/cpp_extension.py", line 1312, in load
return _jit_compile(
^^^^^^^^^^^^^
File "/home/erik/miniconda3/envs/tri_cuda/lib/python3.12/site-packages/torch/utils/cpp_extension.py", line 1747, in _jit_compile
return _import_module_from_library(name, build_directory, is_python_module)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/erik/miniconda3/envs/tri_cuda/lib/python3.12/site-packages/torch/utils/cpp_extension.py", line 2141, in _import_module_from_library
module = importlib.util.module_from_spec(spec)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 813, in module_from_spec
File "", line 1289, in create_module
File "", line 488, in _call_with_frames_removed
ImportError: /home/erik/.cache/torch_extensions/py312_cu124/trilinear_cpp/trilinear_cpp.so: undefined symbol: _Z15trilinear_fw_cuN2at6TensorES0_
Подробнее здесь: https://stackoverflow.com/questions/788 ... t6tensores
Мобильная версия