-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.cpp
More file actions
35 lines (30 loc) · 683 Bytes
/
node.cpp
File metadata and controls
35 lines (30 loc) · 683 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
#include "node.h"
#include "context.h"
namespace graph_executor {
void Node::Bind(const std::vector<Context *> &inputs,
const std::vector<Context *> &outputs) {
inputs_ = inputs;
outputs_ = outputs;
for (Context *c : inputs) {
c->BindConsumer(this);
}
for (Context *c : outputs) {
c->BindProducer(this);
}
}
bool Node::IsReady() const {
// Ensure we can put outputs to context.
for (Context *c : outputs_) {
if (!c->CanPut()) {
return false;
}
}
// Ensure we can get inputs from context.
for (Context *c : inputs_) {
if (!c->CanGet()) {
return false;
}
}
return true;
}
} // namespace graph_executor