[python-dtcwt] 201/497: memoize any to-host copies in OpenCL transform result
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Tue Jul 21 18:06:05 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch debian/sid
in repository python-dtcwt.
commit a708eb9a0a769ab0d81196d456e969253fb532f4
Author: Rich Wareham <rjw57 at cam.ac.uk>
Date: Wed Nov 13 11:35:46 2013 +0000
memoize any to-host copies in OpenCL transform result
---
dtcwt/backend/backend_opencl/transform2d.py | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/dtcwt/backend/backend_opencl/transform2d.py b/dtcwt/backend/backend_opencl/transform2d.py
index e19744f..9be3f9c 100644
--- a/dtcwt/backend/backend_opencl/transform2d.py
+++ b/dtcwt/backend/backend_opencl/transform2d.py
@@ -6,7 +6,7 @@ from six.moves import xrange
from dtcwt import biort as _biort, qshift as _qshift
from dtcwt.defaults import DEFAULT_BIORT, DEFAULT_QSHIFT
-from dtcwt.utils import appropriate_complex_type_for, asfarray
+from dtcwt.utils import appropriate_complex_type_for, asfarray, memoize
from dtcwt.backend.backend_opencl.lowlevel import colfilter, coldfilt, colifilt
from dtcwt.backend.backend_opencl.lowlevel import axis_convolve, axis_convolve_dfilter, q2c
from dtcwt.backend.backend_opencl.lowlevel import to_device, to_queue, to_array, empty
@@ -38,6 +38,15 @@ class TransformDomainSignalOpenCL(object):
are implemented via properties. The original OpenCL arrays may be accessed
via the ``cl_...`` attributes.
+ .. note::
+
+ The copy from device to host is performed *once* and then memoized.
+ This makes repeated access to the host-side attributes efficient but
+ will mean that any changes to the device-side arrays will not be
+ reflected in the host-side attributes after their first access. You
+ should not be modifying the arrays once you return an instance of this
+ class anyway but if you do, beware!
+
.. py:attribute:: cl_lowpass
The CL array containing the lowpass image.
@@ -58,14 +67,17 @@ class TransformDomainSignalOpenCL(object):
self.cl_scales = scales
@property
+ @memoize
def lowpass(self):
return to_array(self.cl_lowpass) if self.cl_lowpass is not None else None
@property
+ @memoize
def subbands(self):
return tuple(to_array(x) for x in self.cl_subbands) if self.cl_subbands is not None else None
@property
+ @memoize
def scales(self):
return tuple(to_array(x) for x in self.cl_scales) if self.cl_scales is not None else None
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-dtcwt.git
More information about the debian-science-commits
mailing list