Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def irfft(x, axes):
return Result(IRFFT(axes),[x])
def pullback(self, inputs, _output, gout):
X,W,b = inputs
# pass in an extra first argument to make output shape computation simpler
return [core.Result(CudnnConvBackwardData(self.ph, self.pw, self.sv, self.sh), [X, gout, W]),
core.Result(CudnnConvBackwardFilter(self.ph, self.pw, self.sv, self.sh), [W, gout, X]),
core.Result(CudnnConvBackwardBias(self.ph, self.pw, self.sv, self.sh), [b, gout])]
def size(x, axis):
return Result(Size(axis), [x])
def zeros(shape, dtype=None): #pylint: disable=W0621
"""
Like numpy.zeros
"""
if (dtype is None):
dtype = cgt.floatX
return core.Result(core.Fill(np.array(0, dtype)), shape)
def pullback(self, inputs, output, goutput):
return [Result(Repeat(self.axes), [goutput] + [size(inputs[0],ax) for ax in self.axes])]
def shp_apply(self, inputs):
def reshape(x, shape): #pylint: disable=W0621
return Result(Reshape(), [x] + list(shape))
def fill(val, shape):
"""
Create an array of shape `shape` filled with scalar `val`
"""
assert isinstance(shape, list)
val = core.as_node(val)
# if val is a constant, use a Fill Op, which includes the value as a attribute
if isinstance(val.op, core.Constant):
return core.Result(core.Fill(val.op.value), shape)
# if val is a non-constant variable, we can use a Repeat Op
else:
singleton = reshape(val, [1]*len(shape))
return core.Result(core.Repeat(range(len(shape))), [singleton] + shape)
def _subtensor4(x, slis, y):
for (ax,sli) in enumerate(slis):
if _is1dintarray(sli):
if y is None:
return core.Result(core.GetFancySli(ax), [x, sli])
else:
return core.Result(core.IncFancySli(ax), [x, sli, y])
assert 0, "should be unreachable"
def batched_matmul(x, y):
return Result(BatchedMul22(False,False), [x,y])
def cos(x):
"Applies function cos elementwise to argument x"
return core.Result(core.ElwiseUnary("cos"), [x])