Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torch-sparse
Commits
66e70ae4
Unverified
Commit
66e70ae4
authored
Mar 21, 2022
by
Matthias Fey
Committed by
GitHub
Mar 21, 2022
Browse files
cmake fixes (#212)
parent
3c64bb0d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
39 deletions
+60
-39
csrc/sparse.h
csrc/sparse.h
+54
-35
csrc/version.cpp
csrc/version.cpp
+6
-4
No files found.
csrc/sparse.h
View file @
66e70ae4
#pragma once
#pragma once
#include <torch/
library
.h>
#include <torch/
extension
.h>
#ifdef _WIN32
#ifdef _WIN32
#if defined(torchsparse_EXPORTS)
#if defined(torchsparse_EXPORTS)
...
@@ -12,32 +12,49 @@
...
@@ -12,32 +12,49 @@
#define SPARSE_API
#define SPARSE_API
#endif
#endif
#if (defined __cpp_inline_variables) || __cplusplus >= 201703L
#define SPARSE_INLINE_VARIABLE inline
#else
#ifdef _MSC_VER
#define SPARSE_INLINE_VARIABLE __declspec(selectany)
#else
#define SPARSE_INLINE_VARIABLE __attribute__((weak))
#endif
#endif
SPARSE_API
int64_t
cuda_version
();
namespace
sparse
{
SPARSE_API
int64_t
cuda_version
()
noexcept
;
namespace
detail
{
SPARSE_INLINE_VARIABLE
int64_t
_cuda_version
=
cuda_version
();
}
// namespace detail
}
// namespace sparse
SPARSE_API
torch
::
Tensor
ind2ptr
(
torch
::
Tensor
ind
,
int64_t
M
);
SPARSE_API
torch
::
Tensor
ind2ptr
(
torch
::
Tensor
ind
,
int64_t
M
);
SPARSE_API
torch
::
Tensor
ptr2ind
(
torch
::
Tensor
ptr
,
int64_t
E
);
SPARSE_API
torch
::
Tensor
ptr2ind
(
torch
::
Tensor
ptr
,
int64_t
E
);
SPARSE_API
torch
::
Tensor
partition
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
SPARSE_API
torch
::
Tensor
torch
::
optional
<
torch
::
Tensor
>
optional_value
,
partition
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
int64_t
num_parts
,
bool
recursive
);
torch
::
optional
<
torch
::
Tensor
>
optional_value
,
int64_t
num_parts
,
bool
recursive
);
SPARSE_API
torch
::
Tensor
partition2
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
SPARSE_API
torch
::
Tensor
partition2
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
torch
::
optional
<
torch
::
Tensor
>
optional_value
,
torch
::
optional
<
torch
::
Tensor
>
optional_value
,
torch
::
optional
<
torch
::
Tensor
>
optional_node_weight
,
torch
::
optional
<
torch
::
Tensor
>
optional_node_weight
,
int64_t
num_parts
,
bool
recursive
);
int64_t
num_parts
,
bool
recursive
);
SPARSE_API
torch
::
Tensor
mt_partition
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
SPARSE_API
torch
::
Tensor
mt_partition
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
torch
::
optional
<
torch
::
Tensor
>
optional_value
,
torch
::
optional
<
torch
::
Tensor
>
optional_value
,
torch
::
optional
<
torch
::
Tensor
>
optional_node_weight
,
torch
::
optional
<
torch
::
Tensor
>
optional_node_weight
,
int64_t
num_parts
,
bool
recursive
,
int64_t
num_parts
,
bool
recursive
,
int64_t
num_workers
);
int64_t
num_workers
);
SPARSE_API
std
::
tuple
<
torch
::
Tensor
,
torch
::
Tensor
>
relabel
(
torch
::
Tensor
col
,
SPARSE_API
std
::
tuple
<
torch
::
Tensor
,
torch
::
Tensor
>
relabel
(
torch
::
Tensor
col
,
torch
::
Tensor
idx
);
torch
::
Tensor
idx
);
SPARSE_API
std
::
tuple
<
torch
::
Tensor
,
torch
::
Tensor
,
torch
::
optional
<
torch
::
Tensor
>
,
SPARSE_API
std
::
tuple
<
torch
::
Tensor
,
torch
::
Tensor
,
torch
::
Tensor
>
torch
::
optional
<
torch
::
Tensor
>
,
torch
::
Tensor
>
relabel_one_hop
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
relabel_one_hop
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
torch
::
optional
<
torch
::
Tensor
>
optional_value
,
torch
::
optional
<
torch
::
Tensor
>
optional_value
,
torch
::
Tensor
idx
,
bool
bipartite
);
torch
::
Tensor
idx
,
bool
bipartite
);
...
@@ -49,7 +66,8 @@ SPARSE_API std::tuple<torch::Tensor, torch::Tensor, torch::Tensor>
...
@@ -49,7 +66,8 @@ SPARSE_API std::tuple<torch::Tensor, torch::Tensor, torch::Tensor>
subgraph
(
torch
::
Tensor
idx
,
torch
::
Tensor
rowptr
,
torch
::
Tensor
row
,
subgraph
(
torch
::
Tensor
idx
,
torch
::
Tensor
rowptr
,
torch
::
Tensor
row
,
torch
::
Tensor
col
);
torch
::
Tensor
col
);
SPARSE_API
std
::
tuple
<
torch
::
Tensor
,
torch
::
Tensor
,
torch
::
Tensor
,
torch
::
Tensor
>
SPARSE_API
std
::
tuple
<
torch
::
Tensor
,
torch
::
Tensor
,
torch
::
Tensor
,
torch
::
Tensor
>
sample_adj
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
torch
::
Tensor
idx
,
sample_adj
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
torch
::
Tensor
idx
,
int64_t
num_neighbors
,
bool
replace
);
int64_t
num_neighbors
,
bool
replace
);
...
@@ -76,7 +94,8 @@ SPARSE_API std::tuple<torch::Tensor, torch::Tensor>
...
@@ -76,7 +94,8 @@ SPARSE_API std::tuple<torch::Tensor, torch::Tensor>
spmm_max
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
spmm_max
(
torch
::
Tensor
rowptr
,
torch
::
Tensor
col
,
torch
::
optional
<
torch
::
Tensor
>
opt_value
,
torch
::
Tensor
mat
);
torch
::
optional
<
torch
::
Tensor
>
opt_value
,
torch
::
Tensor
mat
);
SPARSE_API
std
::
tuple
<
torch
::
Tensor
,
torch
::
Tensor
,
torch
::
optional
<
torch
::
Tensor
>>
SPARSE_API
std
::
tuple
<
torch
::
Tensor
,
torch
::
Tensor
,
torch
::
optional
<
torch
::
Tensor
>>
spspmm_sum
(
torch
::
Tensor
rowptrA
,
torch
::
Tensor
colA
,
spspmm_sum
(
torch
::
Tensor
rowptrA
,
torch
::
Tensor
colA
,
torch
::
optional
<
torch
::
Tensor
>
optional_valueA
,
torch
::
optional
<
torch
::
Tensor
>
optional_valueA
,
torch
::
Tensor
rowptrB
,
torch
::
Tensor
colB
,
torch
::
Tensor
rowptrB
,
torch
::
Tensor
colB
,
...
...
csrc/version.cpp
View file @
66e70ae4
#ifdef WITH_PYTHON
#ifdef WITH_PYTHON
#include <Python.h>
#include <Python.h>
#endif
#endif
#include <torch/script.h>
#include "sparse.h"
#include "sparse.h"
#include <torch/script.h>
#ifdef WITH_CUDA
#ifdef WITH_CUDA
#include <cuda.h>
#include <cuda.h>
...
@@ -18,13 +18,15 @@ PyMODINIT_FUNC PyInit__version_cpu(void) { return NULL; }
...
@@ -18,13 +18,15 @@ PyMODINIT_FUNC PyInit__version_cpu(void) { return NULL; }
#endif
#endif
#endif
#endif
SPARSE_API
int64_t
cuda_version
()
{
namespace
sparse
{
SPARSE_API
int64_t
cuda_version
()
noexcept
{
#ifdef WITH_CUDA
#ifdef WITH_CUDA
return
CUDA_VERSION
;
return
CUDA_VERSION
;
#else
#else
return
-
1
;
return
-
1
;
#endif
#endif
}
}
}
// namespace sparse
static
auto
registry
=
static
auto
registry
=
torch
::
RegisterOperators
().
op
(
torch
::
RegisterOperators
().
op
(
"torch_sparse::cuda_version"
,
&
cuda_version
);
"torch_sparse::cuda_version"
,
&
sparse
::
cuda_version
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment