| 159 | |
| 160 | template <bool output_timestamps> |
| 161 | void SchedulerClock<output_timestamps>::test_start() |
| 162 | { |
| 163 | #ifdef ARM_COMPUTE_GRAPH_ENABLED |
| 164 | // Start intercepting tasks: |
| 165 | ARM_COMPUTE_ERROR_ON(_real_graph_function != nullptr); |
| 166 | _real_graph_function = graph::TaskExecutor::get().execute_function; |
| 167 | auto task_interceptor = [this](graph::ExecutionTask &task) |
| 168 | { |
| 169 | Interceptor<output_timestamps> *scheduler = nullptr; |
| 170 | if (dynamic_cast<Interceptor<output_timestamps> *>(this->_interceptor.get()) != nullptr) |
| 171 | { |
| 172 | scheduler = |
| 173 | arm_compute::utils::cast::polymorphic_downcast<Interceptor<output_timestamps> *>(_interceptor.get()); |
| 174 | if (task.node != nullptr && !task.node->name().empty()) |
| 175 | { |
| 176 | scheduler->set_prefix(task.node->name() + "/"); |
| 177 | |
| 178 | if (_layer_data_map.find(task.node->name()) == _layer_data_map.end()) |
| 179 | { |
| 180 | arm_compute::graph::DataLayerVisitor dlv = {}; |
| 181 | task.node->accept(dlv); |
| 182 | _layer_data_map[task.node->name()] = dlv.layer_data(); |
| 183 | } |
| 184 | } |
| 185 | else |
| 186 | { |
| 187 | scheduler->set_prefix(""); |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | this->_real_graph_function(task); |
| 192 | |
| 193 | if (scheduler != nullptr) |
| 194 | { |
| 195 | scheduler->set_prefix(""); |
| 196 | } |
| 197 | }; |
| 198 | #endif /* ARM_COMPUTE_GRAPH_ENABLED */ |
| 199 | |
| 200 | ARM_COMPUTE_ERROR_ON(_real_scheduler != nullptr); |
| 201 | _real_scheduler_type = Scheduler::get_type(); |
| 202 | //Note: We can't currently replace a custom scheduler |
| 203 | if (_real_scheduler_type != Scheduler::Type::CUSTOM) |
| 204 | { |
| 205 | _real_scheduler = &Scheduler::get(); |
| 206 | _interceptor = std::make_shared<Interceptor<output_timestamps>>(_kernels, _layer_data_map, *_real_scheduler, |
| 207 | _scale_factor); |
| 208 | Scheduler::set(std::static_pointer_cast<IScheduler>(_interceptor)); |
| 209 | #ifdef ARM_COMPUTE_GRAPH_ENABLED |
| 210 | graph::TaskExecutor::get().execute_function = task_interceptor; |
| 211 | #endif /* ARM_COMPUTE_GRAPH_ENABLED */ |
| 212 | |
| 213 | // Create an interceptor for each scheduler |
| 214 | // TODO(COMPID-2638) : Allow multiple schedulers, now it assumes the same scheduler is used. |
| 215 | std::for_each(std::begin(_scheduler_users), std::end(_scheduler_users), |
| 216 | [&](ISchedulerUser *user) |
| 217 | { |
| 218 | if (user != nullptr && user->scheduler() != nullptr) |