* Copyright (c) 2025 Huawei Technologies Co., Ltd.
* This program is free software, you can redistribute it and/or modify it under the terms and conditions of
* CANN Open Software License Agreement Version 2.0 (the "License").
* Please refer to the License for details. You may not use this file except in compliance with the License.
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
* See LICENSE in the root of the software repository for the full text of the License.
*/
#ifndef INC_FRAMEWORK_OMG_OMG_H_
#define INC_FRAMEWORK_OMG_OMG_H_
#include <string>
#include <unordered_map>
#include <vector>
#include <google/protobuf/message.h>
#include "ge/ge_api_types.h"
#include "framework/omg/omg_inner_types.h"
#include "framework/omg/parser/parser_inner_ctx.h"
#include "proto/ge_ir.pb.h"
#include "proto/om.pb.h"
#include "graph/compute_graph.h"
#include "graph/graph.h"
#include "graph/model.h"
#include "runtime/kernel.h"
namespace ge {
* @ingroup domi_omg
* @brief init omg context
* @return void
*/
GE_FUNC_VISIBILITY domi::Status InitDomiOmgContext(const std::string &input_shape, const std::string &input_format,
const std::string &net_format, bool is_dynamic_input);
* @ingroup domi_omg
* @brief generate graph based on the input model file and weight file
* @param [out] graph graph
* @param [in] model_file path of model file
* @param [in] weights_file path of weight file
* @param [in] type type of the input model
* @param [in] op_conf op mapping configuration
* @param [in] target type of platform. If a tiny model is generated, set target to tiny
* @param [in] run_mode run model
* @param [in] enable_l2dynamic enable l2dynamic
* @param [in] is_dynamic_input dynamic input, true of false
* @param [in] atc_params multiply atc params
* @return Status result code
*/
GE_FUNC_VISIBILITY domi::Status ParseGraph(ge::Graph &graph, const std::map<std::string, std::string> &atc_params,
const char *model_file, const char *weights_file, domi::FrameworkType type,
const char *op_conf = nullptr, const char *target = nullptr,
RunMode run_mode = RunMode::GEN_OM_MODEL, bool is_dynamic_input = false);
GE_FUNC_VISIBILITY domi::Status CheckParamForAirInput(ge::Graph &graph);
* @ingroup domi_omg
* @brief generates a simplified JSON file based on the key value of the offline model file in protobuf format
* @param [in] model_file path of offline model file
* @param [out] json_file path of json file
* @param [key] encrypted key
* @return Status result code
*/
GE_FUNC_VISIBILITY domi::Status ConvertOm(const char *model_file, const char *json_file, bool is_covert_to_json);
GE_FUNC_VISIBILITY domi::Status ConvertPbtxtToJson(const char *model_file, const char *json_file);
* @ingroup domi_omg
* @brief convert the model file in protobuf format into a JSON file.
* @param [in] framework type of model
* @param [in] om model_file path of offline model file
* @param [out] json_file path of json file
* @param [key] encrypted key
* @return Status result code
*/
GE_FUNC_VISIBILITY domi::Status ConvertFwkModelToJson(const domi::FrameworkType framework, const char *model_file,
const char *json_file);
* @ingroup domi_omg
* @brief convert the model file into a execute-om file.
* @param [in] om model_file path of offline model file
* @param [out] output path of execute-om file
* @return Status result code
*/
GE_FUNC_VISIBILITY void GetGroupName(ge::proto::ModelDef &model_def);
GE_FUNC_VISIBILITY void FindParserSo(const std::string &path, std::vector<std::string> &file_list,
std::string &caffe_parser_path);
GE_FUNC_VISIBILITY domi::Status DumpInfershapeJson(const ge::Graph &graph, const char *json_file);
GE_FUNC_VISIBILITY domi::Status SetOutputNodeInfo(ge::Graph &graph, const std::string &output_type);
GE_FUNC_VISIBILITY domi::Status GetOutputLeaf(ge::NodePtr node,
std::vector<std::pair<ge::NodePtr, int32_t>> &output_nodes_info);
GE_FUNC_VISIBILITY void CreateOutputNodesInfo(std::vector<std::pair<ge::NodePtr, int32_t>> &output_nodes_info,
std::vector<std::string> &output_nodes_name);
GE_FUNC_VISIBILITY void UpdateOmgCtxWithParserCtx();
GE_FUNC_VISIBILITY void UpdateParserCtxWithOmgCtx();
GE_FUNC_VISIBILITY void PrintModelInfo(ge::proto::ModelDef *model_def, uint32_t modeldef_size);
}
#endif