Skip to content

Commit 976612b

Browse files
committed
first tutorial
1 parent bf92a4c commit 976612b

File tree

4 files changed

+64
-0
lines changed

4 files changed

+64
-0
lines changed

.vscode/c_cpp_properties.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "Linux",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"/home/ubuntu/anaconda3/envs/cppcuda/include/python3.8",
8+
"/home/ubuntu/anaconda3/envs/cppcuda/lib/python3.8/site-packages/torch/include",
9+
"/home/ubuntu/anaconda3/envs/cppcuda/lib/python3.8/site-packages/torch/include/torch/csrc/api/include"
10+
],
11+
"defines": [],
12+
"compilerPath": "/usr/bin/clang",
13+
"cStandard": "c17",
14+
"cppStandard": "c++14",
15+
"intelliSenseMode": "linux-clang-x64"
16+
}
17+
],
18+
"version": 4
19+
}

interpolation.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include <torch/extension.h>
2+
3+
4+
torch::Tensor trilinear_interpolation(
5+
torch::Tensor feats,
6+
torch::Tensor point
7+
){
8+
return feats;
9+
}
10+
11+
12+
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m){
13+
m.def("trilinear_interpolation", &trilinear_interpolation);
14+
}

setup.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from setuptools import setup
2+
from torch.utils.cpp_extension import CppExtension, BuildExtension
3+
4+
5+
setup(
6+
name='cppcuda_tutorial',
7+
version='1.0',
8+
author='kwea123',
9+
author_email='kwea123@gmail.com',
10+
description='cppcuda example',
11+
long_description='cppcuda example',
12+
ext_modules=[
13+
CppExtension(
14+
name='cppcuda_tutorial',
15+
sources=['interpolation.cpp'])
16+
],
17+
cmdclass={
18+
'build_ext': BuildExtension
19+
}
20+
)

test.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import torch
2+
import cppcuda_tutorial
3+
4+
5+
feats = torch.ones(2)
6+
point = torch.zeros(2)
7+
8+
9+
out = cppcuda_tutorial.trilinear_interpolation(feats, point)
10+
11+
print(out)

0 commit comments

Comments
 (0)