Avoid creating iterator object
@@ -529,9 +529,9 @@ cdef class ElementwiseKernel:
shape = size,
is_size_specified = True
- if any(not self.params[i].is_const and
- not internal.vector_equal(args[i].shape, shape)
- for i in range(self.nin)):
+ for i in range(self.nin):
+ if not (self.params[i].is_const or
+ internal.vector_equal(args[i].shape, shape)):
raise ValueError('Shape is mismatched')
out_args = _get_out_args_with_params(
