Skip to content

Commit be5b961

Browse files
⏺ The migration appears to be working well with our fixes. Let's summarize what we've done:
1. Fixed the Phase class to properly implement ProcessingPhase interface 2. Changed parameter types in method signatures from Timestamp to long 3. Fixed inconsistencies in const methods across the class hierarchy 4. Updated isQueued in Fired to use the proper accessor method 5. Made ElementStep::getPhase() pure virtual to ensure derived classes implement it 6. Updated all relevant files to maintain consistency
1 parent ce1c3d5 commit be5b961

File tree

11 files changed

+63
-18
lines changed

11 files changed

+63
-18
lines changed

include/fields/step.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Step : public QueueProvider {
4646
virtual bool incrementRound();
4747
virtual void createQueueKey(long timestamp, int round) = 0;
4848
virtual void process() = 0;
49-
virtual ProcessingPhase& getPhase() const = 0;
49+
virtual const ProcessingPhase& getPhase() const = 0;
5050
static bool add(Step* s);
5151

5252
};

include/network/activation.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "network/bs_type.h"
1212
#include "network/binding_signal.h"
1313
#include "network/link.h"
14+
#include "network/fired.h"
1415
#include "network/timestamp.h"
1516

1617
#include <map>

include/network/element.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
#define NETWORK_ELEMENT_H
33

44
#include "network/timestamp.h"
5+
#include "fields/queue_provider.h"
56

6-
class Element {
7+
class Element : public QueueProvider {
78
public:
89
virtual ~Element() = default;
910
virtual Timestamp getCreated() = 0;

include/network/element_step.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99
class ElementStep : public Step {
1010
public:
1111
ElementStep(Element* element);
12-
Queue* getQueue() override;
13-
void createQueueKey(Timestamp timestamp, int round) override;
12+
Queue* getQueue() const override;
13+
void createQueueKey(long timestamp, int round) override;
14+
virtual const ProcessingPhase& getPhase() const override = 0; // Make this pure virtual for derived classes
1415
Element* getElement();
1516
std::string toString() const override;
1617

include/network/fired.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#define NETWORK_FIRED_H
33

44
#include "fields/step.h"
5+
#include "fields/queue.h"
56
#include "network/activation.h"
67
#include "network/phase.h"
7-
#include "network/queue.h"
88
#include "network/timestamp.h"
99
#include <string>
1010

@@ -13,10 +13,10 @@ class Fired : public Step {
1313
Fired(Activation* act);
1414
virtual ~Fired() = default;
1515

16-
void createQueueKey(Timestamp timestamp, int round) override;
16+
void createQueueKey(long timestamp, int round) override;
1717
void process() override;
1818
void updateNet(double net);
19-
Phase getPhase() const override;
19+
const Phase& getPhase() const override;
2020
Activation* getElement();
2121
Queue* getQueue() const override;
2222
std::string toString() const override;

include/network/phase.h

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
#ifndef NETWORK_PHASE_H
22
#define NETWORK_PHASE_H
33

4-
#include "network/processing_phase.h"
4+
#include "fields/queue_key.h"
55

6-
enum class Phase : public ProcessingPhase {
6+
// First define the enum for Phase types
7+
enum class PhaseType {
78
INFERENCE,
89
FIRED,
910
INSTANTIATION_TRIGGER,
@@ -12,4 +13,45 @@ enum class Phase : public ProcessingPhase {
1213
SAVE
1314
};
1415

16+
// Phase class that implements ProcessingPhase interface
17+
class Phase : public ProcessingPhase {
18+
public:
19+
Phase(PhaseType type) : type(type) {}
20+
21+
int rank() const override {
22+
switch (type) {
23+
case PhaseType::INFERENCE: return 0;
24+
case PhaseType::FIRED: return 1;
25+
case PhaseType::INSTANTIATION_TRIGGER: return 2;
26+
case PhaseType::TRAINING: return 3;
27+
case PhaseType::INACTIVE_LINKS: return 4;
28+
case PhaseType::SAVE: return 5;
29+
default: return 0;
30+
}
31+
}
32+
33+
bool isDelayed() const override {
34+
return type == PhaseType::SAVE; // Only SAVE phase is delayed
35+
}
36+
37+
// Static instances for convenience
38+
static const Phase INFERENCE;
39+
static const Phase FIRED;
40+
static const Phase INSTANTIATION_TRIGGER;
41+
static const Phase TRAINING;
42+
static const Phase INACTIVE_LINKS;
43+
static const Phase SAVE;
44+
45+
private:
46+
PhaseType type;
47+
};
48+
49+
// Define the static instances
50+
inline const Phase Phase::INFERENCE(PhaseType::INFERENCE);
51+
inline const Phase Phase::FIRED(PhaseType::FIRED);
52+
inline const Phase Phase::INSTANTIATION_TRIGGER(PhaseType::INSTANTIATION_TRIGGER);
53+
inline const Phase Phase::TRAINING(PhaseType::TRAINING);
54+
inline const Phase Phase::INACTIVE_LINKS(PhaseType::INACTIVE_LINKS);
55+
inline const Phase Phase::SAVE(PhaseType::SAVE);
56+
1557
#endif // NETWORK_PHASE_H

include/network/save.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#ifndef NETWORK_SAVE_H
22
#define NETWORK_SAVE_H
33

4+
#include "fields/step.h"
45
#include "network/element_step.h"
56
#include "network/neuron.h"
67
#include "network/phase.h"
7-
#include "fields/step.h"
88

99
class Save : public ElementStep {
1010
public:
@@ -13,7 +13,7 @@ class Save : public ElementStep {
1313
Save(Neuron* n);
1414
virtual ~Save() = default;
1515

16-
Phase getPhase() const override;
16+
const Phase& getPhase() const override;
1717
void process() override;
1818
};
1919

src/network/activation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void Activation::setFired(Timestamp f) {
167167
fired = f;
168168
}
169169

170-
void Activation::updateFiredStep(FieldOutput* net) {
170+
void Activation::updateFiredStep(Field* net) {
171171
if (!net->exceedsThreshold() || fired != Timestamp::NOT_SET) {
172172
return;
173173
}

src/network/element_step.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
ElementStep::ElementStep(Element* element) : element(element) {}
44

5-
Queue* ElementStep::getQueue() {
5+
Queue* ElementStep::getQueue() const {
66
return element->getQueue();
77
}
88

9-
void ElementStep::createQueueKey(Timestamp timestamp, int round) {
9+
void ElementStep::createQueueKey(long timestamp, int round) {
1010
queueKey = new FiredQueueKey(round, getPhase(), element, timestamp);
1111
}
1212

src/network/fired.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Fired::Fired(Activation* act) : Step(), act(act), net(0.0), sortValue(0) {}
1010

11-
void Fired::createQueueKey(Timestamp timestamp, int round) {
11+
void Fired::createQueueKey(long timestamp, int round) {
1212
queueKey = new FiredQueueKey(round, getPhase(), getElement(), timestamp);
1313
}
1414

@@ -32,7 +32,7 @@ void Fired::updateNet(double net) {
3232
sortValue = static_cast<int>(net * 1000.0); // Scale to preserve 3 decimals of precision
3333
}
3434

35-
Phase Fired::getPhase() const {
35+
const Phase& Fired::getPhase() const {
3636
return Phase::FIRED;
3737
}
3838

@@ -45,7 +45,7 @@ Queue* Fired::getQueue() const {
4545
}
4646

4747
bool Fired::isQueued() const {
48-
return isQueued;
48+
return getIsQueued();
4949
}
5050

5151
std::string Fired::toString() const {

0 commit comments

Comments
 (0)