def __init__(self, shape, dtype = numpy.float32):
num_elems = numpy.prod(shape)
if dtype == numpy.int32:
c_type = ctypes.c_int
elif dtype == numpy.float32:
c_type = ctypes.c_float
elif dtype == numpy.float64:
c_type = ctypes.c_double
else:
assert(0)
#shared storage for numpy array
self.shape = shape
self.dtype = dtype
self.base = mp.RawArray(c_type, int(num_elems))
self.lock = mp.RLock()
#overloaded operators for convienince
评论列表
文章目录