You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.1 KiB
64 lines
2.1 KiB
/**
|
|
* Copyright 2019-2020 Huawei Technologies Co., Ltd
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#ifndef INC_COMMON_OPTIMIZER_GRAPH_OPTIMIZER_H_
|
|
#define INC_COMMON_OPTIMIZER_GRAPH_OPTIMIZER_H_
|
|
|
|
#include <map>
|
|
#include <string>
|
|
#include "./graph_optimizer_types.h"
|
|
#include "common/ge_inner_error_codes.h"
|
|
#include "common/opskernel/ops_kernel_info_types.h"
|
|
#include "graph/compute_graph.h"
|
|
|
|
using std::map;
|
|
using std::string;
|
|
|
|
namespace ge {
|
|
class GraphOptimizer {
|
|
public:
|
|
virtual ~GraphOptimizer() {}
|
|
|
|
// initialize graphOptimizer
|
|
virtual Status Initialize(const map<string, string> &options) = 0;
|
|
|
|
// close graphOptimizer
|
|
virtual Status Finalize() = 0;
|
|
|
|
// optimize original graph for FE quant optimize
|
|
virtual Status OptimizeGraphPrepare(ComputeGraph &graph) { return SUCCESS; }
|
|
|
|
// optimize original graph, using in graph preparation stage
|
|
virtual Status OptimizeOriginalGraph(ComputeGraph &graph) = 0;
|
|
|
|
// optimize original graph, using for conversion operator insert in graph preparation stage
|
|
virtual Status OptimizeOriginalGraphJudgeInsert(ComputeGraph &graph) { return SUCCESS; }
|
|
|
|
// optimize fused graph
|
|
virtual Status OptimizeFusedGraph(ComputeGraph &graph) = 0;
|
|
|
|
// optimize whole graph, using after graph merged stage
|
|
virtual Status OptimizeWholeGraph(ComputeGraph &graph) = 0;
|
|
|
|
// get attribute of graph optimizer
|
|
virtual Status GetAttributes(GraphOptimizerAttribute &attrs) const = 0;
|
|
|
|
// optimize streamed Graph
|
|
virtual Status OptimizeStreamGraph(ComputeGraph &graph, const RunContext &context) { return SUCCESS; }
|
|
};
|
|
} // namespace ge
|
|
#endif // INC_COMMON_OPTIMIZER_GRAPH_OPTIMIZER_H_
|