| 26 | namespace gpu { |
| 27 | |
| 28 | bool ModelTransformer::Apply(const std::string& name, |
| 29 | SequenceTransformation* transformation) { |
| 30 | // Seed transformations with starting node. Each node may start a chain of |
| 31 | // transformations. |
| 32 | for (auto input : graph_->inputs()) { |
| 33 | for (auto node : graph_->FindConsumers(input->id)) { |
| 34 | AddNodeToProcess(node); |
| 35 | } |
| 36 | } |
| 37 | while (!to_process_.empty()) { |
| 38 | auto node = graph_->GetNode(to_process_.front()); |
| 39 | if (node) { |
| 40 | if (!ApplyStartingWithNode(name, transformation, node)) { |
| 41 | return false; |
| 42 | } |
| 43 | } |
| 44 | to_process_.pop_front(); |
| 45 | } |
| 46 | processed_.clear(); |
| 47 | return true; |
| 48 | } |
| 49 | |
| 50 | bool ModelTransformer::Apply(const std::string& name, |
| 51 | NodeTransformation* transformation) { |