Skip to content

Commit 6dafff9

Browse files
authored
Merge pull request #22 from nicolas-chaulet/cpuversion
Cpuversion
2 parents 90bae82 + 48606cf commit 6dafff9

34 files changed

+498
-470
lines changed

.devcontainer/Dockerfile

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#-------------------------------------------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
4+
#-------------------------------------------------------------------------------------------------------------
5+
6+
FROM ubuntu:bionic
7+
8+
# Avoid warnings by switching to noninteractive
9+
ENV DEBIAN_FRONTEND=noninteractive
10+
11+
# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser"
12+
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
13+
# will be updated to match your local UID/GID (when using the dockerFile property).
14+
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
15+
ARG USERNAME=vscode
16+
ARG USER_UID=1000
17+
ARG USER_GID=$USER_UID
18+
19+
# Uncomment the following COPY line and the corresponding lines in the `RUN` command if you wish to
20+
# include your requirements in the image itself. It is suggested that you only do this if your
21+
# requirements rarely (if ever) change.
22+
23+
RUN apt-get update \
24+
&& apt-get install -y --fix-missing --no-install-recommends\
25+
libffi-dev libssl-dev build-essential \
26+
python3-pip python3-dev python3-venv python3-setuptools\
27+
git iproute2 procps lsb-release clang-format \
28+
&& apt-get clean \
29+
&& rm -rf /var/lib/apt/lists/*
30+
31+
RUN pip3 install -U pip
32+
RUN pip3 install torch numpy scikit-learn flake8 setuptools
33+
RUN pip3 install torch_cluster torch_sparse torch_scatter torch_geometric

.devcontainer/devcontainer.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// For format details, see https://aka.ms/vscode-remote/devcontainer.json or this file's README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.101.1/containers/python-3
3+
{
4+
"name": "Python 3",
5+
"context": "..",
6+
"dockerFile": "Dockerfile",
7+
// Set *default* container specific settings.json values on container create.
8+
"settings": {
9+
"terminal.integrated.shell.linux": "/bin/bash",
10+
"python.pythonPath": "/usr/local/bin/python",
11+
"python.linting.enabled": true,
12+
"python.linting.pylintEnabled": true,
13+
"python.linting.pylintPath": "/usr/local/bin/pylint"
14+
},
15+
// Add the IDs of extensions you want installed when the container is created.
16+
"extensions": [
17+
"ms-python.python",
18+
"ms-vscode.cpptools"
19+
]
20+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
21+
// "forwardPorts": [],
22+
// Use 'postCreateCommand' to run commands after the container is created.
23+
// "postCreateCommand": "pip install -r requirements.txt",
24+
// Uncomment to connect as a non-root user. See https://aka.ms/vscode-remote/containers/non-root.
25+
// "remoteUser": "vscode"
26+
}

cpu/include/fps.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
#include <torch/extension.h>
3+
at::Tensor fps(at::Tensor points, const int nsamples, bool random = true);

cpu/include/group_points.h

Lines changed: 0 additions & 5 deletions
This file was deleted.

cpu/include/interpolate.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#pragma once
2+
#include <torch/extension.h>
3+
4+
at::Tensor knn_interpolate(at::Tensor features, at::Tensor idx, at::Tensor weight);
5+
6+
at::Tensor knn_interpolate_grad(at::Tensor grad_out, at::Tensor idx, at::Tensor weight,
7+
const int m);

cpu/include/knn.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#pragma once
2+
#include <torch/extension.h>
3+
std::pair<at::Tensor, at::Tensor> dense_knn(at::Tensor support, at::Tensor query, int k);

cpu/include/neighbors.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ int batch_nanoflann_neighbors(vector<scalar_t>& queries, vector<scalar_t>& suppo
1717
vector<long>& q_batches, vector<long>& s_batches,
1818
vector<long>& neighbors_indices, vector<float>& dists, float radius,
1919
int max_num, int mode);
20+
21+
template <typename scalar_t>
22+
void nanoflann_knn_neighbors(vector<scalar_t>& queries, vector<scalar_t>& supports,
23+
vector<long>& neighbors_indices, vector<float>& dists, int k);

cpu/include/utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
#define CHECK_CPU(x) AT_ASSERTM(!x.type().is_cuda(), #x " must be a CPU tensor")
55

6-
#define CHECK_CONTIGUOUS(x) AT_ASSERTM(x.is_contiguous(), #x " must be a contiguous tensor")
6+
#define CHECK_CONTIGUOUS(x) AT_ASSERTM(x.is_contiguous(), #x " must be a contiguous tensor")
File renamed without changes.

cpu/src/bindings.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
#include "ball_query.h"
2-
#include "group_points.h"
2+
#include "fps.h"
3+
#include "interpolate.h"
4+
#include "knn.h"
35

46
using namespace pybind11::literals;
57

68
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m)
79
{
8-
m.def("group_points", &group_points);
10+
m.def("dense_knn", &dense_knn, "", "support"_a, "querry"_a, "k"_a);
11+
m.def("knn_interpolate", &knn_interpolate, "", "features"_a, "idx"_a, "weights"_a);
12+
m.def("knn_interpolate_grad", &knn_interpolate_grad, "", "grad_out"_a, "idx"_a, "weights"_a,
13+
"m"_a);
14+
m.def("fps", &fps, "", "points"_a, "num_samples"_a, "random"_a);
915

1016
m.def("ball_query", &ball_query,
1117
"compute the radius search of a point cloud using nanoflann"

0 commit comments

Comments
 (0)