-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
Description
The xp
variable was introduced to deal with places where either numpy
or cupy
would work.
However, over time, the usage of xp
has crept into places where what is being accessed would not work if xp = numpy
. I think it would be better to not overly rely on xp
where possible, so combing through the repo and weeding out unnecessary/incorrect uses of it would be helpful.
Two examples
- using
xp.cuda.runtime.getDeviceCount()
will not work ifxp = numpy
httomo/httomo/method_wrappers/generic.py
Lines 128 to 131 in b28c2c3
if gpu_enabled: | |
self._num_gpus = xp.cuda.runtime.getDeviceCount() | |
_id = httomo.globals.gpu_id | |
self._gpu_id = mpiutil.local_rank % self._num_gpus if _id == -1 else _id |
- using
xp.cuda.Event()
will not work ifxp = numpy
Lines 271 to 276 in b28c2c3
class catch_gputime: | |
def __enter__(self): | |
if gpu_enabled: | |
self.start = xp.cuda.Event() | |
self.start.record() | |
return self |