Commit 954223a2 authored by Benjamin Thomas Graham's avatar Benjamin Thomas Graham
Browse files

make SCN proper submodule

parent 19aca522
...@@ -23,13 +23,13 @@ setup( ...@@ -23,13 +23,13 @@ setup(
url='https://github.com/facebookresearch/SparseConvNet', url='https://github.com/facebookresearch/SparseConvNet',
packages=['sparseconvnet','sparseconvnet.SCN'], packages=['sparseconvnet','sparseconvnet.SCN'],
ext_modules=[ ext_modules=[
CUDAExtension('sparseconvnet_SCN', CUDAExtension('sparseconvnet.SCN',
[ [
'sparseconvnet/SCN/cuda.cu', 'sparseconvnet/SCN/sparseconvnet_cuda.cpp', 'sparseconvnet/SCN/pybind.cpp'], 'sparseconvnet/SCN/cuda.cu', 'sparseconvnet/SCN/sparseconvnet_cuda.cpp', 'sparseconvnet/SCN/pybind.cpp'],
include_dirs=[conda_include_dir, this_dir+'/sparseconvnet/SCN/'], include_dirs=[conda_include_dir, this_dir+'/sparseconvnet/SCN/'],
extra_compile_args=extra) extra_compile_args=extra)
if torch.cuda.is_available() else if torch.cuda.is_available() else
CppExtension('sparseconvnet_SCN', CppExtension('sparseconvnet.SCN',
['sparseconvnet/SCN/pybind.cpp', 'sparseconvnet/SCN/sparseconvnet_cpu.cpp'], ['sparseconvnet/SCN/pybind.cpp', 'sparseconvnet/SCN/sparseconvnet_cpu.cpp'],
include_dirs=[conda_include_dir, this_dir+'/sparseconvnet/SCN/'], include_dirs=[conda_include_dir, this_dir+'/sparseconvnet/SCN/'],
extra_compile_args=extra['cxx'])], extra_compile_args=extra['cxx'])],
......
...@@ -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.
import sparseconvnet_SCN import sparseconvnet.SCN
from torch.autograd import Function from torch.autograd import Function
from torch.nn import Module from torch.nn import Module
from .utils import * from .utils import *
...@@ -82,7 +82,7 @@ class AveragePoolingFunction(Function): ...@@ -82,7 +82,7 @@ class AveragePoolingFunction(Function):
ctx.nFeaturesToDrop = nFeaturesToDrop ctx.nFeaturesToDrop = nFeaturesToDrop
output_features = input_features.new() output_features = input_features.new()
sparseconvnet_SCN.AveragePooling_updateOutput( sparseconvnet.SCN.AveragePooling_updateOutput(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
pool_size, pool_size,
...@@ -109,7 +109,7 @@ class AveragePoolingFunction(Function): ...@@ -109,7 +109,7 @@ class AveragePoolingFunction(Function):
pool_size,\ pool_size,\
pool_stride = ctx.saved_tensors pool_stride = ctx.saved_tensors
grad_input = grad_output.new() grad_input = grad_output.new()
sparseconvnet_SCN.AveragePooling_updateGradInput( sparseconvnet.SCN.AveragePooling_updateGradInput(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
pool_size, pool_size,
......
...@@ -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.
import sparseconvnet_SCN import sparseconvnet.SCN
from torch.autograd import Function from torch.autograd import Function
from torch.nn import Module, Parameter from torch.nn import Module, Parameter
from .utils import * from .utils import *
...@@ -107,7 +107,7 @@ class BatchNormalizationFunction(Function): ...@@ -107,7 +107,7 @@ class BatchNormalizationFunction(Function):
output_features = input_features.new() output_features = input_features.new()
saveMean = input_features.new().resize_(ctx.nPlanes) saveMean = input_features.new().resize_(ctx.nPlanes)
saveInvStd = runningMean.clone().resize_(ctx.nPlanes) saveInvStd = runningMean.clone().resize_(ctx.nPlanes)
sparseconvnet_SCN.BatchNormalization_updateOutput( sparseconvnet.SCN.BatchNormalization_updateOutput(
input_features, input_features,
output_features, output_features,
saveMean, saveMean,
...@@ -144,7 +144,7 @@ class BatchNormalizationFunction(Function): ...@@ -144,7 +144,7 @@ class BatchNormalizationFunction(Function):
grad_input = grad_output.new() grad_input = grad_output.new()
grad_weight = torch.zeros_like(weight) grad_weight = torch.zeros_like(weight)
grad_bias = torch.zeros_like(bias) grad_bias = torch.zeros_like(bias)
sparseconvnet_SCN.BatchNormalization_backward( sparseconvnet.SCN.BatchNormalization_backward(
input_features, input_features,
grad_input, grad_input,
output_features, output_features,
......
...@@ -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.
import sparseconvnet, sparseconvnet_SCN import sparseconvnet, sparseconvnet.SCN
from torch.autograd import Function from torch.autograd import Function
from torch.nn import Module, Parameter from torch.nn import Module, Parameter
from .utils import * from .utils import *
...@@ -91,7 +91,7 @@ class ConvolutionFunction(Function): ...@@ -91,7 +91,7 @@ class ConvolutionFunction(Function):
filter_size, filter_size,
filter_stride) filter_stride)
sparseconvnet.forward_pass_multiplyAdd_count +=\ sparseconvnet.forward_pass_multiplyAdd_count +=\
sparseconvnet_SCN.Convolution_updateOutput( sparseconvnet.SCN.Convolution_updateOutput(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
filter_size, filter_size,
...@@ -110,7 +110,7 @@ class ConvolutionFunction(Function): ...@@ -110,7 +110,7 @@ class ConvolutionFunction(Function):
grad_input = grad_output.new() grad_input = grad_output.new()
grad_weight = torch.zeros_like(weight) grad_weight = torch.zeros_like(weight)
grad_bias = torch.zeros_like(bias) grad_bias = torch.zeros_like(bias)
sparseconvnet_SCN.Convolution_backward( sparseconvnet.SCN.Convolution_backward(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
filter_size, filter_size,
......
...@@ -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.
import sparseconvnet, sparseconvnet_SCN import sparseconvnet, sparseconvnet.SCN
from torch.autograd import Function from torch.autograd import Function
from torch.nn import Module, Parameter from torch.nn import Module, Parameter
from .utils import * from .utils import *
...@@ -105,7 +105,7 @@ class DeconvolutionFunction(Function): ...@@ -105,7 +105,7 @@ class DeconvolutionFunction(Function):
ctx.dimension = dimension ctx.dimension = dimension
sparseconvnet.forward_pass_multiplyAdd_count +=\ sparseconvnet.forward_pass_multiplyAdd_count +=\
sparseconvnet_SCN.Deconvolution_updateOutput( sparseconvnet.SCN.Deconvolution_updateOutput(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
filter_size, filter_size,
...@@ -139,7 +139,7 @@ class DeconvolutionFunction(Function): ...@@ -139,7 +139,7 @@ class DeconvolutionFunction(Function):
grad_input = grad_output.new() grad_input = grad_output.new()
grad_weight = torch.zeros_like(weight) grad_weight = torch.zeros_like(weight)
grad_bias = torch.zeros_like(bias) grad_bias = torch.zeros_like(bias)
sparseconvnet_SCN.Deconvolution_backward( sparseconvnet.SCN.Deconvolution_backward(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
filter_size, filter_size,
......
...@@ -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.
import sparseconvnet, sparseconvnet_SCN import sparseconvnet, sparseconvnet.SCN
from torch.autograd import Function, Variable from torch.autograd import Function, Variable
from torch.nn import Module, Parameter from torch.nn import Module, Parameter
from .utils import * from .utils import *
...@@ -115,7 +115,7 @@ class FullConvolutionFunction(Function): ...@@ -115,7 +115,7 @@ class FullConvolutionFunction(Function):
filter_size, filter_size,
filter_stride) filter_stride)
sparseconvnet.forward_pass_multiplyAdd_count +=\ sparseconvnet.forward_pass_multiplyAdd_count +=\
sparseconvnet_SCN.FullConvolution_updateOutput( sparseconvnet.SCN.FullConvolution_updateOutput(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
filter_size, filter_size,
...@@ -134,7 +134,7 @@ class FullConvolutionFunction(Function): ...@@ -134,7 +134,7 @@ class FullConvolutionFunction(Function):
grad_input = grad_output.new() grad_input = grad_output.new()
grad_weight = torch.zeros_like(weight) grad_weight = torch.zeros_like(weight)
grad_bias = torch.zeros_like(bias) grad_bias = torch.zeros_like(bias)
sparseconvnet_SCN.FullConvolution_backward( sparseconvnet.SCN.FullConvolution_backward(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
filter_size, filter_size,
......
...@@ -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.
import sparseconvnet_SCN import sparseconvnet.SCN
from torch.autograd import Function from torch.autograd import Function
from torch.nn import Module, Parameter from torch.nn import Module, Parameter
from .utils import * from .utils import *
...@@ -165,7 +165,7 @@ class InputLayerFunction(Function): ...@@ -165,7 +165,7 @@ class InputLayerFunction(Function):
output_features = input_features.new() output_features = input_features.new()
ctx.dimension = dimension ctx.dimension = dimension
ctx.metadata_ = metadata ctx.metadata_ = metadata
sparseconvnet_SCN.InputLayer_updateOutput( sparseconvnet.SCN.InputLayer_updateOutput(
metadata, metadata,
spatial_size, spatial_size,
coords, coords,
...@@ -179,7 +179,7 @@ class InputLayerFunction(Function): ...@@ -179,7 +179,7 @@ class InputLayerFunction(Function):
@staticmethod @staticmethod
def backward(ctx, grad_output): def backward(ctx, grad_output):
grad_input = grad_output.new() grad_input = grad_output.new()
sparseconvnet_SCN.InputLayer_updateGradInput( sparseconvnet.SCN.InputLayer_updateGradInput(
ctx.metadata_, ctx.metadata_,
grad_input, grad_input,
grad_output.contiguous()) grad_output.contiguous())
...@@ -196,7 +196,7 @@ class OutputLayerFunction(Function): ...@@ -196,7 +196,7 @@ class OutputLayerFunction(Function):
output_features = input_features.new() output_features = input_features.new()
ctx.metadata_ = metadata ctx.metadata_ = metadata
ctx.dimension = dimension ctx.dimension = dimension
sparseconvnet_SCN.OutputLayer_updateOutput( sparseconvnet.SCN.OutputLayer_updateOutput(
metadata, metadata,
input_features.contiguous(), input_features.contiguous(),
output_features output_features
...@@ -207,7 +207,7 @@ class OutputLayerFunction(Function): ...@@ -207,7 +207,7 @@ class OutputLayerFunction(Function):
def backward(ctx, grad_output): def backward(ctx, grad_output):
grad_input = grad_output.new() grad_input = grad_output.new()
grad_output=grad_output.contiguous() grad_output=grad_output.contiguous()
sparseconvnet_SCN.OutputLayer_updateGradInput( sparseconvnet.SCN.OutputLayer_updateGradInput(
ctx.metadata_, ctx.metadata_,
grad_input, grad_input,
grad_output.contiguous()) grad_output.contiguous())
...@@ -227,7 +227,7 @@ class BLInputLayerFunction(Function): ...@@ -227,7 +227,7 @@ class BLInputLayerFunction(Function):
output_features = input_features.new() output_features = input_features.new()
ctx.metadata_ = metadata ctx.metadata_ = metadata
ctx.dimension = dimension ctx.dimension = dimension
sparseconvnet_SCN.BLInputLayer_updateOutput( sparseconvnet.SCN.BLInputLayer_updateOutput(
metadata, metadata,
spatial_size, spatial_size,
coords, coords,
...@@ -240,7 +240,7 @@ class BLInputLayerFunction(Function): ...@@ -240,7 +240,7 @@ class BLInputLayerFunction(Function):
@staticmethod @staticmethod
def backward(ctx, grad_output): def backward(ctx, grad_output):
grad_input = grad_output.new() grad_input = grad_output.new()
sparseconvnet_SCN.BLInputLayer_updateGradInput( sparseconvnet.SCN.BLInputLayer_updateGradInput(
ctx.metadata_, ctx.metadata_,
grad_input, grad_input,
grad_output.contiguous()) grad_output.contiguous())
...@@ -257,7 +257,7 @@ class BLOutputLayerFunction(Function): ...@@ -257,7 +257,7 @@ class BLOutputLayerFunction(Function):
output_features = input_features.new() output_features = input_features.new()
ctx.metadata_ = metadata ctx.metadata_ = metadata
ctx.dimension = dimension ctx.dimension = dimension
sparseconvnet_SCN.BLOutputLayer_updateOutput( sparseconvnet.SCN.BLOutputLayer_updateOutput(
metadata, metadata,
input_features.contiguous(), input_features.contiguous(),
output_features output_features
...@@ -267,7 +267,7 @@ class BLOutputLayerFunction(Function): ...@@ -267,7 +267,7 @@ class BLOutputLayerFunction(Function):
@staticmethod @staticmethod
def backward(ctx, grad_output): def backward(ctx, grad_output):
grad_input = grad_output.new() grad_input = grad_output.new()
sparseconvnet_SCN.BLOutputLayer_updateGradInput( sparseconvnet.SCN.BLOutputLayer_updateGradInput(
ctx.metadata_, ctx.metadata_,
grad_input, grad_input,
grad_output.contiguous()) grad_output.contiguous())
......
...@@ -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.
import sparseconvnet_SCN import sparseconvnet.SCN
from torch.autograd import Function from torch.autograd import Function
from torch.nn import Module from torch.nn import Module
from .utils import * from .utils import *
...@@ -27,7 +27,7 @@ class MaxPoolingFunction(Function): ...@@ -27,7 +27,7 @@ class MaxPoolingFunction(Function):
ctx.dimension = dimension ctx.dimension = dimension
ctx.nFeaturesToDrop = nFeaturesToDrop ctx.nFeaturesToDrop = nFeaturesToDrop
output_features = input_features.new() output_features = input_features.new()
sparseconvnet_SCN.MaxPooling_updateOutput( sparseconvnet.SCN.MaxPooling_updateOutput(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
pool_size, pool_size,
...@@ -54,7 +54,7 @@ class MaxPoolingFunction(Function): ...@@ -54,7 +54,7 @@ class MaxPoolingFunction(Function):
pool_size,\ pool_size,\
pool_stride = ctx.saved_tensors pool_stride = ctx.saved_tensors
grad_input = grad_output.new() grad_input = grad_output.new()
sparseconvnet_SCN.MaxPooling_updateGradInput( sparseconvnet.SCN.MaxPooling_updateGradInput(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
pool_size, pool_size,
......
...@@ -11,7 +11,7 @@ all coexist within the same MetaData object as long as each spatial size ...@@ -11,7 +11,7 @@ all coexist within the same MetaData object as long as each spatial size
only occurs once. only occurs once.
""" """
import sparseconvnet_SCN import sparseconvnet.SCN
def Metadata(dim): def Metadata(dim):
return getattr(sparseconvnet_SCN, 'Metadata_%d'%dim)() return getattr(sparseconvnet.SCN, 'Metadata_%d'%dim)()
...@@ -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.
import sparseconvnet, sparseconvnet_SCN import sparseconvnet, sparseconvnet.SCN
from torch.autograd import Function from torch.autograd import Function
from torch.nn import Module, Parameter from torch.nn import Module, Parameter
from .utils import * from .utils import *
...@@ -24,7 +24,7 @@ class NetworkInNetworkFunction(Function): ...@@ -24,7 +24,7 @@ class NetworkInNetworkFunction(Function):
weight, weight,
bias) bias)
sparseconvnet.forward_pass_multiplyAdd_count +=\ sparseconvnet.forward_pass_multiplyAdd_count +=\
sparseconvnet_SCN.NetworkInNetwork_updateOutput( sparseconvnet.SCN.NetworkInNetwork_updateOutput(
input_features, input_features,
output_features, output_features,
weight, weight,
...@@ -44,11 +44,11 @@ class NetworkInNetworkFunction(Function): ...@@ -44,11 +44,11 @@ class NetworkInNetworkFunction(Function):
grad_bias = None grad_bias = None
else: else:
grad_bias = torch.zeros_like(bias) grad_bias = torch.zeros_like(bias)
sparseconvnet_SCN.NetworkInNetwork_updateGradInput( sparseconvnet.SCN.NetworkInNetwork_updateGradInput(
grad_input, grad_input,
grad_output, grad_output,
weight) weight)
sparseconvnet_SCN.NetworkInNetwork_accGradParameters( sparseconvnet.SCN.NetworkInNetwork_accGradParameters(
input_features, input_features,
grad_output, grad_output,
grad_weight, grad_weight,
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
# LICENSE file in the root directory of this source tree. # LICENSE file in the root directory of this source tree.
import sparseconvnet import sparseconvnet
import sparseconvnet_SCN import sparseconvnet.SCN
from torch.autograd import Function from torch.autograd import Function
from torch.nn import Module, Parameter from torch.nn import Module, Parameter
from .utils import * from .utils import *
...@@ -82,7 +82,7 @@ class PermutohedralSubmanifoldConvolutionFunction(Function): ...@@ -82,7 +82,7 @@ class PermutohedralSubmanifoldConvolutionFunction(Function):
bias) bias)
sparseconvnet.forward_pass_multiplyAdd_count +=\ sparseconvnet.forward_pass_multiplyAdd_count +=\
sparseconvnet_SCN.PermutohedralSubmanifoldConvolution_updateOutput( sparseconvnet.SCN.PermutohedralSubmanifoldConvolution_updateOutput(
spatial_size, spatial_size,
input_metadata, input_metadata,
input_features, input_features,
...@@ -98,7 +98,7 @@ class PermutohedralSubmanifoldConvolutionFunction(Function): ...@@ -98,7 +98,7 @@ class PermutohedralSubmanifoldConvolutionFunction(Function):
grad_input = grad_output.new() grad_input = grad_output.new()
grad_weight = torch.zeros_like(weight) grad_weight = torch.zeros_like(weight)
grad_bias = torch.zeros_like(bias) grad_bias = torch.zeros_like(bias)
sparseconvnet_SCN.PermutohedralSubmanifoldConvolution_backward( sparseconvnet.SCN.PermutohedralSubmanifoldConvolution_backward(
spatial_size, spatial_size,
ctx.input_metadata, ctx.input_metadata,
input_features, input_features,
......
...@@ -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.
import sparseconvnet, sparseconvnet_SCN import sparseconvnet, sparseconvnet.SCN
from torch.autograd import Function from torch.autograd import Function
from torch.nn import Module, Parameter from torch.nn import Module, Parameter
from .utils import * from .utils import *
...@@ -104,7 +104,7 @@ class RandomizedStrideConvolutionFunction(Function): ...@@ -104,7 +104,7 @@ class RandomizedStrideConvolutionFunction(Function):
filter_size, filter_size,
filter_stride) filter_stride)
sparseconvnet.forward_pass_multiplyAdd_count +=\ sparseconvnet.forward_pass_multiplyAdd_count +=\
sparseconvnet_SCN.RandomizedStrideConvolution_updateOutput( sparseconvnet.SCN.RandomizedStrideConvolution_updateOutput(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
filter_size, filter_size,
...@@ -124,7 +124,7 @@ class RandomizedStrideConvolutionFunction(Function): ...@@ -124,7 +124,7 @@ class RandomizedStrideConvolutionFunction(Function):
grad_input = grad_output.new() grad_input = grad_output.new()
grad_weight = torch.zeros_like(weight) grad_weight = torch.zeros_like(weight)
grad_bias = torch.zeros_like(bias) grad_bias = torch.zeros_like(bias)
sparseconvnet_SCN.RandomizedStrideConvolution_backward( sparseconvnet.SCN.RandomizedStrideConvolution_backward(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
filter_size, filter_size,
......
...@@ -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.
import sparseconvnet_SCN import sparseconvnet.SCN
from torch.autograd import Function from torch.autograd import Function
from torch.nn import Module from torch.nn import Module
from .utils import * from .utils import *
...@@ -27,7 +27,7 @@ class RandomizedStrideMaxPoolingFunction(Function): ...@@ -27,7 +27,7 @@ class RandomizedStrideMaxPoolingFunction(Function):
ctx.dimension = dimension ctx.dimension = dimension
ctx.nFeaturesToDrop = nFeaturesToDrop ctx.nFeaturesToDrop = nFeaturesToDrop
output_features = input_features.new() output_features = input_features.new()
sparseconvnet_SCN.RandomizedStrideMaxPooling_updateOutput( sparseconvnet.SCN.RandomizedStrideMaxPooling_updateOutput(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
pool_size, pool_size,
...@@ -54,7 +54,7 @@ class RandomizedStrideMaxPoolingFunction(Function): ...@@ -54,7 +54,7 @@ class RandomizedStrideMaxPoolingFunction(Function):
pool_size,\ pool_size,\
pool_stride = ctx.saved_tensors pool_stride = ctx.saved_tensors
grad_input = grad_output.new() grad_input = grad_output.new()
sparseconvnet_SCN.RandomizedStrideMaxPooling_updateGradInput( sparseconvnet.SCN.RandomizedStrideMaxPooling_updateGradInput(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
pool_size, pool_size,
......
...@@ -15,7 +15,7 @@ Parameters: ...@@ -15,7 +15,7 @@ Parameters:
dimension : of the input field, dimension : of the input field,
""" """
import sparseconvnet_SCN import sparseconvnet.SCN
from torch.autograd import Function from torch.autograd import Function
from torch.nn import Module from torch.nn import Module
from .utils import * from .utils import *
...@@ -35,7 +35,7 @@ class SparseToDenseFunction(Function): ...@@ -35,7 +35,7 @@ class SparseToDenseFunction(Function):
ctx.dimension = dimension ctx.dimension = dimension
ctx.save_for_backward(input_features, spatial_size) ctx.save_for_backward(input_features, spatial_size)
output = input_features.new() output = input_features.new()
sparseconvnet_SCN.SparseToDense_updateOutput( sparseconvnet.SCN.SparseToDense_updateOutput(
spatial_size, spatial_size,
input_metadata, input_metadata,
input_features, input_features,
...@@ -47,7 +47,7 @@ class SparseToDenseFunction(Function): ...@@ -47,7 +47,7 @@ class SparseToDenseFunction(Function):
def backward(ctx, grad_output): def backward(ctx, grad_output):
grad_input = grad_output.new() grad_input = grad_output.new()
input_features, spatial_size = ctx.saved_tensors input_features, spatial_size = ctx.saved_tensors
sparseconvnet_SCN.SparseToDense_updateGradInput( sparseconvnet.SCN.SparseToDense_updateGradInput(
spatial_size, spatial_size,
ctx.input_metadata, ctx.input_metadata,
input_features, input_features,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
# 'SubmanifoldConvolution == SubmanifoldConvolution' # 'SubmanifoldConvolution == SubmanifoldConvolution'
import sparseconvnet import sparseconvnet
import sparseconvnet_SCN import sparseconvnet.SCN
from torch.autograd import Function from torch.autograd import Function
from torch.nn import Module, Parameter from torch.nn import Module, Parameter
from .utils import * from .utils import *
...@@ -84,7 +84,7 @@ class SubmanifoldConvolutionFunction(Function): ...@@ -84,7 +84,7 @@ class SubmanifoldConvolutionFunction(Function):
filter_size) filter_size)
sparseconvnet.forward_pass_multiplyAdd_count +=\ sparseconvnet.forward_pass_multiplyAdd_count +=\
sparseconvnet_SCN.SubmanifoldConvolution_updateOutput( sparseconvnet.SCN.SubmanifoldConvolution_updateOutput(
spatial_size, spatial_size,
filter_size, filter_size,
input_metadata, input_metadata,
...@@ -101,7 +101,7 @@ class SubmanifoldConvolutionFunction(Function): ...@@ -101,7 +101,7 @@ class SubmanifoldConvolutionFunction(Function):
grad_input = grad_output.new() grad_input = grad_output.new()
grad_weight = torch.zeros_like(weight) grad_weight = torch.zeros_like(weight)
grad_bias = torch.zeros_like(bias) grad_bias = torch.zeros_like(bias)
sparseconvnet_SCN.SubmanifoldConvolution_backward( sparseconvnet.SCN.SubmanifoldConvolution_backward(
spatial_size, spatial_size,
filter_size, filter_size,
ctx.input_metadata, ctx.input_metadata,
......
...@@ -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.
import sparseconvnet_SCN import sparseconvnet.SCN
from torch.autograd import Function, Variable from torch.autograd import Function, Variable
from torch.nn import Module from torch.nn import Module
from .utils import * from .utils import *
...@@ -31,7 +31,7 @@ class UnPoolingFunction(Function): ...@@ -31,7 +31,7 @@ class UnPoolingFunction(Function):
ctx.pool_stride = pool_stride ctx.pool_stride = pool_stride
ctx.nFeaturesToDrop = nFeaturesToDrop ctx.nFeaturesToDrop = nFeaturesToDrop
output_features = input_features.new() output_features = input_features.new()
sparseconvnet_SCN.UnPooling_updateOutput( sparseconvnet.SCN.UnPooling_updateOutput(
input_spatial_size, input_spatial_size,
output_spatial_size, output_spatial_size,
pool_size, pool_size,
...@@ -45,7 +45,7 @@ class UnPoolingFunction(Function): ...@@ -45,7 +45,7 @@ class UnPoolingFunction(Function):
@staticmethod @staticmethod
def backward(ctx, grad_output): def backward(ctx, grad_output):
grad_input=Variable(grad_output.data.new()) grad_input=Variable(grad_output.data.new())
sparseconvnet_SCN.UnPooling_updateGradInput( sparseconvnet.SCN.UnPooling_updateGradInput(
ctx.input_spatial_size, ctx.input_spatial_size,
ctx.output_spatial_size, ctx.output_spatial_size,
ctx.pool_size, ctx.pool_size,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment