提交 0e91b48b authored 作者: Nicolas Ballas's avatar Nicolas Ballas 提交者: Pascal Lamblin

small fix

上级 6178a7a9
...@@ -330,11 +330,7 @@ class AbstractConv2d_gradInputs(BaseAbstractConv2d): ...@@ -330,11 +330,7 @@ class AbstractConv2d_gradInputs(BaseAbstractConv2d):
return [[1], [1], [0]] # no connection to height, width return [[1], [1], [0]] # no connection to height, width
### Optimizations should be move in their appropriate files ### Move to Gpu optimization
### move to Gpu optimization
### Do not replace the AbstractOpt only the inputs
### Abstract Ops is replaced layer by device_specialized opt
@local_optimizer([gpu_from_host, @local_optimizer([gpu_from_host,
AbstractConv2d, AbstractConv2d_gradWeights, AbstractConv2d_gradInputs]) AbstractConv2d, AbstractConv2d_gradWeights, AbstractConv2d_gradInputs])
def local_conv2d_gpu_conv(node): def local_conv2d_gpu_conv(node):
...@@ -344,12 +340,8 @@ def local_conv2d_gpu_conv(node): ...@@ -344,12 +340,8 @@ def local_conv2d_gpu_conv(node):
AbstractConv(host_from_gpu) -> host_from_gpu(AbstractConv) AbstractConv(host_from_gpu) -> host_from_gpu(AbstractConv)
""" """
if isinstance(node.op, GpuFromHost): if isinstance(node.op, GpuFromHost):
#gpu_from_host(conv) -> gpu_conv(gpu_from_host)
host_input = node.inputs[0] host_input = node.inputs[0]
if host_input.owner and \ if host_input.owner and isinstance(host_input.owner.op, BaseAbstractConv2d):
(isinstance(host_input.owner.op, AbstractConv2d) or
isinstance(host_input.owner.op, AbstractConv2d_gradWeights) or
isinstance(host_input.owner.op, AbstractConv2d_gradInputs)):
conv = host_input.owner.op conv = host_input.owner.op
inps = list(host_input.owner.inputs) inps = list(host_input.owner.inputs)
...@@ -361,9 +353,7 @@ def local_conv2d_gpu_conv(node): ...@@ -361,9 +353,7 @@ def local_conv2d_gpu_conv(node):
out.values_eq_approx = values_eq_approx_high_tol out.values_eq_approx = values_eq_approx_high_tol
return [out] return [out]
if (isinstance(node.op, AbstractConv2d) or if isinstance(node.op, BaseAbstractConv2d):
isinstance(node.op, AbstractConv2d_gradWeights) or
isinstance(node.op, AbstractConv2d_gradInputs)):
#conv(host_from_gpu) -> host_from_gpu(gpu_conv) #conv(host_from_gpu) -> host_from_gpu(gpu_conv)
inp1 = node.inputs[0] inp1 = node.inputs[0]
inp2 = node.inputs[1] inp2 = node.inputs[1]
...@@ -385,7 +375,7 @@ register_gpu()(local_conv2d_gpu_conv) ...@@ -385,7 +375,7 @@ register_gpu()(local_conv2d_gpu_conv)
### Call dnn conv class directly ### Cudnn Opt
@local_optimizer([AbstractConv2d, AbstractConv2d_gradWeights, AbstractConv2d_gradInputs]) @local_optimizer([AbstractConv2d, AbstractConv2d_gradWeights, AbstractConv2d_gradInputs])
def local_conv2d_cudnn(node): def local_conv2d_cudnn(node):
...@@ -425,7 +415,7 @@ def local_conv2d_cudnn(node): ...@@ -425,7 +415,7 @@ def local_conv2d_cudnn(node):
return [rval] return [rval]
register_specialize_device(local_conv2d_cudnn, 'cudnn') register_specialize_device(local_conv2d_cudnn, 'cudnn')
### Corrmm opt
@local_optimizer([AbstractConv2d]) @local_optimizer([AbstractConv2d])
def local_conv2d_corrmm(node): def local_conv2d_corrmm(node):
...@@ -521,7 +511,6 @@ register_specialize_device(local_conv2d_gradinputs_corrmm, 'conv_gemm') ...@@ -521,7 +511,6 @@ register_specialize_device(local_conv2d_gradinputs_corrmm, 'conv_gemm')
### Cpu Optmization ### Cpu Optmization
### Desactived focus on GPU optimization first
@local_optimizer([AbstractConv2d]) @local_optimizer([AbstractConv2d])
def local_conv2d_cpu(node): def local_conv2d_cpu(node):
...@@ -532,6 +521,11 @@ def local_conv2d_cpu(node): ...@@ -532,6 +521,11 @@ def local_conv2d_cpu(node):
if isinstance(img.type, CudaNdarrayType) or \ if isinstance(img.type, CudaNdarrayType) or \
isinstance(kern.type, CudaNdarrayType): isinstance(kern.type, CudaNdarrayType):
return None return None
if node.op.border_mode not in ['full', 'valid']:
return None
if not node.op.filters_flip:
# Not tested yet
return None
rval = cpu_conv2d(img, kern, rval = cpu_conv2d(img, kern,
node.op.imshp, node.op.kshp, node.op.imshp, node.op.kshp,
...@@ -551,7 +545,6 @@ def local_conv2d_gradweight_cpu(node): ...@@ -551,7 +545,6 @@ def local_conv2d_gradweight_cpu(node):
return None return None
if node.op.border_mode not in ['full', 'valid']: if node.op.border_mode not in ['full', 'valid']:
return None return None
if not node.op.filters_flip: if not node.op.filters_flip:
# Not tested yet # Not tested yet
return return
...@@ -640,10 +633,8 @@ def local_conv2d_gradinputs_cpu(node): ...@@ -640,10 +633,8 @@ def local_conv2d_gradinputs_cpu(node):
if isinstance(kern.type, CudaNdarrayType) or \ if isinstance(kern.type, CudaNdarrayType) or \
isinstance(topgrad.type, CudaNdarrayType): isinstance(topgrad.type, CudaNdarrayType):
return None return None
if node.op.border_mode not in ['full', 'valid']: if node.op.border_mode not in ['full', 'valid']:
return None return None
if not node.op.filters_flip: if not node.op.filters_flip:
# Not tested yet # Not tested yet
return None return None
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论