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
SparseConvNet
Commits
ed2a1c04
"git@developer.sourcefind.cn:OpenDAS/openpcdet.git" did not exist on "4a8a3bf72f563bf8f3ea76b72e49fec4c2414b3f"
Commit
ed2a1c04
authored
Oct 09, 2018
by
Benjamin Thomas Graham
Browse files
PyTorch 1.0
parent
3aab2c31
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
26 additions
and
27 deletions
+26
-27
README.md
README.md
+2
-2
build.sh
build.sh
+1
-1
sparseconvnet/SCN/CPU/Convolution.cpp
sparseconvnet/SCN/CPU/Convolution.cpp
+15
-15
sparseconvnet/SCN/CPU/Deconvolution.cpp
sparseconvnet/SCN/CPU/Deconvolution.cpp
+3
-3
sparseconvnet/SCN/pybind.cpp
sparseconvnet/SCN/pybind.cpp
+1
-1
sparseconvnet/SCN/sparseconvnet_cpu.cpp
sparseconvnet/SCN/sparseconvnet_cpu.cpp
+1
-1
sparseconvnet/SCN/sparseconvnet_cuda.cpp
sparseconvnet/SCN/sparseconvnet_cuda.cpp
+1
-2
sparseconvnet/sparseConvNetTensor.py
sparseconvnet/sparseConvNetTensor.py
+2
-2
No files found.
README.md
View file @
ed2a1c04
...
@@ -128,10 +128,10 @@ python VGGplus.py
...
@@ -128,10 +128,10 @@ python VGGplus.py
## Setup
## Setup
Tested with Ubuntu 16.04, Python 3.6 in
[
Miniconda
](
https://conda.io/miniconda.html
)
and PyTorch
v0.4 (with merged Tensors/Variables)
.
Tested with Ubuntu 16.04, Python 3.6 in
[
Miniconda
](
https://conda.io/miniconda.html
)
and PyTorch
1.0
.
```
```
conda install pytorch -c pytorch
conda install pytorch
-nightly
-c pytorch
# See https://pytorch.org/get-started/locally/
conda install google-sparsehash -c bioconda # OR apt-get install libsparsehash-dev
conda install google-sparsehash -c bioconda # OR apt-get install libsparsehash-dev
conda install -c anaconda pillow
conda install -c anaconda pillow
git clone git@github.com:facebookresearch/SparseConvNet.git
git clone git@github.com:facebookresearch/SparseConvNet.git
...
...
build.sh
View file @
ed2a1c04
#!/bin/bash
#!/bin/bash
rm
-rf
build/ dist/ sparseconvnet.egg-info
sparseconvnet_SCN
*
.so
rm
-rf
build/ dist/ sparseconvnet.egg-info
python setup.py
install
python setup.py
install
sparseconvnet/SCN/CPU/Convolution.cpp
View file @
ed2a1c04
...
@@ -62,7 +62,7 @@ double cpu_Convolution_updateOutput(
...
@@ -62,7 +62,7 @@ double cpu_Convolution_updateOutput(
// auto w = weight.select(0, i);
// auto w = weight.select(0, i);
// auto output_rows = at::mm(input_rows, w);
// auto output_rows = at::mm(input_rows, w);
// output_features.index_add_(0, rt.select(1, 1), output_rows);
// output_features.index_add_(0, rt.select(1, 1), output_rows);
auto
input_rows
=
input_features
.
type
()
.
tensor
({
nRules
,
ip
}
);
auto
input_rows
=
at
::
empty
({
nRules
,
ip
},
input_features
.
type
());
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
auto
w
=
weight
.
select
(
0
,
i
);
auto
w
=
weight
.
select
(
0
,
i
);
auto
output_rows
=
at
::
mm
(
input_rows
,
w
);
auto
output_rows
=
at
::
mm
(
input_rows
,
w
);
...
@@ -105,9 +105,9 @@ void cpu_Convolution_backward(
...
@@ -105,9 +105,9 @@ void cpu_Convolution_backward(
// at::mm_out(dw, input_rows.t(), d_output_rows);
// at::mm_out(dw, input_rows.t(), d_output_rows);
// auto d_input_rows = at::mm(d_output_rows, w.t());
// auto d_input_rows = at::mm(d_output_rows, w.t());
// d_input_features.index_add_(0, rt.select(1, 0), d_input_rows);
// d_input_features.index_add_(0, rt.select(1, 0), d_input_rows);
auto
input_rows
=
input_features
.
type
()
.
tensor
({
nRules
,
ip
}
);
auto
input_rows
=
at
::
empty
({
nRules
,
ip
},
input_features
.
type
());
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
auto
d_output_rows
=
d_output_features
.
type
()
.
tensor
({
nRules
,
op
}
);
auto
d_output_rows
=
at
::
empty
({
nRules
,
op
},
d_output_features
.
type
());
rule_index_select
<
T
>
(
d_output_rows
,
d_output_features
,
nRules
,
&
r
[
1
]);
rule_index_select
<
T
>
(
d_output_rows
,
d_output_features
,
nRules
,
&
r
[
1
]);
at
::
mm_out
(
dw
,
input_rows
.
t
(),
d_output_rows
);
at
::
mm_out
(
dw
,
input_rows
.
t
(),
d_output_rows
);
auto
d_input_rows
=
at
::
mm
(
d_output_rows
,
w
.
t
());
auto
d_input_rows
=
at
::
mm
(
d_output_rows
,
w
.
t
());
...
@@ -144,7 +144,7 @@ double cpu_SubmanifoldConvolution_updateOutput(
...
@@ -144,7 +144,7 @@ double cpu_SubmanifoldConvolution_updateOutput(
// auto w = weight.select(0, i);
// auto w = weight.select(0, i);
// auto output_rows = at::mm(input_rows, w);
// auto output_rows = at::mm(input_rows, w);
// output_features.index_add_(0, rt.select(1, 1), output_rows);
// output_features.index_add_(0, rt.select(1, 1), output_rows);
auto
input_rows
=
input_features
.
type
()
.
tensor
({
nRules
,
ip
}
);
auto
input_rows
=
at
::
empty
({
nRules
,
ip
},
input_features
.
type
());
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
auto
w
=
weight
.
select
(
0
,
i
);
auto
w
=
weight
.
select
(
0
,
i
);
auto
output_rows
=
at
::
mm
(
input_rows
,
w
);
auto
output_rows
=
at
::
mm
(
input_rows
,
w
);
...
@@ -186,9 +186,9 @@ void cpu_SubmanifoldConvolution_backward(
...
@@ -186,9 +186,9 @@ void cpu_SubmanifoldConvolution_backward(
// at::mm_out(dw, input_rows.t(), d_output_rows);
// at::mm_out(dw, input_rows.t(), d_output_rows);
// auto d_input_rows = at::mm(d_output_rows, w.t());
// auto d_input_rows = at::mm(d_output_rows, w.t());
// d_input_features.index_add_(0, rt.select(1, 0), d_input_rows);
// d_input_features.index_add_(0, rt.select(1, 0), d_input_rows);
auto
input_rows
=
input_features
.
type
()
.
tensor
({
nRules
,
ip
}
);
auto
input_rows
=
at
::
empty
({
nRules
,
ip
},
input_features
.
type
());
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
auto
d_output_rows
=
d_output_features
.
type
()
.
tensor
({
nRules
,
op
}
);
auto
d_output_rows
=
at
::
empty
({
nRules
,
op
},
d_output_features
.
type
());
rule_index_select
<
T
>
(
d_output_rows
,
d_output_features
,
nRules
,
&
r
[
1
]);
rule_index_select
<
T
>
(
d_output_rows
,
d_output_features
,
nRules
,
&
r
[
1
]);
at
::
mm_out
(
dw
,
input_rows
.
t
(),
d_output_rows
);
at
::
mm_out
(
dw
,
input_rows
.
t
(),
d_output_rows
);
auto
d_input_rows
=
at
::
mm
(
d_output_rows
,
w
.
t
());
auto
d_input_rows
=
at
::
mm
(
d_output_rows
,
w
.
t
());
...
@@ -224,7 +224,7 @@ double cpu_PermutohedralSubmanifoldConvolution_updateOutput(
...
@@ -224,7 +224,7 @@ double cpu_PermutohedralSubmanifoldConvolution_updateOutput(
// auto w = weight.select(0, i);
// auto w = weight.select(0, i);
// auto output_rows = at::mm(input_rows, w);
// auto output_rows = at::mm(input_rows, w);
// output_features.index_add_(0, rt.select(1, 1), output_rows);
// output_features.index_add_(0, rt.select(1, 1), output_rows);
auto
input_rows
=
input_features
.
type
()
.
tensor
({
nRules
,
ip
}
);
auto
input_rows
=
at
::
empty
({
nRules
,
ip
},
input_features
.
type
());
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
auto
w
=
weight
.
select
(
0
,
i
);
auto
w
=
weight
.
select
(
0
,
i
);
auto
output_rows
=
at
::
mm
(
input_rows
,
w
);
auto
output_rows
=
at
::
mm
(
input_rows
,
w
);
...
@@ -265,9 +265,9 @@ void cpu_PermutohedralSubmanifoldConvolution_backward(
...
@@ -265,9 +265,9 @@ void cpu_PermutohedralSubmanifoldConvolution_backward(
// at::mm_out(dw, input_rows.t(), d_output_rows);
// at::mm_out(dw, input_rows.t(), d_output_rows);
// auto d_input_rows = at::mm(d_output_rows, w.t());
// auto d_input_rows = at::mm(d_output_rows, w.t());
// d_input_features.index_add_(0, rt.select(1, 0), d_input_rows);
// d_input_features.index_add_(0, rt.select(1, 0), d_input_rows);
auto
input_rows
=
input_features
.
type
()
.
tensor
({
nRules
,
ip
}
);
auto
input_rows
=
at
::
empty
({
nRules
,
ip
},
input_features
.
type
());
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
auto
d_output_rows
=
d_output_features
.
type
()
.
tensor
({
nRules
,
op
}
);
auto
d_output_rows
=
at
::
empty
({
nRules
,
op
},
d_output_features
.
type
());
rule_index_select
<
T
>
(
d_output_rows
,
d_output_features
,
nRules
,
&
r
[
1
]);
rule_index_select
<
T
>
(
d_output_rows
,
d_output_features
,
nRules
,
&
r
[
1
]);
at
::
mm_out
(
dw
,
input_rows
.
t
(),
d_output_rows
);
at
::
mm_out
(
dw
,
input_rows
.
t
(),
d_output_rows
);
auto
d_input_rows
=
at
::
mm
(
d_output_rows
,
w
.
t
());
auto
d_input_rows
=
at
::
mm
(
d_output_rows
,
w
.
t
());
...
@@ -307,7 +307,7 @@ double cpu_FullConvolution_updateOutput(
...
@@ -307,7 +307,7 @@ double cpu_FullConvolution_updateOutput(
// auto w = weight.select(0, i);
// auto w = weight.select(0, i);
// auto output_rows = at::mm(input_rows, w);
// auto output_rows = at::mm(input_rows, w);
// output_features.index_add_(0, rt.select(1, 1), output_rows);
// output_features.index_add_(0, rt.select(1, 1), output_rows);
auto
input_rows
=
input_features
.
type
()
.
tensor
({
nRules
,
ip
}
);
auto
input_rows
=
at
::
empty
({
nRules
,
ip
},
input_features
.
type
());
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
auto
w
=
weight
.
select
(
0
,
i
);
auto
w
=
weight
.
select
(
0
,
i
);
auto
output_rows
=
at
::
mm
(
input_rows
,
w
);
auto
output_rows
=
at
::
mm
(
input_rows
,
w
);
...
@@ -352,9 +352,9 @@ void cpu_FullConvolution_backward(
...
@@ -352,9 +352,9 @@ void cpu_FullConvolution_backward(
// at::mm_out(dw, input_rows.t(), d_output_rows);
// at::mm_out(dw, input_rows.t(), d_output_rows);
// auto d_input_rows = at::mm(d_output_rows, w.t());
// auto d_input_rows = at::mm(d_output_rows, w.t());
// d_input_features.index_add_(0, rt.select(1, 0), d_input_rows);
// d_input_features.index_add_(0, rt.select(1, 0), d_input_rows);
auto
input_rows
=
input_features
.
type
()
.
tensor
({
nRules
,
ip
}
);
auto
input_rows
=
at
::
empty
({
nRules
,
ip
},
input_features
.
type
());
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
auto
d_output_rows
=
d_output_features
.
type
()
.
tensor
({
nRules
,
op
}
);
auto
d_output_rows
=
at
::
empty
({
nRules
,
op
},
d_output_features
.
type
());
rule_index_select
<
T
>
(
d_output_rows
,
d_output_features
,
nRules
,
&
r
[
1
]);
rule_index_select
<
T
>
(
d_output_rows
,
d_output_features
,
nRules
,
&
r
[
1
]);
at
::
mm_out
(
dw
,
input_rows
.
t
(),
d_output_rows
);
at
::
mm_out
(
dw
,
input_rows
.
t
(),
d_output_rows
);
auto
d_input_rows
=
at
::
mm
(
d_output_rows
,
w
.
t
());
auto
d_input_rows
=
at
::
mm
(
d_output_rows
,
w
.
t
());
...
@@ -393,7 +393,7 @@ double cpu_RandomizedStrideConvolution_updateOutput(
...
@@ -393,7 +393,7 @@ double cpu_RandomizedStrideConvolution_updateOutput(
// auto w = weight.select(0, i);
// auto w = weight.select(0, i);
// auto output_rows = at::mm(input_rows, w);
// auto output_rows = at::mm(input_rows, w);
// output_features.index_add_(0, rt.select(1, 1), output_rows);
// output_features.index_add_(0, rt.select(1, 1), output_rows);
auto
input_rows
=
input_features
.
type
()
.
tensor
({
nRules
,
ip
}
);
auto
input_rows
=
at
::
empty
({
nRules
,
ip
},
input_features
.
type
());
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
auto
w
=
weight
.
select
(
0
,
i
);
auto
w
=
weight
.
select
(
0
,
i
);
auto
output_rows
=
at
::
mm
(
input_rows
,
w
);
auto
output_rows
=
at
::
mm
(
input_rows
,
w
);
...
@@ -436,9 +436,9 @@ void cpu_RandomizedStrideConvolution_backward(
...
@@ -436,9 +436,9 @@ void cpu_RandomizedStrideConvolution_backward(
// at::mm_out(dw, input_rows.t(), d_output_rows);
// at::mm_out(dw, input_rows.t(), d_output_rows);
// auto d_input_rows = at::mm(d_output_rows, w.t());
// auto d_input_rows = at::mm(d_output_rows, w.t());
// d_input_features.index_add_(0, rt.select(1, 0), d_input_rows);
// d_input_features.index_add_(0, rt.select(1, 0), d_input_rows);
auto
input_rows
=
input_features
.
type
()
.
tensor
({
nRules
,
ip
}
);
auto
input_rows
=
at
::
empty
({
nRules
,
ip
},
input_features
.
type
());
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
0
]);
auto
d_output_rows
=
d_output_features
.
type
()
.
tensor
({
nRules
,
op
}
);
auto
d_output_rows
=
at
::
empty
({
nRules
,
op
},
d_output_features
.
type
());
rule_index_select
<
T
>
(
d_output_rows
,
d_output_features
,
nRules
,
&
r
[
1
]);
rule_index_select
<
T
>
(
d_output_rows
,
d_output_features
,
nRules
,
&
r
[
1
]);
at
::
mm_out
(
dw
,
input_rows
.
t
(),
d_output_rows
);
at
::
mm_out
(
dw
,
input_rows
.
t
(),
d_output_rows
);
auto
d_input_rows
=
at
::
mm
(
d_output_rows
,
w
.
t
());
auto
d_input_rows
=
at
::
mm
(
d_output_rows
,
w
.
t
());
...
...
sparseconvnet/SCN/CPU/Deconvolution.cpp
View file @
ed2a1c04
...
@@ -34,7 +34,7 @@ double cpu_Deconvolution_updateOutput(
...
@@ -34,7 +34,7 @@ double cpu_Deconvolution_updateOutput(
// auto w = weight.select(0, i);
// auto w = weight.select(0, i);
// auto output_rows = at::mm(input_rows, w);
// auto output_rows = at::mm(input_rows, w);
// output_features.index_add_(0, rt.select(1, 0), output_rows);
// output_features.index_add_(0, rt.select(1, 0), output_rows);
auto
input_rows
=
input_features
.
type
()
.
tensor
({
nRules
,
ip
}
);
auto
input_rows
=
at
::
empty
({
nRules
,
ip
},
input_features
.
type
());
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
1
]);
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
1
]);
auto
w
=
weight
.
select
(
0
,
i
);
auto
w
=
weight
.
select
(
0
,
i
);
auto
output_rows
=
at
::
mm
(
input_rows
,
w
);
auto
output_rows
=
at
::
mm
(
input_rows
,
w
);
...
@@ -77,9 +77,9 @@ void cpu_Deconvolution_backward(
...
@@ -77,9 +77,9 @@ void cpu_Deconvolution_backward(
// at::mm_out(dw, input_rows.t(), d_output_rows);
// at::mm_out(dw, input_rows.t(), d_output_rows);
// auto d_input_rows = at::mm(d_output_rows, w.t());
// auto d_input_rows = at::mm(d_output_rows, w.t());
// d_input_features.index_add_(0, rt.select(1, 1), d_input_rows);
// d_input_features.index_add_(0, rt.select(1, 1), d_input_rows);
auto
input_rows
=
input_features
.
type
().
tensor
({
nRules
,
ip
}
);
auto
input_rows
=
at
::
empty
({
nRules
,
ip
},
d_output_features
.
type
()
);
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
1
]);
rule_index_select
<
T
>
(
input_rows
,
input_features
,
nRules
,
&
r
[
1
]);
auto
d_output_rows
=
d_output_features
.
type
()
.
tensor
({
nRules
,
op
}
);
auto
d_output_rows
=
at
::
empty
({
nRules
,
op
},
d_output_features
.
type
());
rule_index_select
<
T
>
(
d_output_rows
,
d_output_features
,
nRules
,
&
r
[
0
]);
rule_index_select
<
T
>
(
d_output_rows
,
d_output_features
,
nRules
,
&
r
[
0
]);
at
::
mm_out
(
dw
,
input_rows
.
t
(),
d_output_rows
);
at
::
mm_out
(
dw
,
input_rows
.
t
(),
d_output_rows
);
auto
d_input_rows
=
at
::
mm
(
d_output_rows
,
w
.
t
());
auto
d_input_rows
=
at
::
mm
(
d_output_rows
,
w
.
t
());
...
...
sparseconvnet/SCN/pybind.cpp
View file @
ed2a1c04
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
// This source code is licensed under the license found in the
// This source code is licensed under the license found in the
// LICENSE file in the root directory of this source tree.
// LICENSE file in the root directory of this source tree.
#include <torch/
torch
.h>
#include <torch/
extension
.h>
#include "sparseconvnet.h"
#include "sparseconvnet.h"
...
...
sparseconvnet/SCN/sparseconvnet_cpu.cpp
View file @
ed2a1c04
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
#include <omp.h>
#include <omp.h>
#endif
#endif
#include <torch/
torch
.h>
#include <torch/
extension
.h>
#include "Metadata/Metadata.cpp"
#include "Metadata/Metadata.cpp"
template
class
Metadata
<
1
>;
template
class
Metadata
<
1
>;
...
...
sparseconvnet/SCN/sparseconvnet_cuda.cpp
View file @
ed2a1c04
...
@@ -9,10 +9,9 @@
...
@@ -9,10 +9,9 @@
#include <omp.h>
#include <omp.h>
#endif
#endif
//#include <ATen/ATen.h>
#include <cuda.h>
#include <cuda.h>
#include <cuda_runtime.h>
#include <cuda_runtime.h>
#include <torch/
torch
.h>
#include <torch/
extension
.h>
#include "Metadata/Metadata.cpp"
#include "Metadata/Metadata.cpp"
template
class
Metadata
<
1
>;
template
class
Metadata
<
1
>;
...
...
sparseconvnet/sparseConvNetTensor.py
View file @
ed2a1c04
...
@@ -29,8 +29,8 @@ class SparseConvNetTensor(object):
...
@@ -29,8 +29,8 @@ class SparseConvNetTensor(object):
return
self
return
self
return
self
.
features
.
type
()
return
self
.
features
.
type
()
def
cuda
(
self
,
async
=
False
):
def
cuda
(
self
):
self
.
features
=
self
.
features
.
cuda
(
async
=
async
)
self
.
features
=
self
.
features
.
cuda
()
return
self
return
self
def
cpu
(
self
):
def
cpu
(
self
):
...
...
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