def make_node(self, input):
ib = tuple(input.type.broadcastable)
if not ib == self.input_broadcastable:
if len(ib) != len(self.input_broadcastable):
raise TypeError((
"The number of dimensions of the "
"input is incorrect for this op. Expected %s, got %s."
% (self.input_broadcastable, ib)))
for expected, b in zip(self.input_broadcastable, ib):
if expected is True and b is False:
raise TypeError((
"The broadcastable pattern of the "
"input is incorrect for this op. Expected %s, got %s."
% (self.input_broadcastable, ib)))
# else, expected == b or expected is False and b is True
# Both case are good.
ob = []
if not isinstance(input.type, CudaNdarrayType):
input = as_cuda_ndarray_variable(input)
for value in self.new_order:
if value == 'x':
ob.append(True)
else:
ob.append(ib[value])
return Apply(self, [input], [CudaNdarrayType(broadcastable=ob)()])
评论列表
文章目录