From a039598e572b9cbf26b668f5fa0b8d1494789352 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Sun, 16 Feb 2014 15:03:11 -0600 Subject: [PATCH] Recognize no-op in reshape --- pyopencl/array.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyopencl/array.py b/pyopencl/array.py index 9b28f17b..2d61e3e1 100644 --- a/pyopencl/array.py +++ b/pyopencl/array.py @@ -1173,6 +1173,10 @@ class Array(object): # TODO: add more error-checking, perhaps if isinstance(shape[0], tuple) or isinstance(shape[0], list): shape = tuple(shape[0]) + + if shape == self.shape: + return self + size = reduce(lambda x, y: x * y, shape, 1) if size != self.size: raise ValueError("total size of new array must be unchanged") -- GitLab