-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComputeBinaryWritable.java
More file actions
35 lines (29 loc) · 900 Bytes
/
Copy pathComputeBinaryWritable.java
File metadata and controls
35 lines (29 loc) · 900 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
// Get a binary snapshot of the reservoir with bias
package s6regen;
public final class ComputeBinaryWritable extends Compute {
private final int location;
public ComputeBinaryWritable(Reservoir r,int writableLocation) {
super(r);
location = writableLocation;
}
@Override
public void compute() {
float[] wt=reservoir.weights;
float[] workA = reservoir.computeBuffers[0];
reservoir.gather(workA);
int wtIdx=reservoir.weightIndex;
for(int i=0;i<reservoir.computeSize;i++){
workA[i]=(workA[i]+wt[wtIdx++])>0 ?1f:-1f;
}
reservoir.weightIndex=wtIdx;
reservoir.scatterWritable(workA, location);
}
@Override
public int weightSize() {
return reservoir.sizeGather()+reservoir.computeSize;
}
@Override
public int buffersRequired() {
return 1;
}
}