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
d8c8a060
Commit
d8c8a060
authored
Aug 29, 2019
by
Michal Pandy
Browse files
Use references where possible
parent
1171aae3
Changes
34
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
948 additions
and
937 deletions
+948
-937
sparseconvnet/SCN/CUDA/IOLayers.cpp
sparseconvnet/SCN/CUDA/IOLayers.cpp
+20
-20
sparseconvnet/SCN/CUDA/LeakyReLU.cpp
sparseconvnet/SCN/CUDA/LeakyReLU.cpp
+5
-5
sparseconvnet/SCN/CUDA/MaxPooling.cpp
sparseconvnet/SCN/CUDA/MaxPooling.cpp
+28
-28
sparseconvnet/SCN/CUDA/SparseToDense.cpp
sparseconvnet/SCN/CUDA/SparseToDense.cpp
+9
-9
sparseconvnet/SCN/CUDA/UnPooling.cpp
sparseconvnet/SCN/CUDA/UnPooling.cpp
+12
-12
sparseconvnet/SCN/Metadata/ConvolutionRules.h
sparseconvnet/SCN/Metadata/ConvolutionRules.h
+0
-1
sparseconvnet/SCN/Metadata/Metadata.cpp
sparseconvnet/SCN/Metadata/Metadata.cpp
+49
-48
sparseconvnet/SCN/Metadata/Metadata.h
sparseconvnet/SCN/Metadata/Metadata.h
+52
-49
sparseconvnet/SCN/cuda.cu
sparseconvnet/SCN/cuda.cu
+2
-2
sparseconvnet/SCN/misc/drawCurve.cpp
sparseconvnet/SCN/misc/drawCurve.cpp
+3
-3
sparseconvnet/SCN/pybind.cpp
sparseconvnet/SCN/pybind.cpp
+66
-66
sparseconvnet/SCN/sparseconvnet.h
sparseconvnet/SCN/sparseconvnet.h
+164
-164
sparseconvnet/SCN/sparseconvnet_cpu.cpp
sparseconvnet/SCN/sparseconvnet_cpu.cpp
+262
-262
sparseconvnet/SCN/sparseconvnet_cuda.cpp
sparseconvnet/SCN/sparseconvnet_cuda.cpp
+276
-268
No files found.
sparseconvnet/SCN/CUDA/IOLayers.cpp
View file @
d8c8a060
...
@@ -16,10 +16,10 @@ void InputLayer_bp(T *d_input_features, T *d_output_features, Int nRows,
...
@@ -16,10 +16,10 @@ void InputLayer_bp(T *d_input_features, T *d_output_features, Int nRows,
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_InputLayer_updateOutput
(
Metadata
<
Dimension
>
&
m
,
void
cuda_InputLayer_updateOutput
(
Metadata
<
Dimension
>
&
m
,
/*long*/
at
::
Tensor
spatialSize
,
/*long*/
at
::
Tensor
&
spatialSize
,
/*long*/
at
::
Tensor
input_coords
,
/*long*/
at
::
Tensor
&
input_coords
,
/*cuda float*/
at
::
Tensor
input_features
,
/*cuda float*/
at
::
Tensor
&
input_features
,
/*cuda float*/
at
::
Tensor
output_features
,
/*cuda float*/
at
::
Tensor
&
output_features
,
long
batchSize
,
long
mode
)
{
long
batchSize
,
long
mode
)
{
m
.
inputLayer
(
spatialSize
,
input_coords
,
batchSize
,
mode
);
m
.
inputLayer
(
spatialSize
,
input_coords
,
batchSize
,
mode
);
...
@@ -44,8 +44,8 @@ void cuda_InputLayer_updateOutput(Metadata<Dimension> &m,
...
@@ -44,8 +44,8 @@ void cuda_InputLayer_updateOutput(Metadata<Dimension> &m,
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_InputLayer_updateGradInput
(
void
cuda_InputLayer_updateGradInput
(
Metadata
<
Dimension
>
&
m
,
Metadata
<
Dimension
>
&
m
,
/*cuda float*/
at
::
Tensor
d_input_features
,
/*cuda float*/
at
::
Tensor
&
d_input_features
,
/*cuda float*/
at
::
Tensor
d_output_features
)
{
/*cuda float*/
at
::
Tensor
&
d_output_features
)
{
auto
&
rules
=
m
.
inputLayerRuleBook
;
auto
&
rules
=
m
.
inputLayerRuleBook
;
Int
nPlanes
=
d_output_features
.
size
(
1
);
Int
nPlanes
=
d_output_features
.
size
(
1
);
...
@@ -69,8 +69,8 @@ void cuda_InputLayer_updateGradInput(
...
@@ -69,8 +69,8 @@ void cuda_InputLayer_updateGradInput(
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_OutputLayer_updateOutput
(
Metadata
<
Dimension
>
&
m
,
void
cuda_OutputLayer_updateOutput
(
Metadata
<
Dimension
>
&
m
,
/*cuda float*/
at
::
Tensor
input_features
,
/*cuda float*/
at
::
Tensor
&
input_features
,
/*cuda float*/
at
::
Tensor
output_features
)
{
/*cuda float*/
at
::
Tensor
&
output_features
)
{
auto
&
rules
=
m
.
inputLayerRuleBook
;
auto
&
rules
=
m
.
inputLayerRuleBook
;
Int
nPlanes
=
input_features
.
size
(
1
);
Int
nPlanes
=
input_features
.
size
(
1
);
...
@@ -93,8 +93,8 @@ void cuda_OutputLayer_updateOutput(Metadata<Dimension> &m,
...
@@ -93,8 +93,8 @@ void cuda_OutputLayer_updateOutput(Metadata<Dimension> &m,
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_OutputLayer_updateGradInput
(
void
cuda_OutputLayer_updateGradInput
(
Metadata
<
Dimension
>
&
m
,
Metadata
<
Dimension
>
&
m
,
/*cuda float*/
at
::
Tensor
d_input_features
,
/*cuda float*/
at
::
Tensor
&
d_input_features
,
/*cuda float*/
at
::
Tensor
d_output_features
)
{
/*cuda float*/
at
::
Tensor
&
d_output_features
)
{
auto
&
rules
=
m
.
inputLayerRuleBook
;
auto
&
rules
=
m
.
inputLayerRuleBook
;
Int
nPlanes
=
d_output_features
.
size
(
1
);
Int
nPlanes
=
d_output_features
.
size
(
1
);
...
@@ -118,10 +118,10 @@ void cuda_OutputLayer_updateGradInput(
...
@@ -118,10 +118,10 @@ void cuda_OutputLayer_updateGradInput(
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_BLInputLayer_updateOutput
(
Metadata
<
Dimension
>
&
m
,
void
cuda_BLInputLayer_updateOutput
(
Metadata
<
Dimension
>
&
m
,
/*long*/
at
::
Tensor
spatialSize
,
/*long*/
at
::
Tensor
&
spatialSize
,
/*long*/
at
::
Tensor
input_coords
,
/*long*/
at
::
Tensor
&
input_coords
,
/*cuda float*/
at
::
Tensor
input_features
,
/*cuda float*/
at
::
Tensor
&
input_features
,
/*cuda float*/
at
::
Tensor
output_features
,
/*cuda float*/
at
::
Tensor
&
output_features
,
long
mode
)
{
long
mode
)
{
m
.
blLayer
(
spatialSize
,
input_coords
,
mode
);
m
.
blLayer
(
spatialSize
,
input_coords
,
mode
);
...
@@ -148,8 +148,8 @@ void cuda_BLInputLayer_updateOutput(Metadata<Dimension> &m,
...
@@ -148,8 +148,8 @@ void cuda_BLInputLayer_updateOutput(Metadata<Dimension> &m,
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_BLInputLayer_updateGradInput
(
void
cuda_BLInputLayer_updateGradInput
(
Metadata
<
Dimension
>
&
m
,
Metadata
<
Dimension
>
&
m
,
/*cuda float*/
at
::
Tensor
d_input_features
,
/*cuda float*/
at
::
Tensor
&
d_input_features
,
/*cuda float*/
at
::
Tensor
d_output_features
)
{
/*cuda float*/
at
::
Tensor
&
d_output_features
)
{
auto
&
rules
=
m
.
blLayerRuleBook
;
auto
&
rules
=
m
.
blLayerRuleBook
;
Int
nPlanes
=
d_output_features
.
size
(
1
);
Int
nPlanes
=
d_output_features
.
size
(
1
);
...
@@ -176,8 +176,8 @@ void cuda_BLInputLayer_updateGradInput(
...
@@ -176,8 +176,8 @@ void cuda_BLInputLayer_updateGradInput(
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_BLOutputLayer_updateOutput
(
void
cuda_BLOutputLayer_updateOutput
(
Metadata
<
Dimension
>
&
m
,
Metadata
<
Dimension
>
&
m
,
/*cuda float*/
at
::
Tensor
input_features
,
/*cuda float*/
at
::
Tensor
&
input_features
,
/*cuda float*/
at
::
Tensor
output_features
)
{
/*cuda float*/
at
::
Tensor
&
output_features
)
{
auto
&
rules
=
m
.
blLayerRuleBook
;
auto
&
rules
=
m
.
blLayerRuleBook
;
Int
nPlanes
=
input_features
.
size
(
1
);
Int
nPlanes
=
input_features
.
size
(
1
);
...
@@ -201,8 +201,8 @@ void cuda_BLOutputLayer_updateOutput(
...
@@ -201,8 +201,8 @@ void cuda_BLOutputLayer_updateOutput(
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_BLOutputLayer_updateGradInput
(
void
cuda_BLOutputLayer_updateGradInput
(
Metadata
<
Dimension
>
&
m
,
Metadata
<
Dimension
>
&
m
,
/*cuda float*/
at
::
Tensor
d_input_features
,
/*cuda float*/
at
::
Tensor
&
d_input_features
,
/*cuda float*/
at
::
Tensor
d_output_features
)
{
/*cuda float*/
at
::
Tensor
&
d_output_features
)
{
auto
&
rules
=
m
.
blLayerRuleBook
;
auto
&
rules
=
m
.
blLayerRuleBook
;
Int
nPlanes
=
d_output_features
.
size
(
2
);
Int
nPlanes
=
d_output_features
.
size
(
2
);
...
...
sparseconvnet/SCN/CUDA/LeakyReLU.cpp
View file @
d8c8a060
...
@@ -11,8 +11,8 @@ void LeakyReLU_bp(T *input_features, T *d_input_features, T *output_features,
...
@@ -11,8 +11,8 @@ void LeakyReLU_bp(T *input_features, T *d_input_features, T *output_features,
Int
n
,
T
alpha
);
Int
n
,
T
alpha
);
template
<
typename
T
>
template
<
typename
T
>
void
cuda_LeakyReLU_updateOutput
(
/*cuda float*/
at
::
Tensor
input_features
,
void
cuda_LeakyReLU_updateOutput
(
/*cuda float*/
at
::
Tensor
&
input_features
,
/*cuda float*/
at
::
Tensor
output_features
,
/*cuda float*/
at
::
Tensor
&
output_features
,
T
alpha
)
{
T
alpha
)
{
output_features
.
resize_as_
(
input_features
);
output_features
.
resize_as_
(
input_features
);
auto
n
=
input_features
.
numel
();
auto
n
=
input_features
.
numel
();
...
@@ -22,9 +22,9 @@ void cuda_LeakyReLU_updateOutput(/*cuda float*/ at::Tensor input_features,
...
@@ -22,9 +22,9 @@ void cuda_LeakyReLU_updateOutput(/*cuda float*/ at::Tensor input_features,
template
<
typename
T
>
template
<
typename
T
>
void
cuda_LeakyReLU_updateGradInput
(
void
cuda_LeakyReLU_updateGradInput
(
/*cuda float*/
at
::
Tensor
input_features
,
/*cuda float*/
at
::
Tensor
&
input_features
,
/*cuda float*/
at
::
Tensor
d_input_features
,
/*cuda float*/
at
::
Tensor
&
d_input_features
,
/*cuda float*/
at
::
Tensor
d_output_features
,
T
alpha
)
{
/*cuda float*/
at
::
Tensor
&
d_output_features
,
T
alpha
)
{
d_input_features
.
resize_as_
(
d_output_features
);
d_input_features
.
resize_as_
(
d_output_features
);
auto
n
=
d_input_features
.
numel
();
auto
n
=
d_input_features
.
numel
();
LeakyReLU_bp
<
T
>
(
input_features
.
data
<
T
>
(),
d_input_features
.
data
<
T
>
(),
LeakyReLU_bp
<
T
>
(
input_features
.
data
<
T
>
(),
d_input_features
.
data
<
T
>
(),
...
...
sparseconvnet/SCN/CUDA/MaxPooling.cpp
View file @
d8c8a060
...
@@ -16,14 +16,14 @@ void cuda_MaxPooling_BackwardPass(T *input_features, T *d_input_features,
...
@@ -16,14 +16,14 @@ void cuda_MaxPooling_BackwardPass(T *input_features, T *d_input_features,
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_MaxPooling_updateOutput
(
void
cuda_MaxPooling_updateOutput
(
/*long*/
at
::
Tensor
inputSize
,
/*long*/
at
::
Tensor
outputSize
,
/*long*/
at
::
Tensor
&
inputSize
,
/*long*/
at
::
Tensor
&
outputSize
,
/*long*/
at
::
Tensor
poolSize
,
/*long*/
at
::
Tensor
&
poolSize
,
/*long*/
at
::
Tensor
poolStride
,
Metadata
<
Dimension
>
&
m
,
/*long*/
at
::
Tensor
&
poolStride
,
Metadata
<
Dimension
>
&
m
,
/*cuda float*/
at
::
Tensor
input_features
,
/*cuda float*/
at
::
Tensor
&
input_features
,
/*cuda float*/
at
::
Tensor
output_features
,
long
nFeaturesToDrop
)
{
/*cuda float*/
at
::
Tensor
&
output_features
,
long
nFeaturesToDrop
)
{
Int
nPlanes
=
input_features
.
size
(
1
)
-
nFeaturesToDrop
;
Int
nPlanes
=
input_features
.
size
(
1
)
-
nFeaturesToDrop
;
auto
_rules
=
const
auto
&
_rules
=
m
.
getRuleBook
(
inputSize
,
outputSize
,
poolSize
,
poolStride
,
true
);
m
.
getRuleBook
(
inputSize
,
outputSize
,
poolSize
,
poolStride
,
true
);
Int
nActive
=
m
.
getNActive
(
outputSize
);
Int
nActive
=
m
.
getNActive
(
outputSize
);
output_features
.
resize_
({
nActive
,
nPlanes
});
output_features
.
resize_
({
nActive
,
nPlanes
});
...
@@ -36,16 +36,16 @@ void cuda_MaxPooling_updateOutput(
...
@@ -36,16 +36,16 @@ void cuda_MaxPooling_updateOutput(
}
}
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_MaxPooling_updateGradInput
(
void
cuda_MaxPooling_updateGradInput
(
/*long*/
at
::
Tensor
inputSize
,
/*long*/
at
::
Tensor
outputSize
,
/*long*/
at
::
Tensor
&
inputSize
,
/*long*/
at
::
Tensor
&
outputSize
,
/*long*/
at
::
Tensor
poolSize
,
/*long*/
at
::
Tensor
&
poolSize
,
/*long*/
at
::
Tensor
poolStride
,
Metadata
<
Dimension
>
&
m
,
/*long*/
at
::
Tensor
&
poolStride
,
Metadata
<
Dimension
>
&
m
,
/*cuda float*/
at
::
Tensor
input_features
,
/*cuda float*/
at
::
Tensor
&
input_features
,
/*cuda float*/
at
::
Tensor
d_input_features
,
/*cuda float*/
at
::
Tensor
&
d_input_features
,
/*cuda float*/
at
::
Tensor
output_features
,
/*cuda float*/
at
::
Tensor
&
output_features
,
/*cuda float*/
at
::
Tensor
d_output_features
,
long
nFeaturesToDrop
)
{
/*cuda float*/
at
::
Tensor
&
d_output_features
,
long
nFeaturesToDrop
)
{
Int
nPlanes
=
input_features
.
size
(
1
)
-
nFeaturesToDrop
;
Int
nPlanes
=
input_features
.
size
(
1
)
-
nFeaturesToDrop
;
auto
_rules
=
const
auto
&
_rules
=
m
.
getRuleBook
(
inputSize
,
outputSize
,
poolSize
,
poolStride
,
true
);
m
.
getRuleBook
(
inputSize
,
outputSize
,
poolSize
,
poolStride
,
true
);
d_input_features
.
resize_as_
(
input_features
);
d_input_features
.
resize_as_
(
input_features
);
d_input_features
.
zero_
();
d_input_features
.
zero_
();
...
@@ -60,14 +60,14 @@ void cuda_MaxPooling_updateGradInput(
...
@@ -60,14 +60,14 @@ void cuda_MaxPooling_updateGradInput(
}
}
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_RandomizedStrideMaxPooling_updateOutput
(
void
cuda_RandomizedStrideMaxPooling_updateOutput
(
/*long*/
at
::
Tensor
inputSize
,
/*long*/
at
::
Tensor
outputSize
,
/*long*/
at
::
Tensor
&
inputSize
,
/*long*/
at
::
Tensor
&
outputSize
,
/*long*/
at
::
Tensor
poolSize
,
/*long*/
at
::
Tensor
&
poolSize
,
/*long*/
at
::
Tensor
poolStride
,
Metadata
<
Dimension
>
&
m
,
/*long*/
at
::
Tensor
&
poolStride
,
Metadata
<
Dimension
>
&
m
,
/*cuda float*/
at
::
Tensor
input_features
,
/*cuda float*/
at
::
Tensor
&
input_features
,
/*cuda float*/
at
::
Tensor
output_features
,
long
nFeaturesToDrop
)
{
/*cuda float*/
at
::
Tensor
&
output_features
,
long
nFeaturesToDrop
)
{
Int
nPlanes
=
input_features
.
size
(
1
)
-
nFeaturesToDrop
;
Int
nPlanes
=
input_features
.
size
(
1
)
-
nFeaturesToDrop
;
auto
_rules
=
m
.
getRandomizedStrideRuleBook
(
inputSize
,
outputSize
,
poolSize
,
const
auto
&
_rules
=
m
.
getRandomizedStrideRuleBook
(
inputSize
,
outputSize
,
poolSize
,
poolStride
,
true
);
poolStride
,
true
);
Int
nActive
=
m
.
getNActive
(
outputSize
);
Int
nActive
=
m
.
getNActive
(
outputSize
);
output_features
.
resize_
({
nActive
,
nPlanes
});
output_features
.
resize_
({
nActive
,
nPlanes
});
...
@@ -80,16 +80,16 @@ void cuda_RandomizedStrideMaxPooling_updateOutput(
...
@@ -80,16 +80,16 @@ void cuda_RandomizedStrideMaxPooling_updateOutput(
}
}
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_RandomizedStrideMaxPooling_updateGradInput
(
void
cuda_RandomizedStrideMaxPooling_updateGradInput
(
/*long*/
at
::
Tensor
inputSize
,
/*long*/
at
::
Tensor
outputSize
,
/*long*/
at
::
Tensor
&
inputSize
,
/*long*/
at
::
Tensor
&
outputSize
,
/*long*/
at
::
Tensor
poolSize
,
/*long*/
at
::
Tensor
&
poolSize
,
/*long*/
at
::
Tensor
poolStride
,
Metadata
<
Dimension
>
&
m
,
/*long*/
at
::
Tensor
&
poolStride
,
Metadata
<
Dimension
>
&
m
,
/*cuda float*/
at
::
Tensor
input_features
,
/*cuda float*/
at
::
Tensor
&
input_features
,
/*cuda float*/
at
::
Tensor
d_input_features
,
/*cuda float*/
at
::
Tensor
&
d_input_features
,
/*cuda float*/
at
::
Tensor
output_features
,
/*cuda float*/
at
::
Tensor
&
output_features
,
/*cuda float*/
at
::
Tensor
d_output_features
,
long
nFeaturesToDrop
)
{
/*cuda float*/
at
::
Tensor
&
d_output_features
,
long
nFeaturesToDrop
)
{
Int
nPlanes
=
input_features
.
size
(
1
)
-
nFeaturesToDrop
;
Int
nPlanes
=
input_features
.
size
(
1
)
-
nFeaturesToDrop
;
auto
_rules
=
m
.
getRandomizedStrideRuleBook
(
inputSize
,
outputSize
,
poolSize
,
const
auto
&
_rules
=
m
.
getRandomizedStrideRuleBook
(
inputSize
,
outputSize
,
poolSize
,
poolStride
,
true
);
poolStride
,
true
);
d_input_features
.
resize_as_
(
input_features
);
d_input_features
.
resize_as_
(
input_features
);
d_input_features
.
zero_
();
d_input_features
.
zero_
();
...
...
sparseconvnet/SCN/CUDA/SparseToDense.cpp
View file @
d8c8a060
...
@@ -15,9 +15,9 @@ void cuda_SparseToDense_BackwardPass(T *d_input_features, T *d_output_features,
...
@@ -15,9 +15,9 @@ void cuda_SparseToDense_BackwardPass(T *d_input_features, T *d_output_features,
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_SparseToDense_updateOutput
(
void
cuda_SparseToDense_updateOutput
(
/*long*/
at
::
Tensor
inputSize
,
Metadata
<
Dimension
>
&
m
,
/*long*/
at
::
Tensor
&
inputSize
,
Metadata
<
Dimension
>
&
m
,
/*cuda float*/
at
::
Tensor
input_features
,
/*cuda float*/
at
::
Tensor
&
input_features
,
/*cuda float*/
at
::
Tensor
output_features
,
long
nPlanes
)
{
/*cuda float*/
at
::
Tensor
&
output_features
,
long
nPlanes
)
{
{
{
std
::
array
<
long
,
Dimension
+
2
>
sz
;
std
::
array
<
long
,
Dimension
+
2
>
sz
;
...
@@ -30,7 +30,7 @@ void cuda_SparseToDense_updateOutput(
...
@@ -30,7 +30,7 @@ void cuda_SparseToDense_updateOutput(
output_features
.
zero_
();
output_features
.
zero_
();
}
}
if
(
input_features
.
ndimension
()
==
2
)
{
if
(
input_features
.
ndimension
()
==
2
)
{
auto
_rules
=
m
.
getSparseToDenseRuleBook
(
inputSize
,
true
);
const
auto
&
_rules
=
m
.
getSparseToDenseRuleBook
(
inputSize
,
true
);
Int
_nPlanes
=
input_features
.
size
(
1
);
Int
_nPlanes
=
input_features
.
size
(
1
);
auto
iF
=
input_features
.
data
<
T
>
();
auto
iF
=
input_features
.
data
<
T
>
();
auto
oF
=
output_features
.
data
<
T
>
();
auto
oF
=
output_features
.
data
<
T
>
();
...
@@ -40,16 +40,16 @@ void cuda_SparseToDense_updateOutput(
...
@@ -40,16 +40,16 @@ void cuda_SparseToDense_updateOutput(
}
}
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_SparseToDense_updateGradInput
(
void
cuda_SparseToDense_updateGradInput
(
/*long*/
at
::
Tensor
inputSize
,
Metadata
<
Dimension
>
&
m
,
/*long*/
at
::
Tensor
&
inputSize
,
Metadata
<
Dimension
>
&
m
,
/*cuda float*/
at
::
Tensor
input_features
,
/*cuda float*/
at
::
Tensor
&
input_features
,
/*cuda float*/
at
::
Tensor
d_input_features
,
/*cuda float*/
at
::
Tensor
&
d_input_features
,
/*cuda float*/
at
::
Tensor
d_output_features
)
{
/*cuda float*/
at
::
Tensor
&
d_output_features
)
{
d_input_features
.
resize_as_
(
input_features
);
d_input_features
.
resize_as_
(
input_features
);
d_input_features
.
zero_
();
d_input_features
.
zero_
();
if
(
input_features
.
ndimension
()
==
2
)
{
if
(
input_features
.
ndimension
()
==
2
)
{
auto
_rules
=
m
.
getSparseToDenseRuleBook
(
inputSize
,
true
);
const
auto
&
_rules
=
m
.
getSparseToDenseRuleBook
(
inputSize
,
true
);
long
spatialVolume
=
inputSize
.
prod
().
data
<
long
>
()[
0
];
long
spatialVolume
=
inputSize
.
prod
().
data
<
long
>
()[
0
];
Int
_nPlanes
=
d_input_features
.
size
(
1
);
Int
_nPlanes
=
d_input_features
.
size
(
1
);
auto
diF
=
d_input_features
.
data
<
T
>
();
auto
diF
=
d_input_features
.
data
<
T
>
();
...
...
sparseconvnet/SCN/CUDA/UnPooling.cpp
View file @
d8c8a060
...
@@ -15,14 +15,14 @@ void cuda_UnPooling_BackwardPass(T *d_input_features, T *d_output_features,
...
@@ -15,14 +15,14 @@ void cuda_UnPooling_BackwardPass(T *d_input_features, T *d_output_features,
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_UnPooling_updateOutput
(
void
cuda_UnPooling_updateOutput
(
/*long*/
at
::
Tensor
inputSize
,
/*long*/
at
::
Tensor
outputSize
,
/*long*/
at
::
Tensor
&
inputSize
,
/*long*/
at
::
Tensor
&
outputSize
,
/*long*/
at
::
Tensor
poolSize
,
/*long*/
at
::
Tensor
&
poolSize
,
/*long*/
at
::
Tensor
poolStride
,
Metadata
<
Dimension
>
&
m
,
/*long*/
at
::
Tensor
&
poolStride
,
Metadata
<
Dimension
>
&
m
,
/*cuda float*/
at
::
Tensor
input_features
,
/*cuda float*/
at
::
Tensor
&
input_features
,
/*cuda float*/
at
::
Tensor
output_features
,
long
nFeaturesToDrop
)
{
/*cuda float*/
at
::
Tensor
&
output_features
,
long
nFeaturesToDrop
)
{
Int
nPlanes
=
input_features
.
size
(
1
)
-
nFeaturesToDrop
;
Int
nPlanes
=
input_features
.
size
(
1
)
-
nFeaturesToDrop
;
auto
_rules
=
const
auto
&
_rules
=
m
.
getRuleBook
(
outputSize
,
inputSize
,
poolSize
,
poolStride
,
true
);
m
.
getRuleBook
(
outputSize
,
inputSize
,
poolSize
,
poolStride
,
true
);
Int
nActive
=
m
.
getNActive
(
outputSize
);
Int
nActive
=
m
.
getNActive
(
outputSize
);
output_features
.
resize_
({
nActive
,
input_features
.
size
(
1
)
-
nFeaturesToDrop
});
output_features
.
resize_
({
nActive
,
input_features
.
size
(
1
)
-
nFeaturesToDrop
});
...
@@ -37,14 +37,14 @@ void cuda_UnPooling_updateOutput(
...
@@ -37,14 +37,14 @@ void cuda_UnPooling_updateOutput(
template
<
typename
T
,
Int
Dimension
>
template
<
typename
T
,
Int
Dimension
>
void
cuda_UnPooling_updateGradInput
(
void
cuda_UnPooling_updateGradInput
(
/*long*/
at
::
Tensor
inputSize
,
/*long*/
at
::
Tensor
outputSize
,
/*long*/
at
::
Tensor
&
inputSize
,
/*long*/
at
::
Tensor
&
outputSize
,
/*long*/
at
::
Tensor
poolSize
,
/*long*/
at
::
Tensor
&
poolSize
,
/*long*/
at
::
Tensor
poolStride
,
Metadata
<
Dimension
>
&
m
,
/*long*/
at
::
Tensor
&
poolStride
,
Metadata
<
Dimension
>
&
m
,
/*cuda float*/
at
::
Tensor
d_input_features
,
/*cuda float*/
at
::
Tensor
&
d_input_features
,
/*cuda float*/
at
::
Tensor
d_output_features
,
long
nFeaturesToDrop
)
{
/*cuda float*/
at
::
Tensor
&
d_output_features
,
long
nFeaturesToDrop
)
{
Int
nPlanes
=
d_input_features
.
size
(
1
)
-
nFeaturesToDrop
;
Int
nPlanes
=
d_input_features
.
size
(
1
)
-
nFeaturesToDrop
;
auto
_rules
=
const
auto
&
_rules
=
m
.
getRuleBook
(
outputSize
,
inputSize
,
poolSize
,
poolStride
,
true
);
m
.
getRuleBook
(
outputSize
,
inputSize
,
poolSize
,
poolStride
,
true
);
auto
diF
=
d_input_features
.
data
<
T
>
()
+
nFeaturesToDrop
;
auto
diF
=
d_input_features
.
data
<
T
>
()
+
nFeaturesToDrop
;
...
...
sparseconvnet/SCN/Metadata/ConvolutionRules.h
View file @
d8c8a060
...
@@ -15,7 +15,6 @@ void Convolution_InputSgToRulesAndOutputSg(SparseGrid<dimension> &inputGrid,
...
@@ -15,7 +15,6 @@ void Convolution_InputSgToRulesAndOutputSg(SparseGrid<dimension> &inputGrid,
long
*
stride
,
long
*
inputSpatialSize
,
long
*
stride
,
long
*
inputSpatialSize
,
long
*
outputSpatialSize
)
{
long
*
outputSpatialSize
)
{
rules
.
resize
(
volume
<
dimension
>
(
size
));
rules
.
resize
(
volume
<
dimension
>
(
size
));
for
(
auto
const
&
inIter
:
inputGrid
.
mp
)
{
for
(
auto
const
&
inIter
:
inputGrid
.
mp
)
{
auto
outRegion
=
OutputRegionCalculator
<
dimension
>
(
auto
outRegion
=
OutputRegionCalculator
<
dimension
>
(
inIter
.
first
,
size
,
stride
,
outputSpatialSize
);
inIter
.
first
,
size
,
stride
,
outputSpatialSize
);
...
...
sparseconvnet/SCN/Metadata/Metadata.cpp
View file @
d8c8a060
...
@@ -22,7 +22,7 @@ template <Int dimension> SparseGrid<dimension>::SparseGrid() : ctr(0) {
...
@@ -22,7 +22,7 @@ template <Int dimension> SparseGrid<dimension>::SparseGrid() : ctr(0) {
mp
.
set_empty_key
(
empty_key
);
mp
.
set_empty_key
(
empty_key
);
}
}
template
<
typename
T
>
T
*
OptionalTensorData
(
at
::
Tensor
tensor
)
{
template
<
typename
T
>
T
*
OptionalTensorData
(
at
::
Tensor
&
tensor
)
{
return
tensor
.
numel
()
?
tensor
.
data
<
T
>
()
:
nullptr
;
return
tensor
.
numel
()
?
tensor
.
data
<
T
>
()
:
nullptr
;
}
}
...
@@ -30,9 +30,9 @@ template <Int dimension>
...
@@ -30,9 +30,9 @@ template <Int dimension>
void
addPointToSparseGridMapAndFeatures
(
SparseGridMap
<
dimension
>
&
mp
,
void
addPointToSparseGridMapAndFeatures
(
SparseGridMap
<
dimension
>
&
mp
,
Point
<
dimension
>
p
,
Int
&
nActive
,
Point
<
dimension
>
p
,
Int
&
nActive
,
long
nPlanes
,
long
nPlanes
,
/*float*/
at
::
Tensor
features
,
/*float*/
at
::
Tensor
&
features
,
float
*
vec
,
bool
overwrite
)
{
float
*
vec
,
bool
overwrite
)
{
auto
mapVal
=
mp
.
insert
(
std
::
make_pair
(
p
,
nActive
));
auto
mapVal
=
mp
.
insert
(
std
::
make_pair
(
p
,
nActive
));
if
(
mapVal
.
second
)
{
if
(
mapVal
.
second
)
{
nActive
++
;
nActive
++
;
...
@@ -65,16 +65,17 @@ template <Int dimension> void Metadata<dimension>::clear() {
...
@@ -65,16 +65,17 @@ template <Int dimension> void Metadata<dimension>::clear() {
blLayerRuleBook
.
clear
();
blLayerRuleBook
.
clear
();
}
}
template
<
Int
dimension
>
template
<
Int
dimension
>
Int
Metadata
<
dimension
>::
getNActive
(
/*long*/
at
::
Tensor
spatialSize
)
{
Int
Metadata
<
dimension
>::
getNActive
(
/*long*/
at
::
Tensor
&
spatialSize
)
{
return
nActive
[
LongTensorToPoint
<
dimension
>
(
spatialSize
)];
return
nActive
[
LongTensorToPoint
<
dimension
>
(
spatialSize
)];
};
};
template
<
Int
dimension
>
template
<
Int
dimension
>
SparseGrids
<
dimension
>
&
SparseGrids
<
dimension
>
&
Metadata
<
dimension
>::
getSparseGrid
(
/*long*/
at
::
Tensor
spatialSize
)
{
Metadata
<
dimension
>::
getSparseGrid
(
/*long*/
at
::
Tensor
&
spatialSize
)
{
return
grids
[
LongTensorToPoint
<
dimension
>
(
spatialSize
)];
return
grids
[
LongTensorToPoint
<
dimension
>
(
spatialSize
)];
};
};
template
<
Int
dimension
>
template
<
Int
dimension
>
void
Metadata
<
dimension
>::
setInputSpatialSize
(
/*long*/
at
::
Tensor
spatialSize
)
{
void
Metadata
<
dimension
>::
setInputSpatialSize
(
/*long*/
at
::
Tensor
&
spatialSize
)
{
inputSpatialSize
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
inputSpatialSize
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
inputSGs
=
&
grids
[
inputSpatialSize
];
inputSGs
=
&
grids
[
inputSpatialSize
];
inputNActive
=
&
nActive
[
inputSpatialSize
];
inputNActive
=
&
nActive
[
inputSpatialSize
];
...
@@ -85,10 +86,10 @@ template <Int dimension> void Metadata<dimension>::batchAddSample() {
...
@@ -85,10 +86,10 @@ template <Int dimension> void Metadata<dimension>::batchAddSample() {
inputSG
=
&
inputSGs
->
back
();
inputSG
=
&
inputSGs
->
back
();
}
}
template
<
Int
dimension
>
template
<
Int
dimension
>
void
Metadata
<
dimension
>::
setInputSpatialLocation
(
/*float*/
at
::
Tensor
features
,
void
Metadata
<
dimension
>::
setInputSpatialLocation
(
/*lo
ng
*/
at
::
Tensor
location
,
/*
f
lo
at
*/
at
::
Tensor
&
features
,
/*
f
lo
at
*/
at
::
Tensor
vec
,
/*lo
ng
*/
at
::
Tensor
&
location
,
bool
overwrite
)
{
/*float*/
at
::
Tensor
&
vec
,
bool
overwrite
)
{
auto
p
=
LongTensorToPoint
<
dimension
>
(
location
);
auto
p
=
LongTensorToPoint
<
dimension
>
(
location
);
SparseGridMap
<
dimension
>
&
mp
=
inputSG
->
mp
;
SparseGridMap
<
dimension
>
&
mp
=
inputSG
->
mp
;
Int
&
nActive
=
*
inputNActive
;
Int
&
nActive
=
*
inputNActive
;
...
@@ -98,9 +99,9 @@ void Metadata<dimension>::setInputSpatialLocation(/*float*/ at::Tensor features,
...
@@ -98,9 +99,9 @@ void Metadata<dimension>::setInputSpatialLocation(/*float*/ at::Tensor features,
}
}
template
<
Int
dimension
>
template
<
Int
dimension
>
void
Metadata
<
dimension
>::
setInputSpatialLocations
(
void
Metadata
<
dimension
>::
setInputSpatialLocations
(
/*float*/
at
::
Tensor
features
,
/*float*/
at
::
Tensor
&
features
,
/*long*/
at
::
Tensor
locations
,
/*long*/
at
::
Tensor
&
locations
,
/*float*/
at
::
Tensor
vecs
,
bool
overwrite
)
{
/*float*/
at
::
Tensor
&
vecs
,
bool
overwrite
)
{
/* assert(locations.ndimension() == 2 and "locations must be 2
/* assert(locations.ndimension() == 2 and "locations must be 2
* dimensional!"); */
* dimensional!"); */
/* assert(vecs.ndimension() == 2 and "vecs must be 2 dimensional!"); */
/* assert(vecs.ndimension() == 2 and "vecs must be 2 dimensional!"); */
...
@@ -147,7 +148,7 @@ void Metadata<dimension>::setInputSpatialLocations(
...
@@ -147,7 +148,7 @@ void Metadata<dimension>::setInputSpatialLocations(
template
<
Int
dimension
>
template
<
Int
dimension
>
at
::
Tensor
at
::
Tensor
Metadata
<
dimension
>::
getSpatialLocations
(
/*long*/
at
::
Tensor
spatialSize
)
{
Metadata
<
dimension
>::
getSpatialLocations
(
/*long*/
at
::
Tensor
&
spatialSize
)
{
Int
nActive
=
getNActive
(
spatialSize
);
Int
nActive
=
getNActive
(
spatialSize
);
auto
&
SGs
=
getSparseGrid
(
spatialSize
);
auto
&
SGs
=
getSparseGrid
(
spatialSize
);
Int
batchSize
=
SGs
.
size
();
Int
batchSize
=
SGs
.
size
();
...
@@ -169,8 +170,8 @@ Metadata<dimension>::getSpatialLocations(/*long*/ at::Tensor spatialSize) {
...
@@ -169,8 +170,8 @@ Metadata<dimension>::getSpatialLocations(/*long*/ at::Tensor spatialSize) {
}
}
template
<
Int
dimension
>
template
<
Int
dimension
>
void
Metadata
<
dimension
>::
createMetadataForDenseToSparse
(
void
Metadata
<
dimension
>::
createMetadataForDenseToSparse
(
/*long*/
at
::
Tensor
spatialSize
,
/*long*/
at
::
Tensor
&
spatialSize
,
/*long*/
at
::
Tensor
nz_
,
long
batchSize
)
{
/*long*/
at
::
Tensor
&
nz_
,
long
batchSize
)
{
clear
();
clear
();
setInputSpatialSize
(
spatialSize
);
setInputSpatialSize
(
spatialSize
);
inputSGs
->
resize
(
batchSize
);
inputSGs
->
resize
(
batchSize
);
...
@@ -208,9 +209,9 @@ void Metadata<dimension>::createMetadataForDenseToSparse(
...
@@ -208,9 +209,9 @@ void Metadata<dimension>::createMetadataForDenseToSparse(
template
<
Int
dimension
>
template
<
Int
dimension
>
void
Metadata
<
dimension
>::
sparsifyMetadata
(
Metadata
<
dimension
>
&
mOut
,
void
Metadata
<
dimension
>::
sparsifyMetadata
(
Metadata
<
dimension
>
&
mOut
,
/*long*/
at
::
Tensor
spatialSize
,
/*long*/
at
::
Tensor
&
spatialSize
,
/*byte*/
at
::
Tensor
filter
,
/*byte*/
at
::
Tensor
&
filter
,
/*long*/
at
::
Tensor
cuSum
)
{
/*long*/
at
::
Tensor
&
cuSum
)
{
// Create a new SparseGrids with fewer entries.
// Create a new SparseGrids with fewer entries.
mOut
.
clear
();
mOut
.
clear
();
auto
p
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
auto
p
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
...
@@ -240,7 +241,7 @@ void Metadata<dimension>::sparsifyMetadata(Metadata<dimension> &mOut,
...
@@ -240,7 +241,7 @@ void Metadata<dimension>::sparsifyMetadata(Metadata<dimension> &mOut,
template
<
Int
dimension
>
template
<
Int
dimension
>
void
Metadata
<
dimension
>::
appendMetadata
(
Metadata
<
dimension
>
&
mAdd
,
void
Metadata
<
dimension
>::
appendMetadata
(
Metadata
<
dimension
>
&
mAdd
,
/*long*/
at
::
Tensor
spatialSize
)
{
/*long*/
at
::
Tensor
&
spatialSize
)
{
auto
p
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
auto
p
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
auto
&
sgs1
=
grids
[
p
];
auto
&
sgs1
=
grids
[
p
];
auto
&
sgs2
=
mAdd
.
grids
[
p
];
auto
&
sgs2
=
mAdd
.
grids
[
p
];
...
@@ -257,7 +258,7 @@ void Metadata<dimension>::appendMetadata(Metadata<dimension> &mAdd,
...
@@ -257,7 +258,7 @@ void Metadata<dimension>::appendMetadata(Metadata<dimension> &mAdd,
template
<
Int
dimension
>
template
<
Int
dimension
>
std
::
vector
<
at
::
Tensor
>
std
::
vector
<
at
::
Tensor
>
Metadata
<
dimension
>::
sparsifyCompare
(
Metadata
<
dimension
>
&
mGT
,
Metadata
<
dimension
>::
sparsifyCompare
(
Metadata
<
dimension
>
&
mGT
,
/*long*/
at
::
Tensor
spatialSize
)
{
/*long*/
at
::
Tensor
&
spatialSize
)
{
auto
p
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
auto
p
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
at
::
Tensor
gt
=
torch
::
zeros
({
nActive
[
p
]},
at
::
kByte
);
at
::
Tensor
gt
=
torch
::
zeros
({
nActive
[
p
]},
at
::
kByte
);
at
::
Tensor
ref_map
=
torch
::
empty
({
mGT
.
nActive
[
p
]},
at
::
kLong
);
at
::
Tensor
ref_map
=
torch
::
empty
({
mGT
.
nActive
[
p
]},
at
::
kLong
);
...
@@ -288,10 +289,10 @@ Metadata<dimension>::sparsifyCompare(Metadata<dimension> &mGT,
...
@@ -288,10 +289,10 @@ Metadata<dimension>::sparsifyCompare(Metadata<dimension> &mGT,
// size[dimension] == #feature planes
// size[dimension] == #feature planes
template
<
Int
dimension
>
template
<
Int
dimension
>
void
Metadata
<
dimension
>::
addSampleFromThresholdedTensor
(
void
Metadata
<
dimension
>::
addSampleFromThresholdedTensor
(
/*float*/
at
::
Tensor
features_
,
/*float*/
at
::
Tensor
&
features_
,
/*float*/
at
::
Tensor
tensor_
,
/*float*/
at
::
Tensor
&
tensor_
,
/*long*/
at
::
Tensor
offset_
,
/*long*/
at
::
Tensor
&
offset_
,
/*long*/
at
::
Tensor
spatialSize_
,
float
threshold
)
{
/*long*/
at
::
Tensor
&
spatialSize_
,
float
threshold
)
{
auto
&
nActive
=
*
inputNActive
;
auto
&
nActive
=
*
inputNActive
;
auto
&
SGs
=
*
inputSGs
;
auto
&
SGs
=
*
inputSGs
;
...
@@ -404,8 +405,8 @@ template <Int dimension> void Metadata<dimension>::generateRuleBooks2s2() {
...
@@ -404,8 +405,8 @@ template <Int dimension> void Metadata<dimension>::generateRuleBooks2s2() {
}
}
template
<
Int
dimension
>
template
<
Int
dimension
>
void
Metadata
<
dimension
>::
inputLayer
(
/*long*/
at
::
Tensor
spatialSize
,
void
Metadata
<
dimension
>::
inputLayer
(
/*long*/
at
::
Tensor
&
spatialSize
,
/*long*/
at
::
Tensor
coords
,
Int
batchSize
,
/*long*/
at
::
Tensor
&
coords
,
Int
batchSize
,
Int
mode
)
{
Int
mode
)
{
assert
(
spatialSize
.
ndimension
()
==
1
);
assert
(
spatialSize
.
ndimension
()
==
1
);
assert
(
spatialSize
.
size
(
0
)
==
dimension
);
assert
(
spatialSize
.
size
(
0
)
==
dimension
);
...
@@ -417,8 +418,8 @@ void Metadata<dimension>::inputLayer(/*long*/ at::Tensor spatialSize,
...
@@ -417,8 +418,8 @@ void Metadata<dimension>::inputLayer(/*long*/ at::Tensor spatialSize,
*
inputNActive
);
*
inputNActive
);
}
}
template
<
Int
dimension
>
template
<
Int
dimension
>
void
Metadata
<
dimension
>::
blLayer
(
/*long*/
at
::
Tensor
spatialSize
,
void
Metadata
<
dimension
>::
blLayer
(
/*long*/
at
::
Tensor
&
spatialSize
,
/*long*/
at
::
Tensor
coords
,
Int
mode
)
{
/*long*/
at
::
Tensor
&
coords
,
Int
mode
)
{
assert
(
spatialSize
.
ndimension
()
==
1
);
assert
(
spatialSize
.
ndimension
()
==
1
);
assert
(
spatialSize
.
size
(
0
)
==
dimension
);
assert
(
spatialSize
.
size
(
0
)
==
dimension
);
assert
(
coords
.
ndimension
()
==
3
);
assert
(
coords
.
ndimension
()
==
3
);
...
@@ -429,8 +430,8 @@ void Metadata<dimension>::blLayer(/*long*/ at::Tensor spatialSize,
...
@@ -429,8 +430,8 @@ void Metadata<dimension>::blLayer(/*long*/ at::Tensor spatialSize,
}
}
template
<
Int
dimension
>
template
<
Int
dimension
>
RuleBook
&
Metadata
<
dimension
>::
getSubmanifoldRuleBook
(
RuleBook
&
Metadata
<
dimension
>::
getSubmanifoldRuleBook
(
/*long*/
at
::
Tensor
spatialSize
,
/*long*/
at
::
Tensor
&
spatialSize
,
/*long*/
at
::
Tensor
size
,
bool
openMP
)
{
/*long*/
at
::
Tensor
&
size
,
bool
openMP
)
{
auto
p
=
TwoLongTensorsToPoint
<
dimension
>
(
spatialSize
,
size
);
auto
p
=
TwoLongTensorsToPoint
<
dimension
>
(
spatialSize
,
size
);
auto
&
rb
=
submanifoldRuleBooks
[
p
];
auto
&
rb
=
submanifoldRuleBooks
[
p
];
if
(
rb
.
empty
())
{
if
(
rb
.
empty
())
{
...
@@ -444,7 +445,7 @@ RuleBook &Metadata<dimension>::getSubmanifoldRuleBook(
...
@@ -444,7 +445,7 @@ RuleBook &Metadata<dimension>::getSubmanifoldRuleBook(
}
}
template
<
Int
dimension
>
template
<
Int
dimension
>
RuleBook
&
Metadata
<
dimension
>::
getPermutohedralSubmanifoldRuleBook
(
RuleBook
&
Metadata
<
dimension
>::
getPermutohedralSubmanifoldRuleBook
(
/*long*/
at
::
Tensor
spatialSize
,
bool
openMP
)
{
/*long*/
at
::
Tensor
&
spatialSize
,
bool
openMP
)
{
auto
p
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
auto
p
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
auto
&
rb
=
permutohedralRuleBooks
[
p
];
auto
&
rb
=
permutohedralRuleBooks
[
p
];
if
(
rb
.
empty
())
{
if
(
rb
.
empty
())
{
...
@@ -458,7 +459,7 @@ RuleBook &Metadata<dimension>::getPermutohedralSubmanifoldRuleBook(
...
@@ -458,7 +459,7 @@ RuleBook &Metadata<dimension>::getPermutohedralSubmanifoldRuleBook(
}
}
template
<
Int
dimension
>
template
<
Int
dimension
>
RuleBook
&
Metadata
<
dimension
>::
getActivePoolingRuleBook
(
RuleBook
&
Metadata
<
dimension
>::
getActivePoolingRuleBook
(
/*long*/
at
::
Tensor
spatialSize
)
{
/*long*/
at
::
Tensor
&
spatialSize
)
{
auto
spatialSz
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
auto
spatialSz
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
auto
&
SGs
=
grids
[
spatialSz
];
auto
&
SGs
=
grids
[
spatialSz
];
auto
&
rb
=
activePoolingRuleBooks
[
spatialSz
];
auto
&
rb
=
activePoolingRuleBooks
[
spatialSz
];
...
@@ -468,7 +469,7 @@ RuleBook &Metadata<dimension>::getActivePoolingRuleBook(
...
@@ -468,7 +469,7 @@ RuleBook &Metadata<dimension>::getActivePoolingRuleBook(
}
}
template
<
Int
dimension
>
template
<
Int
dimension
>
RuleBook
&
Metadata
<
dimension
>::
getSparseToDenseRuleBook
(
RuleBook
&
Metadata
<
dimension
>::
getSparseToDenseRuleBook
(
/*long*/
at
::
Tensor
spatialSize
,
bool
openMP
)
{
/*long*/
at
::
Tensor
&
spatialSize
,
bool
openMP
)
{
auto
ss
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
auto
ss
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
auto
&
SGs
=
grids
[
ss
];
auto
&
SGs
=
grids
[
ss
];
auto
&
rb
=
sparseToDenseRuleBooks
[
ss
];
auto
&
rb
=
sparseToDenseRuleBooks
[
ss
];
...
@@ -484,10 +485,10 @@ RuleBook &Metadata<dimension>::getSparseToDenseRuleBook(
...
@@ -484,10 +485,10 @@ RuleBook &Metadata<dimension>::getSparseToDenseRuleBook(
}
}
template
<
Int
dimension
>
template
<
Int
dimension
>
RuleBook
&
Metadata
<
dimension
>::
getRuleBook
(
RuleBook
&
Metadata
<
dimension
>::
getRuleBook
(
/*long*/
at
::
Tensor
inputSpatialSize
,
/*long*/
at
::
Tensor
&
inputSpatialSize
,
/*long*/
at
::
Tensor
outputSpatialSize
,
/*long*/
at
::
Tensor
&
outputSpatialSize
,
/*long*/
at
::
Tensor
size
,
/*long*/
at
::
Tensor
&
size
,
/*long*/
at
::
Tensor
stride
,
bool
openMP
)
{
/*long*/
at
::
Tensor
&
stride
,
bool
openMP
)
{
auto
p
=
ThreeLongTensorsToPoint
<
dimension
>
(
inputSpatialSize
,
size
,
stride
);
auto
p
=
ThreeLongTensorsToPoint
<
dimension
>
(
inputSpatialSize
,
size
,
stride
);
auto
&
rb
=
ruleBooks
[
p
];
auto
&
rb
=
ruleBooks
[
p
];
if
(
rb
.
empty
())
{
if
(
rb
.
empty
())
{
...
@@ -511,10 +512,10 @@ RuleBook &Metadata<dimension>::getRuleBook(
...
@@ -511,10 +512,10 @@ RuleBook &Metadata<dimension>::getRuleBook(
}
}
template
<
Int
dimension
>
template
<
Int
dimension
>
RuleBook
&
Metadata
<
dimension
>::
getFullConvolutionRuleBook
(
RuleBook
&
Metadata
<
dimension
>::
getFullConvolutionRuleBook
(
/*long*/
at
::
Tensor
inputSpatialSize
,
/*long*/
at
::
Tensor
&
inputSpatialSize
,
/*long*/
at
::
Tensor
outputSpatialSize
,
/*long*/
at
::
Tensor
&
outputSpatialSize
,
/*long*/
at
::
Tensor
size
,
/*long*/
at
::
Tensor
&
size
,
/*long*/
at
::
Tensor
stride
,
Metadata
<
dimension
>
&
newM
)
{
/*long*/
at
::
Tensor
&
stride
,
Metadata
<
dimension
>
&
newM
)
{
auto
&
rb
=
newM
.
fullConvolutionRuleBook
;
auto
&
rb
=
newM
.
fullConvolutionRuleBook
;
if
(
rb
.
empty
())
{
if
(
rb
.
empty
())
{
newM
.
clear
();
newM
.
clear
();
...
@@ -533,10 +534,10 @@ RuleBook &Metadata<dimension>::getFullConvolutionRuleBook(
...
@@ -533,10 +534,10 @@ RuleBook &Metadata<dimension>::getFullConvolutionRuleBook(
template
<
Int
dimension
>
template
<
Int
dimension
>
RuleBook
&
Metadata
<
dimension
>::
getRandomizedStrideRuleBook
(
RuleBook
&
Metadata
<
dimension
>::
getRandomizedStrideRuleBook
(
/*long*/
at
::
Tensor
inputSpatialSize
,
/*long*/
at
::
Tensor
&
inputSpatialSize
,
/*long*/
at
::
Tensor
outputSpatialSize
,
/*long*/
at
::
Tensor
&
outputSpatialSize
,
/*long*/
at
::
Tensor
size
,
/*long*/
at
::
Tensor
&
size
,
/*long*/
at
::
Tensor
stride
,
bool
openMP
)
{
/*long*/
at
::
Tensor
&
stride
,
bool
openMP
)
{
auto
p
=
ThreeLongTensorsToPoint
<
dimension
>
(
inputSpatialSize
,
size
,
stride
);
auto
p
=
ThreeLongTensorsToPoint
<
dimension
>
(
inputSpatialSize
,
size
,
stride
);
auto
&
rb
=
ruleBooks
[
p
];
auto
&
rb
=
ruleBooks
[
p
];
if
(
rb
.
empty
())
{
if
(
rb
.
empty
())
{
...
@@ -577,7 +578,7 @@ at::Tensor vvl2t(std::vector<std::vector<long>> v) {
...
@@ -577,7 +578,7 @@ at::Tensor vvl2t(std::vector<std::vector<long>> v) {
template
<
Int
dimension
>
template
<
Int
dimension
>
std
::
vector
<
at
::
Tensor
>
std
::
vector
<
at
::
Tensor
>
Metadata
<
dimension
>::
compareSparseHelper
(
Metadata
<
dimension
>
&
mR
,
Metadata
<
dimension
>::
compareSparseHelper
(
Metadata
<
dimension
>
&
mR
,
/* long */
at
::
Tensor
spatialSize
)
{
/* long */
at
::
Tensor
&
spatialSize
)
{
auto
p
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
auto
p
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
auto
&
sgsL
=
grids
[
p
];
auto
&
sgsL
=
grids
[
p
];
auto
&
sgsR
=
mR
.
grids
[
p
];
auto
&
sgsR
=
mR
.
grids
[
p
];
...
@@ -624,7 +625,7 @@ at::Tensor vvl2t_(std::vector<std::vector<Int>> v) {
...
@@ -624,7 +625,7 @@ at::Tensor vvl2t_(std::vector<std::vector<Int>> v) {
template
<
Int
dimension
>
template
<
Int
dimension
>
at
::
Tensor
at
::
Tensor
Metadata
<
dimension
>::
copyFeaturesHelper
(
Metadata
<
dimension
>
&
mR
,
Metadata
<
dimension
>::
copyFeaturesHelper
(
Metadata
<
dimension
>
&
mR
,
/* long */
at
::
Tensor
spatialSize
)
{
/* long */
at
::
Tensor
&
spatialSize
)
{
auto
p
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
auto
p
=
LongTensorToPoint
<
dimension
>
(
spatialSize
);
auto
&
sgsL
=
grids
[
p
];
auto
&
sgsL
=
grids
[
p
];
auto
&
sgsR
=
mR
.
grids
[
p
];
auto
&
sgsR
=
mR
.
grids
[
p
];
...
...
sparseconvnet/SCN/Metadata/Metadata.h
View file @
d8c8a060
...
@@ -38,7 +38,7 @@ template <Int dimension>
...
@@ -38,7 +38,7 @@ template <Int dimension>
void
addPointToSparseGridMapAndFeatures
(
SparseGridMap
<
dimension
>
&
mp
,
void
addPointToSparseGridMapAndFeatures
(
SparseGridMap
<
dimension
>
&
mp
,
Point
<
dimension
>
p
,
Int
&
nActive
,
Point
<
dimension
>
p
,
Int
&
nActive
,
long
nPlanes
,
long
nPlanes
,
/*float*/
at
::
Tensor
features
,
/*float*/
at
::
Tensor
&
features
,
float
*
vec
,
bool
overwrite
);
float
*
vec
,
bool
overwrite
);
template
<
Int
dimension
>
class
Metadata
{
template
<
Int
dimension
>
class
Metadata
{
...
@@ -81,45 +81,47 @@ public:
...
@@ -81,45 +81,47 @@ public:
Metadata
();
Metadata
();
void
clear
();
void
clear
();
Int
getNActive
(
/*long*/
at
::
Tensor
spatialSize
);
Int
getNActive
(
/*long*/
at
::
Tensor
&
spatialSize
);
SparseGrids
<
dimension
>
&
getSparseGrid
(
/*long*/
at
::
Tensor
spatialSize
);
SparseGrids
<
dimension
>
&
getSparseGrid
(
/*long*/
at
::
Tensor
&
spatialSize
);
void
setInputSpatialSize
(
/*long*/
at
::
Tensor
spatialSize
);
void
setInputSpatialSize
(
/*long*/
at
::
Tensor
&
spatialSize
);
void
batchAddSample
();
void
batchAddSample
();
void
setInputSpatialLocation
(
/*float*/
at
::
Tensor
features
,
void
setInputSpatialLocation
(
/*float*/
at
::
Tensor
&
features
,
/*long*/
at
::
Tensor
location
,
/*long*/
at
::
Tensor
&
location
,
/*float*/
at
::
Tensor
vec
,
bool
overwrite
);
/*float*/
at
::
Tensor
&
vec
,
bool
overwrite
);
void
setInputSpatialLocations
(
/*float*/
at
::
Tensor
features
,
void
setInputSpatialLocations
(
/*float*/
at
::
Tensor
&
features
,
/*long*/
at
::
Tensor
locations
,
/*long*/
at
::
Tensor
&
locations
,
/*float*/
at
::
Tensor
vecs
,
bool
overwrite
);
/*float*/
at
::
Tensor
&
vecs
,
bool
overwrite
);
at
::
Tensor
getSpatialLocations
(
/*long*/
at
::
Tensor
spatialSize
);
at
::
Tensor
getSpatialLocations
(
/*long*/
at
::
Tensor
&
spatialSize
);
void
createMetadataForDenseToSparse
(
/*long*/
at
::
Tensor
spatialSize
,
void
createMetadataForDenseToSparse
(
/*long*/
at
::
Tensor
&
spatialSize
,
/*long*/
at
::
Tensor
nz_
,
long
batchSize
);
/*long*/
at
::
Tensor
&
nz_
,
long
batchSize
);
void
sparsifyMetadata
(
Metadata
<
dimension
>
&
mOut
,
void
sparsifyMetadata
(
Metadata
<
dimension
>
&
mOut
,
/*long*/
at
::
Tensor
spatialSize
,
/*long*/
at
::
Tensor
&
spatialSize
,
/*byte*/
at
::
Tensor
filter
,
/*byte*/
at
::
Tensor
&
filter
,
/*long*/
at
::
Tensor
cuSum
);
/*long*/
at
::
Tensor
&
cuSum
);
void
appendMetadata
(
Metadata
<
dimension
>
&
mAdd
,
void
appendMetadata
(
Metadata
<
dimension
>
&
mAdd
,
/*long*/
at
::
Tensor
spatialSize
);
/*long*/
at
::
Tensor
&
spatialSize
);
/* std::vector<at::Tensor> sparsifyCompare(Metadata<dimension> &mReference, */
/* std::vector<at::Tensor &> sparsifyCompare(Metadata<dimension> &mReference,
*/
/* Metadata<dimension> &mSparsified,
/* Metadata<dimension> &mSparsified,
*/
*/
/* /\*long*\/ at::Tensor spatialSize);
/* /\*long*\/ at::Tensor &
* spatialSize);
*/
*/
std
::
vector
<
at
::
Tensor
>
sparsifyCompare
(
Metadata
<
dimension
>
&
mReference
,
std
::
vector
<
at
::
Tensor
>
sparsifyCompare
(
Metadata
<
dimension
>
&
mReference
,
/*long*/
at
::
Tensor
spatialSize
);
/*long*/
at
::
Tensor
&
spatialSize
);
// tensor is size[0] x .. x size[dimension-1] x size[dimension]
// tensor is size[0] x .. x size[dimension-1] x size[dimension]
// size[0] x .. x size[dimension-1] == spatial volume
// size[0] x .. x size[dimension-1] == spatial volume
// size[dimension] == #feature planes
// size[dimension] == #feature planes
void
addSampleFromThresholdedTensor
(
/*float*/
at
::
Tensor
features_
,
void
addSampleFromThresholdedTensor
(
/*float*/
at
::
Tensor
&
features_
,
/*float*/
at
::
Tensor
tensor_
,
/*float*/
at
::
Tensor
&
tensor_
,
/*long*/
at
::
Tensor
offset_
,
/*long*/
at
::
Tensor
&
offset_
,
/*long*/
at
::
Tensor
spatialSize_
,
/*long*/
at
::
Tensor
&
spatialSize_
,
float
threshold
);
float
threshold
);
// 3x3 submanifold convolutions, 3x3/2x2 pooling or strided convolutions
// 3x3 submanifold convolutions, 3x3/2x2 pooling or strided convolutions
...
@@ -128,41 +130,42 @@ public:
...
@@ -128,41 +130,42 @@ public:
// 3x3 submanifold convolutions, 2x2 pooling or strided convolutions
// 3x3 submanifold convolutions, 2x2 pooling or strided convolutions
void
generateRuleBooks2s2
();
void
generateRuleBooks2s2
();
void
inputLayer
(
/*long*/
at
::
Tensor
spatialSize
,
void
inputLayer
(
/*long*/
at
::
Tensor
&
spatialSize
,
/*long*/
at
::
Tensor
coords
,
Int
batchSize
,
Int
mode
);
/*long*/
at
::
Tensor
&
coords
,
Int
batchSize
,
Int
mode
);
void
blLayer
(
/*long*/
at
::
Tensor
spatialSize
,
/*long*/
at
::
Tensor
coords
,
void
blLayer
(
/*long*/
at
::
Tensor
&
spatialSize
,
/*long*/
at
::
Tensor
&
coords
,
Int
mode
);
Int
mode
);
RuleBook
&
getSubmanifoldRuleBook
(
/*long*/
at
::
Tensor
spatialSize
,
RuleBook
&
getSubmanifoldRuleBook
(
/*long*/
at
::
Tensor
&
spatialSize
,
/*long*/
at
::
Tensor
size
,
bool
openMP
);
/*long*/
at
::
Tensor
&
size
,
bool
openMP
);
RuleBook
&
getPermutohedralSubmanifoldRuleBook
(
/*long*/
at
::
Tensor
spatialSize
,
RuleBook
&
bool
openMP
);
getPermutohedralSubmanifoldRuleBook
(
/*long*/
at
::
Tensor
&
spatialSize
,
RuleBook
&
getActivePoolingRuleBook
(
/*long*/
at
::
Tensor
spatialSize
);
bool
openMP
);
RuleBook
&
getSparseToDenseRuleBook
(
/*long*/
at
::
Tensor
spatialSize
,
RuleBook
&
getActivePoolingRuleBook
(
/*long*/
at
::
Tensor
&
spatialSize
);
RuleBook
&
getSparseToDenseRuleBook
(
/*long*/
at
::
Tensor
&
spatialSize
,
bool
openMP
);
bool
openMP
);
RuleBook
&
getRuleBook
(
/*long*/
at
::
Tensor
inputSpatialSize
,
RuleBook
&
getRuleBook
(
/*long*/
at
::
Tensor
&
inputSpatialSize
,
/*long*/
at
::
Tensor
outputSpatialSize
,
/*long*/
at
::
Tensor
&
outputSpatialSize
,
/*long*/
at
::
Tensor
size
,
/*long*/
at
::
Tensor
&
size
,
/*long*/
at
::
Tensor
stride
,
bool
openMP
);
/*long*/
at
::
Tensor
&
stride
,
bool
openMP
);
RuleBook
&
getFullConvolutionRuleBook
(
/*long*/
at
::
Tensor
inputSpatialSize
,
RuleBook
&
getFullConvolutionRuleBook
(
/*long*/
at
::
Tensor
&
inputSpatialSize
,
/*long*/
at
::
Tensor
outputSpatialSize
,
/*long*/
at
::
Tensor
&
outputSpatialSize
,
/*long*/
at
::
Tensor
size
,
/*long*/
at
::
Tensor
&
size
,
/*long*/
at
::
Tensor
stride
,
/*long*/
at
::
Tensor
&
stride
,
Metadata
<
dimension
>
&
newM
);
Metadata
<
dimension
>
&
newM
);
RuleBook
&
getRandomizedStrideRuleBook
(
/*long*/
at
::
Tensor
inputSpatialSize
,
RuleBook
&
getRandomizedStrideRuleBook
(
/*long*/
at
::
Tensor
&
inputSpatialSize
,
/*long*/
at
::
Tensor
outputSpatialSize
,
/*long*/
at
::
Tensor
&
outputSpatialSize
,
/*long*/
at
::
Tensor
size
,
/*long*/
at
::
Tensor
&
size
,
/*long*/
at
::
Tensor
stride
,
/*long*/
at
::
Tensor
&
stride
,
bool
openMP
);
bool
openMP
);
std
::
vector
<
at
::
Tensor
>
std
::
vector
<
at
::
Tensor
>
compareSparseHelper
(
Metadata
<
dimension
>
&
mR
,
compareSparseHelper
(
Metadata
<
dimension
>
&
mR
,
/* long */
at
::
Tensor
spatialSize
);
/* long */
at
::
Tensor
&
spatialSize
);
at
::
Tensor
copyFeaturesHelper
(
Metadata
<
dimension
>
&
mR
,
at
::
Tensor
copyFeaturesHelper
(
Metadata
<
dimension
>
&
mR
,
/* long */
at
::
Tensor
spatialSize
);
/* long */
at
::
Tensor
&
spatialSize
);
};
};
template
<
typename
T
>
T
*
OptionalTensorData
(
at
::
Tensor
tensor
);
template
<
typename
T
>
T
*
OptionalTensorData
(
at
::
Tensor
&
tensor
);
template
<
Int
dimension
>
Int
volume
(
long
*
point
);
template
<
Int
dimension
>
Int
volume
(
long
*
point
);
#endif
#endif
sparseconvnet/SCN/cuda.cu
View file @
d8c8a060
...
@@ -23,12 +23,12 @@
...
@@ -23,12 +23,12 @@
template
void
ActivePooling_ForwardPass
<
float
>(
float
*
input_features
,
template
void
ActivePooling_ForwardPass
<
float
>(
float
*
input_features
,
float
*
output_features
,
float
*
output_features
,
Int
batchSize
,
Int
maxActive
,
Int
batchSize
,
Int
maxActive
,
Int
nPlanes
,
Int
*
rules
,
Int
nPlanes
,
const
Int
*
rules
,
bool
average
);
bool
average
);
template
void
ActivePooling_BackwardPass
<
float
>(
float
*
d_input_features
,
template
void
ActivePooling_BackwardPass
<
float
>(
float
*
d_input_features
,
float
*
d_output_features
,
float
*
d_output_features
,
Int
batchSize
,
Int
maxActive
,
Int
batchSize
,
Int
maxActive
,
Int
nPlanes
,
Int
*
rules
,
Int
nPlanes
,
const
Int
*
rules
,
bool
average
);
bool
average
);
template
void
dAffineReluTrivialConvolution_forward
<
float
>(
template
void
dAffineReluTrivialConvolution_forward
<
float
>(
...
...
sparseconvnet/SCN/misc/drawCurve.cpp
View file @
d8c8a060
...
@@ -7,9 +7,9 @@
...
@@ -7,9 +7,9 @@
// Helper function to draw pen strokes with
// Helper function to draw pen strokes with
// nPlanes = 3, feature vector = (1,dx,dy)
// nPlanes = 3, feature vector = (1,dx,dy)
void
cpu_float_DrawCurve_2
(
Metadata
<
2
>
&
m
,
void
cpu_float_DrawCurve_2
(
Metadata
<
2
>
&
m
,
/*float*/
at
::
Tensor
features
,
/*float*/
at
::
Tensor
&
features
,
/*float*/
at
::
Tensor
stroke
)
{
/*float*/
at
::
Tensor
&
stroke
)
{
at
::
Tensor
location
=
at
::
zeros
(
at
::
CPU
(
at
::
kLong
),
{
2
});
at
::
Tensor
&
location
=
at
::
zeros
(
at
::
CPU
(
at
::
kLong
),
{
2
});
auto
location_
=
location
.
data
<
long
>
();
auto
location_
=
location
.
data
<
long
>
();
auto
vec
=
at
::
zeros
(
at
::
CPU
(
at
::
kFloat
),
{
3
});
auto
vec
=
at
::
zeros
(
at
::
CPU
(
at
::
kFloat
),
{
3
});
...
...
sparseconvnet/SCN/pybind.cpp
View file @
d8c8a060
...
@@ -31,168 +31,168 @@ template <Int Dimension> void dimension(py::module &m, const char *name) {
...
@@ -31,168 +31,168 @@ template <Int Dimension> void dimension(py::module &m, const char *name) {
.
def
(
"compareSparseHelper"
,
&
Metadata
<
Dimension
>::
compareSparseHelper
)
.
def
(
"compareSparseHelper"
,
&
Metadata
<
Dimension
>::
compareSparseHelper
)
.
def
(
"copyFeaturesHelper"
,
&
Metadata
<
Dimension
>::
copyFeaturesHelper
);
.
def
(
"copyFeaturesHelper"
,
&
Metadata
<
Dimension
>::
copyFeaturesHelper
);
m
.
def
(
"ActivePooling_updateOutput"
,
m
.
def
(
"ActivePooling_updateOutput"
,
(
void
(
*
)(
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
bool
))
&
bool
))
&
ActivePooling_updateOutput
,
ActivePooling_updateOutput
,
""
);
""
);
m
.
def
(
"ActivePooling_updateGradInput"
,
m
.
def
(
"ActivePooling_updateGradInput"
,
(
void
(
*
)(
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
,
bool
))
&
at
::
Tensor
&
,
bool
))
&
ActivePooling_updateGradInput
,
ActivePooling_updateGradInput
,
""
);
""
);
m
.
def
(
"AveragePooling_updateOutput"
,
m
.
def
(
"AveragePooling_updateOutput"
,
(
void
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
long
))
&
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
long
))
&
AveragePooling_updateOutput
,
AveragePooling_updateOutput
,
""
);
""
);
m
.
def
(
"AveragePooling_updateGradInput"
,
m
.
def
(
"AveragePooling_updateGradInput"
,
(
void
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
long
))
&
long
))
&
AveragePooling_updateGradInput
,
AveragePooling_updateGradInput
,
""
);
""
);
m
.
def
(
"Convolution_updateOutput"
,
m
.
def
(
"Convolution_updateOutput"
,
(
double
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
double
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
))
&
at
::
Tensor
&
))
&
Convolution_updateOutput
,
Convolution_updateOutput
,
""
);
""
);
m
.
def
(
"Convolution_backward"
,
m
.
def
(
"Convolution_backward"
,
(
void
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
))
&
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
))
&
Convolution_backward
,
Convolution_backward
,
""
);
""
);
m
.
def
(
"RandomizedStrideConvolution_updateOutput"
,
m
.
def
(
"RandomizedStrideConvolution_updateOutput"
,
(
double
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
double
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
))
&
at
::
Tensor
&
))
&
RandomizedStrideConvolution_updateOutput
,
RandomizedStrideConvolution_updateOutput
,
""
);
""
);
m
.
def
(
"RandomizedStrideConvolution_backward"
,
m
.
def
(
"RandomizedStrideConvolution_backward"
,
(
void
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
))
&
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
))
&
RandomizedStrideConvolution_backward
,
RandomizedStrideConvolution_backward
,
""
);
""
);
m
.
def
(
"Deconvolution_updateOutput"
,
m
.
def
(
"Deconvolution_updateOutput"
,
(
double
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
double
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
))
&
at
::
Tensor
&
))
&
Deconvolution_updateOutput
,
Deconvolution_updateOutput
,
""
);
""
);
m
.
def
(
"Deconvolution_backward"
,
m
.
def
(
"Deconvolution_backward"
,
(
void
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
))
&
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
))
&
Deconvolution_backward
,
Deconvolution_backward
,
""
);
""
);
m
.
def
(
"FullConvolution_updateOutput"
,
m
.
def
(
"FullConvolution_updateOutput"
,
(
double
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
double
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
))
&
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
))
&
FullConvolution_updateOutput
,
FullConvolution_updateOutput
,
""
);
""
);
m
.
def
(
"FullConvolution_backward"
,
m
.
def
(
"FullConvolution_backward"
,
(
void
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
))
&
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
))
&
FullConvolution_backward
,
FullConvolution_backward
,
""
);
""
);
m
.
def
(
"MaxPooling_updateOutput"
,
m
.
def
(
"MaxPooling_updateOutput"
,
(
void
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
long
))
&
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
long
))
&
MaxPooling_updateOutput
,
MaxPooling_updateOutput
,
""
);
""
);
m
.
def
(
"MaxPooling_updateGradInput"
,
m
.
def
(
"MaxPooling_updateGradInput"
,
(
void
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
,
long
))
&
at
::
Tensor
&
,
long
))
&
MaxPooling_updateGradInput
,
MaxPooling_updateGradInput
,
""
);
""
);
m
.
def
(
"RandomizedStrideMaxPooling_updateOutput"
,
m
.
def
(
"RandomizedStrideMaxPooling_updateOutput"
,
(
void
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
long
))
&
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
long
))
&
RandomizedStrideMaxPooling_updateOutput
,
RandomizedStrideMaxPooling_updateOutput
,
""
);
""
);
m
.
def
(
"RandomizedStrideMaxPooling_updateGradInput"
,
m
.
def
(
"RandomizedStrideMaxPooling_updateGradInput"
,
(
void
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
,
long
))
&
at
::
Tensor
&
,
long
))
&
RandomizedStrideMaxPooling_updateGradInput
,
RandomizedStrideMaxPooling_updateGradInput
,
""
);
""
);
m
.
def
(
"SparseToDense_updateOutput"
,
m
.
def
(
"SparseToDense_updateOutput"
,
(
void
(
*
)(
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
long
))
&
long
))
&
SparseToDense_updateOutput
,
SparseToDense_updateOutput
,
""
);
""
);
m
.
def
(
"SparseToDense_updateGradInput"
,
m
.
def
(
"SparseToDense_updateGradInput"
,
(
void
(
*
)(
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
))
&
at
::
Tensor
&
))
&
SparseToDense_updateGradInput
,
SparseToDense_updateGradInput
,
""
);
""
);
m
.
def
(
"SubmanifoldConvolution_updateOutput"
,
m
.
def
(
"SubmanifoldConvolution_updateOutput"
,
(
double
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
(
double
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
))
&
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
))
&
SubmanifoldConvolution_updateOutput
,
SubmanifoldConvolution_updateOutput
,
""
);
""
);
m
.
def
(
"SubmanifoldConvolution_backward"
,
m
.
def
(
"SubmanifoldConvolution_backward"
,
(
void
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
))
&
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
))
&
SubmanifoldConvolution_backward
,
SubmanifoldConvolution_backward
,
""
);
""
);
m
.
def
(
"PermutohedralSubmanifoldConvolution_updateOutput"
,
m
.
def
(
"PermutohedralSubmanifoldConvolution_updateOutput"
,
(
double
(
*
)(
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
(
double
(
*
)(
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
,
at
::
Tensor
))
&
at
::
Tensor
&
,
at
::
Tensor
&
))
&
PermutohedralSubmanifoldConvolution_updateOutput
,
PermutohedralSubmanifoldConvolution_updateOutput
,
""
);
""
);
m
.
def
(
"PermutohedralSubmanifoldConvolution_backward"
,
m
.
def
(
"PermutohedralSubmanifoldConvolution_backward"
,
(
void
(
*
)(
at
::
Tensor
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
))
&
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
))
&
PermutohedralSubmanifoldConvolution_backward
,
PermutohedralSubmanifoldConvolution_backward
,
""
);
""
);
m
.
def
(
"InputLayer_updateOutput"
,
m
.
def
(
"InputLayer_updateOutput"
,
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
,
long
,
long
))
&
at
::
Tensor
&
,
long
,
long
))
&
InputLayer_updateOutput
,
InputLayer_updateOutput
,
""
);
""
);
m
.
def
(
"InputLayer_updateGradInput"
,
m
.
def
(
"InputLayer_updateGradInput"
,
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
))
&
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
))
&
InputLayer_updateGradInput
,
InputLayer_updateGradInput
,
""
);
""
);
m
.
def
(
"OutputLayer_updateOutput"
,
m
.
def
(
"OutputLayer_updateOutput"
,
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
))
&
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
))
&
OutputLayer_updateOutput
,
OutputLayer_updateOutput
,
""
);
""
);
m
.
def
(
"OutputLayer_updateGradInput"
,
m
.
def
(
"OutputLayer_updateGradInput"
,
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
))
&
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
))
&
OutputLayer_updateGradInput
,
OutputLayer_updateGradInput
,
""
);
""
);
m
.
def
(
"BLInputLayer_updateOutput"
,
m
.
def
(
"BLInputLayer_updateOutput"
,
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
,
long
))
&
at
::
Tensor
&
,
long
))
&
BLInputLayer_updateOutput
,
BLInputLayer_updateOutput
,
""
);
""
);
m
.
def
(
"BLInputLayer_updateGradInput"
,
m
.
def
(
"BLInputLayer_updateGradInput"
,
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
))
&
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
))
&
BLInputLayer_updateGradInput
,
BLInputLayer_updateGradInput
,
""
);
""
);
m
.
def
(
"BLOutputLayer_updateOutput"
,
m
.
def
(
"BLOutputLayer_updateOutput"
,
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
))
&
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
))
&
BLOutputLayer_updateOutput
,
BLOutputLayer_updateOutput
,
""
);
""
);
m
.
def
(
"BLOutputLayer_updateGradInput"
,
m
.
def
(
"BLOutputLayer_updateGradInput"
,
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
))
&
(
void
(
*
)(
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
))
&
BLOutputLayer_updateGradInput
,
BLOutputLayer_updateGradInput
,
""
);
""
);
m
.
def
(
"UnPooling_updateOutput"
,
m
.
def
(
"UnPooling_updateOutput"
,
(
void
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
long
))
&
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
long
))
&
UnPooling_updateOutput
,
UnPooling_updateOutput
,
""
);
""
);
m
.
def
(
"UnPooling_updateGradInput"
,
m
.
def
(
"UnPooling_updateGradInput"
,
(
void
(
*
)(
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
at
::
Tensor
,
(
void
(
*
)(
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
Metadata
<
Dimension
>
&
,
at
::
Tensor
,
at
::
Tensor
,
long
))
&
Metadata
<
Dimension
>
&
,
at
::
Tensor
&
,
at
::
Tensor
&
,
long
))
&
UnPooling_updateGradInput
,
UnPooling_updateGradInput
,
""
);
""
);
}
}
...
...
sparseconvnet/SCN/sparseconvnet.h
View file @
d8c8a060
This diff is collapsed.
Click to expand it.
sparseconvnet/SCN/sparseconvnet_cpu.cpp
View file @
d8c8a060
This diff is collapsed.
Click to expand it.
sparseconvnet/SCN/sparseconvnet_cuda.cpp
View file @
d8c8a060
This diff is collapsed.
Click to expand it.
Prev
1
2
Next
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