unroll_patch=None, imshp_logical=imshp_logical, kshp_logical=None, version=-1, direction_hint='bprop inputs') din = din(topgrad, filters) copy_stack_trace(node.outputs[0], din) din = theano.tensor.patternbroadcast(din, node.outputs[0].broadcastable) copy_stack_trace(node.outputs[0], din) return [din] # Register Cpu Optmization conv_groupopt = theano.gof.optdb.LocalGroupDB() conv_groupopt.__name__ = "conv_opts" register_specialize_device(conv_groupopt, 'fast_compile', 'fast_run') # GEMM-based convolution # It can be disabled by excluding 'conv_gemm'. conv_groupopt.register('local_abstractconv_gemm', local_abstractconv_gemm, 30, 'conv_gemm', 'fast_compile', 'fast_run') conv_groupopt.register('local_abstractconv_gradweight_gemm', local_abstractconv_gradweight_gemm, 30, 'conv_gemm', 'fast_compile', 'fast_run') conv_groupopt.register('local_abstractconv_gradinputs_gemm', local_abstractconv_gradinputs_gemm, 30, 'conv_gemm', 'fast_compile', 'fast_run') # Legacy convolution conv_groupopt.register('local_conv2d_cpu', local_conv2d_cpu, 40, 'fast_compile', 'fast_run') conv_groupopt.register('local_conv2d_gradweight_cpu',
if node.op.border_mode not in ['full', 'valid']: return None if not node.op.filter_flip: # Not tested yet return None rval = cpu_conv2d(img, kern, node.op.imshp, node.op.kshp, border_mode=node.op.border_mode, subsample=node.op.subsample) return [rval] register_specialize_device(local_conv2d_cpu, 'fast_compile') @local_optimizer([AbstractConv2d_gradWeights]) def local_conv2d_gradweight_cpu(node): img, topgrad, shape = node.inputs if ((not isinstance(img.type, TensorType) or not isinstance(topgrad.type, TensorType))): return None if node.op.border_mode not in ['full', 'valid']: return None if not node.op.filter_flip: # Not tested yet return
imshp_logical=imshp_logical, kshp_logical=None, version=-1, direction_hint="bprop inputs", ) din = din(topgrad, filters) copy_stack_trace(node.outputs[0], din) din = theano.tensor.patternbroadcast(din, node.outputs[0].broadcastable) copy_stack_trace(node.outputs[0], din) return [din] # Register Cpu Optmization conv_groupopt = theano.gof.optdb.LocalGroupDB() conv_groupopt.__name__ = "conv_opts" register_specialize_device(conv_groupopt, "fast_compile", "fast_run") # GEMM-based convolution # It can be disabled by excluding 'conv_gemm'. conv_groupopt.register( "local_abstractconv_gemm", local_abstractconv_gemm, 30, "conv_gemm", "fast_compile", "fast_run", ) conv_groupopt.register( "local_abstractconv_gradweight_gemm", local_abstractconv_gradweight_gemm, 30,
img, kern = node.inputs if ((not isinstance(img.type, TensorType) or not isinstance(kern.type, TensorType))): return None if node.op.border_mode not in ['full', 'valid']: return None if not node.op.filter_flip: # Not tested yet return None rval = cpu_conv2d(img, kern, node.op.imshp, node.op.kshp, border_mode=node.op.border_mode, subsample=node.op.subsample) return [rval] register_specialize_device(local_conv2d_cpu, 'fast_compile') @local_optimizer([AbstractConv2d_gradWeights]) def local_conv2d_gradweight_cpu(node): img, topgrad, shape = node.inputs if ((not isinstance(img.type, TensorType) or not isinstance(topgrad.type, TensorType))): return None if node.op.border_mode not in ['full', 'valid']: return None if not node.op.filter_flip: # Not tested yet return