A trivial implementation of GraphInfo around the Interpreter. NOTE: this interpreter info represents the subset of the graph that is executed according to execution plan. Thus, the indices are execution plan indices rather than raw node indices.
| 124 | // the indices are execution plan indices rather than raw node |
| 125 | // indices. |
| 126 | class InterpreterInfo : public GraphInfo { |
| 127 | public: |
| 128 | explicit InterpreterInfo(Subgraph* subgraph) : subgraph_(subgraph) {} |
| 129 | |
| 130 | size_t num_tensors() const override { return subgraph_->tensors().size(); } |
| 131 | TfLiteTensor* tensor(size_t index) override { |
| 132 | return &subgraph_->tensors()[index]; |
| 133 | } |
| 134 | size_t num_nodes() const override { |
| 135 | return subgraph_->execution_plan().size(); |
| 136 | } |
| 137 | const TfLiteNode& node(size_t index) const override { |
| 138 | int node_index = subgraph_->execution_plan()[index]; |
| 139 | return subgraph_->nodes_and_registration()[node_index].first; |
| 140 | } |
| 141 | size_t node_index(size_t index) const override { |
| 142 | return subgraph_->execution_plan()[index]; |
| 143 | } |
| 144 | const std::vector<int>& inputs() const override { |
| 145 | return subgraph_->inputs(); |
| 146 | } |
| 147 | const std::vector<int>& outputs() const override { |
| 148 | return subgraph_->outputs(); |
| 149 | } |
| 150 | const std::vector<int>& variables() const override { |
| 151 | return subgraph_->variables(); |
| 152 | } |
| 153 | |
| 154 | public: |
| 155 | Subgraph* subgraph_; |
| 156 | }; |
| 157 | |
| 158 | Subgraph::Subgraph(ErrorReporter* error_reporter, |
| 159 | TfLiteExternalContext** external_contexts, |