提交 b079a529 authored 作者: David Warde-Farley's avatar David Warde-Farley

PEP3113 tuple parameter unpacking for pycuda_example and scan.

上级 bc3bd4ee
......@@ -124,9 +124,10 @@ class PycudaElemwiseSourceModuleOp(Op):
self.pycuda_fct = mod.get_function(fct_name)
return out_node
def perform(self, node, inputs, (z,)):
def perform(self, node, inputs, out):
#TODO support broadcast!
#TODO assert all input have the same shape
z, = out
if z[0] is None or z[0].shape!=inputs[0].shape:
z[0] = theano.sandbox.cuda.CudaNdarray.zeros(inputs[0].shape)
self.pycuda_fct(inputs[0],inputs[1],z[0], block=(inputs[0].shape[0],inputs[0].shape[1],1))
......@@ -191,8 +192,9 @@ class PycudaElemwiseKernelOp(Op):
#include <numpy/arrayobject.h>""")
return out_node
def perform(self, node, inputs, (z,)):
def perform(self, node, inputs, out):
#TODO assert all input have the same shape
z, = out
if z[0] is None or z[0].shape!=inputs[0].shape:
z[0] = theano.sandbox.cuda.CudaNdarray.zeros(inputs[0].shape)
i = inputs + z
......
......@@ -1062,7 +1062,7 @@ class Scan(Op):
# OLD DOCUMENTATION CAN BE FOUND NEAR REVISION 2581
#
def __init__(self,(inputs, outputs, givens, slice_to_seqs),n_seqs, n_outs,
def __init__(self, ins, n_seqs, n_outs,
inplace_map={}, seqs_taps={}, outs_taps={},
n_steps = gof.Constant(gof.generic, 'unknown', '?_steps'),
truncate_gradient = -1, n_outs_not_shared =0,
......@@ -1093,6 +1093,7 @@ class Scan(Op):
:param name: see scan fct
:param mode: see scan fct
'''
inputs, outputs, givens, slice_to_seqs = ins
# build a list of output types for any Apply node using this op.
self.apply_output_types = []
for i, o in enumerate(outputs):
......@@ -1601,7 +1602,7 @@ class Scan(Op):
class ScanGrad(Op):
"""Gradient Op for Scan"""
def __init__(self,(g_ins, g_outs) , n_seqs, n_outs,
def __init__(self, grads, n_seqs, n_outs,
n_outs_not_shared,
go_backwards = False, seqs_taps = {}, outs_taps= {},
truncate_gradient = -1, mode = None, name = None):
......@@ -1609,7 +1610,7 @@ class ScanGrad(Op):
:param mode: see scan fct
:param name: see scan fct
"""
g_ins, g_outs = grads
self.inputs = g_ins
self.outputs = g_outs
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论