-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexecutor.py
More file actions
36 lines (26 loc) · 739 Bytes
/
executor.py
File metadata and controls
36 lines (26 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import itertools
import numpy as np
from scipy.special import logsumexp
class Executor(object):
def __init__(self):
self.P = 1
self.rank = 0
def max(self, x):
return np.max(x)
def sum(self, x):
return np.sum(x)
def gather(self, x, all_x_shape):
return x
def bcast(self, x):
pass
def logsumexp(self, x):
return logsumexp(x)
def cumsum(self, x):
return np.cumsum(x)
def redistribute(self, particles, ncopies):
particles = list(itertools.chain.from_iterable(
[[particles[i]]*ncopies[i] for i in range(len(particles))]
))
return particles
def gather_all(self, particles):
return particles