def set(self, hdata): assert(hdata.shape == self.shape) hdata = hdata.astype(self.dtype) if self.flags['C_CONTIGUOUS'] and hdata.flags['C_CONTIGUOUS']: memcpy(self, hdata) elif self.ndim == 2: memcpy2D(self, hdata) else: raise RuntimeError("Copying with this data layout is unsupported") return self
def get(self, dst=None): hdata = dst if dst is not None else np.empty(self.shape, self.dtype) # hdata = dst if dst is not None else np.zeros(self.shape, self.dtype) assert(hdata.shape == self.shape) assert(hdata.dtype == self.dtype) if self.flags['C_CONTIGUOUS'] and hdata.flags['C_CONTIGUOUS']: memcpy(hdata, self) elif self.ndim == 2: memcpy2D(hdata, self) else: raise RuntimeError("Copying with this data layout is unsupported") return hdata
def main(self, input_rings, output_rings): """Iterate through first ring, copying to each output ring""" input_ring = input_rings[0] for output_ring in output_rings: for ispan, ospan in self.ring_transfer(input_ring, output_ring): memory.memcpy2D(ospan.data, ispan.data)