2 * Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "luci/Plan/CircleNodeExecutionPlan.h"
28 * @brief Set annotation for circle node execution plan
29 * @note Once CircleExecutionPlanAnnotation is annotated, it should not be changed.
30 * If CircleExecutionPlanAnnotation is needed to be changed, create
31 * new CircleExecutionPlanAnnotation.
33 class CircleExecutionPlanAnnotation final : public loco::NodeAnnotation
36 CircleExecutionPlanAnnotation() = delete;
38 explicit CircleExecutionPlanAnnotation(luci::CircleNodeExecutionPlan execution_plan)
39 : _execution_plan{std::move(execution_plan)}
45 const luci::CircleNodeExecutionPlan &execution_plan(void) const { return _execution_plan; }
49 luci::CircleNodeExecutionPlan _execution_plan;
57 bool has_execution_plan(const luci::CircleNode *circle_node)
59 return circle_node->annot<CircleExecutionPlanAnnotation>() != nullptr;
62 void add_execution_plan(luci::CircleNode *circle_node,
63 const luci::CircleNodeExecutionPlan &execution_plan)
65 circle_node->annot<CircleExecutionPlanAnnotation>(nullptr);
66 circle_node->annot(std::make_unique<CircleExecutionPlanAnnotation>(execution_plan));
69 luci::CircleNodeExecutionPlan get_execution_plan(const luci::CircleNode *circle_node)
71 if (!has_execution_plan(circle_node))
72 throw std::runtime_error("Cannot find CircleNodeExecutionPlanAnnotation");
74 return circle_node->annot<CircleExecutionPlanAnnotation>()->execution_plan();