Compare commits
7 Commits
Author | SHA1 | Date |
---|---|---|
mindspore-ci-bot | 885af56694 | 4 years ago |
yanghaoran | 9f8bdb838e | 4 years ago |
mindspore-ci-bot | 2cb83c8f4d | 5 years ago |
yanghaoran | 20f86e636b | 5 years ago |
mindspore-ci-bot | efd823cc18 | 5 years ago |
wuweikang | ca11480c34 | 5 years ago |
lujiale | db2ea7a6ff | 5 years ago |
@ -0,0 +1,56 @@
|
|||||||
|
/**
|
||||||
|
* 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_FRAMEWORK_MEMORY_MEMORY_API_H_
|
||||||
|
#define INC_FRAMEWORK_MEMORY_MEMORY_API_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "ge/ge_api_error_codes.h"
|
||||||
|
#include "runtime/mem.h"
|
||||||
|
|
||||||
|
namespace ge {
|
||||||
|
enum MemStorageType {
|
||||||
|
HBM = 0,
|
||||||
|
RDMA_HBM,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct HostVarInfo {
|
||||||
|
uint64_t base_addr;
|
||||||
|
uint64_t var_size;
|
||||||
|
};
|
||||||
|
|
||||||
|
///
|
||||||
|
/// \param size [in] rdma pool memory size to be allocated.
|
||||||
|
/// \param mem_type [in] memory type for rdma pool.
|
||||||
|
/// \return Status result of function
|
||||||
|
Status InitRdmaPool(size_t size, rtMemType_t mem_type = RT_MEMORY_HBM);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// \param var_info [in] host variable addr infos.
|
||||||
|
/// \param mem_type [in] memory type for rdma pool.
|
||||||
|
/// \return Status result of function
|
||||||
|
Status RdmaRemoteRegister(const std::vector<HostVarInfo> &var_info, rtMemType_t mem_type = RT_MEMORY_HBM);
|
||||||
|
|
||||||
|
///
|
||||||
|
/// \param var_name [in] var_name name of host variable.
|
||||||
|
/// \param base_addr [out] base_addr vase addr of host variable.
|
||||||
|
/// \param var_size [out] var_size memory_size of host variable.
|
||||||
|
/// \return Status result of function
|
||||||
|
Status GetVarBaseAddrAndSize(const std::string &var_name, uint64_t &base_addr, uint64_t &var_size);
|
||||||
|
} // namespace ge
|
||||||
|
#endif // INC_FRAMEWORK_MEMORY_MEMORY_API_H_
|
@ -0,0 +1,110 @@
|
|||||||
|
/**
|
||||||
|
* 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_FRAMEWORK_OMG_PARSER_MODEL_PARSER_H_
|
||||||
|
#define INC_FRAMEWORK_OMG_PARSER_MODEL_PARSER_H_
|
||||||
|
|
||||||
|
#include <google/protobuf/message.h>
|
||||||
|
#include "framework/common/types.h"
|
||||||
|
#include "framework/omg/omg_inner_types.h"
|
||||||
|
#include "graph/attr_value.h"
|
||||||
|
#include "graph/compute_graph.h"
|
||||||
|
#include "graph/ge_tensor.h"
|
||||||
|
#include "graph/graph.h"
|
||||||
|
#include "graph/op_desc.h"
|
||||||
|
#include "graph/operator.h"
|
||||||
|
#include "graph/range_vistor.h"
|
||||||
|
#include "graph/utils/attr_utils.h"
|
||||||
|
#include "graph/utils/graph_utils.h"
|
||||||
|
#include "graph/utils/op_desc_utils.h"
|
||||||
|
#include "graph/utils/tensor_utils.h"
|
||||||
|
|
||||||
|
using Status = domi::Status;
|
||||||
|
|
||||||
|
namespace domi {
|
||||||
|
using GetGraphCallback = std::function<std::unique_ptr<google::protobuf::Message>(
|
||||||
|
const google::protobuf::Message *root_proto, const std::string &graph)>;
|
||||||
|
class ModelParser {
|
||||||
|
public:
|
||||||
|
ModelParser() {}
|
||||||
|
|
||||||
|
virtual ~ModelParser() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Analyze network model data
|
||||||
|
* @param [in] file Network model file path
|
||||||
|
* @param [in|out] graph Save the network information after analysis
|
||||||
|
* @return SUCCESS
|
||||||
|
* @return Others failed
|
||||||
|
*/
|
||||||
|
virtual Status Parse(const char *file, ge::Graph &graph) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Parse relevant data from memory and save it to graph
|
||||||
|
* @param [in] input Model file memory data
|
||||||
|
* @param [in|out] graph A graph for saving the model information after analysis
|
||||||
|
* @return SUCCESS
|
||||||
|
* @return FAILED
|
||||||
|
* @author
|
||||||
|
*/
|
||||||
|
virtual Status ParseFromMemory(const char *data, uint32_t size, ge::ComputeGraphPtr &graph) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Analyze network model data
|
||||||
|
* @param [in] proto network model
|
||||||
|
* @param [in|out] graph Save the network information after analysis
|
||||||
|
* @return SUCCESS
|
||||||
|
* @return Others failed
|
||||||
|
*/
|
||||||
|
virtual Status ParseProto(const google::protobuf::Message *proto, ge::ComputeGraphPtr &graph) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Analyze callback model data in subgraph
|
||||||
|
* @param [in] proto network model
|
||||||
|
* @param [in] callback callback of subgraph
|
||||||
|
* @param [in|out] graph Save the network information after analysis
|
||||||
|
* @return SUCCESS
|
||||||
|
* @return Others failed
|
||||||
|
*/
|
||||||
|
virtual Status ParseProtoWithSubgraph(const google::protobuf::Message *proto, GetGraphCallback callback,
|
||||||
|
ge::ComputeGraphPtr &graph) = 0;
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Convert model files to JSON format
|
||||||
|
* @param [in] model_file Model file path to be converted
|
||||||
|
* @param [out] json_file Converted JSON file path
|
||||||
|
* @return SUCCESS
|
||||||
|
* @return Others failed
|
||||||
|
*/
|
||||||
|
virtual Status ToJson(const char *model_file, const char *json_file) { return domi::SUCCESS; }
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Convert network data type
|
||||||
|
* @param [in] type Data type to be converted
|
||||||
|
* @return ge::DataType
|
||||||
|
*/
|
||||||
|
virtual ge::DataType ConvertToGeDataType(const uint32_t type) = 0;
|
||||||
|
|
||||||
|
virtual Status ParseAllGraph(const google::protobuf::Message *root_proto, ge::ComputeGraphPtr &root_graph) = 0;
|
||||||
|
};
|
||||||
|
} // namespace domi
|
||||||
|
|
||||||
|
#endif // INC_FRAMEWORK_OMG_PARSER_MODEL_PARSER_H_
|
@ -0,0 +1,92 @@
|
|||||||
|
/**
|
||||||
|
* 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_FRAMEWORK_OMG_PARSER_OP_PARSER_H_
|
||||||
|
#define INC_FRAMEWORK_OMG_PARSER_OP_PARSER_H_
|
||||||
|
|
||||||
|
#include <google/protobuf/text_format.h>
|
||||||
|
#include "common/types.h"
|
||||||
|
#include "omg/omg_inner_types.h"
|
||||||
|
#include "proto/om.pb.h"
|
||||||
|
#include "graph/ge_tensor.h"
|
||||||
|
#include "graph/op_desc.h"
|
||||||
|
#include "graph/utils/op_desc_utils.h"
|
||||||
|
|
||||||
|
using google::protobuf::Message;
|
||||||
|
using Status = domi::Status;
|
||||||
|
|
||||||
|
namespace ge {
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Used to analyze operator information
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class OpParser {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Deconstructor
|
||||||
|
*/
|
||||||
|
virtual ~OpParser() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Analytic operator parameters
|
||||||
|
* @param [in] op_src Parameter data to be resolved
|
||||||
|
* @param [out] graph Parsed parameter data
|
||||||
|
* @return SUCCESS
|
||||||
|
* @return FAILED
|
||||||
|
*/
|
||||||
|
virtual Status ParseParams(const Message *op_src, ge::OpDescPtr &op_desc) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Analytic operator parameters
|
||||||
|
* @param [in] op_src Parameter data to be resolved
|
||||||
|
* @param [out] Operator parameter data
|
||||||
|
* @return SUCCESS
|
||||||
|
* @return FAILED
|
||||||
|
*/
|
||||||
|
virtual Status ParseParams(const Message *op_src, ge::Operator &op_dest) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Analytic operator weight information
|
||||||
|
* @param [in] op_src Weight data to be resolved
|
||||||
|
* @param [out] op_dest Weight data after analysis
|
||||||
|
* @return SUCCESS
|
||||||
|
* @return FAILED
|
||||||
|
*/
|
||||||
|
virtual Status ParseWeights(const Message *op_src, ge::NodePtr &node) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Get the format information according to the parameters in the operator
|
||||||
|
* @param [in] op_src Parameter data to be resolved
|
||||||
|
* @param [out] format Output the parsed format
|
||||||
|
* @return SUCCESS
|
||||||
|
* @return FAILED
|
||||||
|
*/
|
||||||
|
virtual Status GetFormat(const Message *op_src, domi::domiTensorFormat_t &format) {
|
||||||
|
(void)op_src;
|
||||||
|
// Indicates that the op does not provide a value for format
|
||||||
|
format = domi::DOMI_TENSOR_RESERVED;
|
||||||
|
return domi::SUCCESS;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} // namespace ge
|
||||||
|
|
||||||
|
#endif // INC_FRAMEWORK_OMG_PARSER_OP_PARSER_H_
|
@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* 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_FRAMEWORK_OMG_PARSER_PARSER_API_H_
|
||||||
|
#define INC_FRAMEWORK_OMG_PARSER_PARSER_API_H_
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
#include "ge/ge_api_error_codes.h"
|
||||||
|
|
||||||
|
namespace ge {
|
||||||
|
// Initialize parser
|
||||||
|
Status ParserInitialize(const std::map<std::string, std::string>& options);
|
||||||
|
// Finalize parser, release all resources
|
||||||
|
Status ParserFinalize();
|
||||||
|
} // namespace ge
|
||||||
|
#endif // INC_FRAMEWORK_OMG_PARSER_PARSER_API_H_
|
@ -0,0 +1,138 @@
|
|||||||
|
/**
|
||||||
|
* 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_FRAMEWORK_OMG_PARSER_PARSER_FACTORY_H_
|
||||||
|
#define INC_FRAMEWORK_OMG_PARSER_PARSER_FACTORY_H_
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
|
#include <string>
|
||||||
|
#include "framework/common/types.h"
|
||||||
|
#include "framework/omg/omg_inner_types.h"
|
||||||
|
|
||||||
|
using Status = domi::Status;
|
||||||
|
|
||||||
|
namespace domi {
|
||||||
|
class WeightsParser;
|
||||||
|
class ModelParser;
|
||||||
|
|
||||||
|
typedef std::shared_ptr<ModelParser> (*MODEL_PARSER_CREATOR_FUN)(void);
|
||||||
|
|
||||||
|
// Create modelparser for different frameworks
|
||||||
|
class ModelParserFactory {
|
||||||
|
public:
|
||||||
|
static ModelParserFactory *Instance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Create a modelparser based on the type entered
|
||||||
|
* @param [in] type Framework type
|
||||||
|
* @return Created modelparser
|
||||||
|
*/
|
||||||
|
std::shared_ptr<ModelParser> CreateModelParser(const domi::FrameworkType type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Register create function
|
||||||
|
* @param [in] type Framework type
|
||||||
|
* @param [in] fun ModelParser's create function
|
||||||
|
*/
|
||||||
|
void RegisterCreator(const domi::FrameworkType type, MODEL_PARSER_CREATOR_FUN fun);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
ModelParserFactory() {}
|
||||||
|
~ModelParserFactory();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map<domi::FrameworkType, MODEL_PARSER_CREATOR_FUN> creator_map_;
|
||||||
|
}; // end class ModelParserFactory
|
||||||
|
|
||||||
|
class ModelParserRegisterar {
|
||||||
|
public:
|
||||||
|
ModelParserRegisterar(const domi::FrameworkType type, MODEL_PARSER_CREATOR_FUN fun) {
|
||||||
|
ModelParserFactory::Instance()->RegisterCreator(type, fun);
|
||||||
|
}
|
||||||
|
~ModelParserRegisterar() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Registration macros for model parsers
|
||||||
|
#define REGISTER_MODEL_PARSER_CREATOR(type, clazz) \
|
||||||
|
std::shared_ptr<ModelParser> Creator_##type##_Model_Parser() { \
|
||||||
|
std::shared_ptr<clazz> ptr = nullptr; \
|
||||||
|
try { \
|
||||||
|
ptr = make_shared<clazz>(); \
|
||||||
|
} catch (...) { \
|
||||||
|
ptr = nullptr; \
|
||||||
|
} \
|
||||||
|
return std::shared_ptr<ModelParser>(ptr); \
|
||||||
|
} \
|
||||||
|
ModelParserRegisterar g_##type##_Model_Parser_Creator(type, Creator_##type##_Model_Parser)
|
||||||
|
|
||||||
|
typedef std::shared_ptr<WeightsParser> (*WEIGHTS_PARSER_CREATOR_FUN)(void);
|
||||||
|
|
||||||
|
// Create weightsparser for different frameworks
|
||||||
|
class WeightsParserFactory {
|
||||||
|
public:
|
||||||
|
static WeightsParserFactory *Instance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Create weightsparser based on the type entered
|
||||||
|
* @param [in] type Framework type
|
||||||
|
* @return Created weightsparser
|
||||||
|
*/
|
||||||
|
std::shared_ptr<WeightsParser> CreateWeightsParser(const domi::FrameworkType type);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Register create function
|
||||||
|
* @param [in] type Framework type
|
||||||
|
* @param [in] fun WeightsParser's create function
|
||||||
|
*/
|
||||||
|
void RegisterCreator(const domi::FrameworkType type, WEIGHTS_PARSER_CREATOR_FUN fun);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
WeightsParserFactory() {}
|
||||||
|
~WeightsParserFactory();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::map<domi::FrameworkType, WEIGHTS_PARSER_CREATOR_FUN> creator_map_;
|
||||||
|
}; // end class WeightsParserFactory
|
||||||
|
|
||||||
|
class WeightsParserRegisterar {
|
||||||
|
public:
|
||||||
|
WeightsParserRegisterar(const domi::FrameworkType type, WEIGHTS_PARSER_CREATOR_FUN fun) {
|
||||||
|
WeightsParserFactory::Instance()->RegisterCreator(type, fun);
|
||||||
|
}
|
||||||
|
~WeightsParserRegisterar() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Register macro of weight resolver
|
||||||
|
#define REGISTER_WEIGHTS_PARSER_CREATOR(type, clazz) \
|
||||||
|
std::shared_ptr<WeightsParser> Creator_##type##_Weights_Parser() { \
|
||||||
|
std::shared_ptr<clazz> ptr = nullptr; \
|
||||||
|
try { \
|
||||||
|
ptr = make_shared<clazz>(); \
|
||||||
|
} catch (...) { \
|
||||||
|
ptr = nullptr; \
|
||||||
|
} \
|
||||||
|
return std::shared_ptr<WeightsParser>(ptr); \
|
||||||
|
} \
|
||||||
|
WeightsParserRegisterar g_##type##_Weights_Parser_Creator(type, Creator_##type##_Weights_Parser)
|
||||||
|
}; // namespace domi
|
||||||
|
|
||||||
|
#endif // INC_FRAMEWORK_OMG_PARSER_PARSER_FACTORY_H_
|
@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* 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_FRAMEWORK_OMG_PARSER_PARSER_INNER_CONTEXT_H_
|
||||||
|
#define INC_FRAMEWORK_OMG_PARSER_PARSER_INNER_CONTEXT_H_
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <utility>
|
||||||
|
#include <vector>
|
||||||
|
#include "external/register/register_fmk_types.h"
|
||||||
|
#include "external/register/register_types.h"
|
||||||
|
#include "framework/omg/omg_inner_types.h"
|
||||||
|
|
||||||
|
namespace ge {
|
||||||
|
struct ParserContext {
|
||||||
|
std::unordered_map<std::string, std::vector<int64_t>> input_dims;
|
||||||
|
domi::domiTensorFormat_t format = domi::DOMI_TENSOR_ND;
|
||||||
|
;
|
||||||
|
RunMode run_mode = ONLY_PRE_CHECK;
|
||||||
|
std::string custom_proto_path; // save caffe custom proto path, used by caffe parse
|
||||||
|
std::string caffe_proto_path; // save caffe proto path, used by caffe parse
|
||||||
|
};
|
||||||
|
|
||||||
|
ParserContext &GetParserContext();
|
||||||
|
} // namespace ge
|
||||||
|
|
||||||
|
#endif // INC_FRAMEWORK_OMG_PARSER_PARSER_INNER_CONTEXT_H_
|
@ -0,0 +1,74 @@
|
|||||||
|
/**
|
||||||
|
* 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_FRAMEWORK_OMG_PARSER_WEIGHTS_PARSER_H_
|
||||||
|
#define INC_FRAMEWORK_OMG_PARSER_WEIGHTS_PARSER_H_
|
||||||
|
|
||||||
|
#include "graph/graph.h"
|
||||||
|
#include "graph/attr_value.h"
|
||||||
|
#include "graph/compute_graph.h"
|
||||||
|
#include "graph/ge_tensor.h"
|
||||||
|
#include "graph/op_desc.h"
|
||||||
|
#include "graph/operator.h"
|
||||||
|
#include "graph/range_vistor.h"
|
||||||
|
#include "graph/utils/attr_utils.h"
|
||||||
|
#include "graph/utils/op_desc_utils.h"
|
||||||
|
#include "graph/utils/tensor_utils.h"
|
||||||
|
|
||||||
|
namespace domi {
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Weight information resolver
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class WeightsParser {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Constructor
|
||||||
|
*/
|
||||||
|
WeightsParser() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Deconstructor
|
||||||
|
*/
|
||||||
|
virtual ~WeightsParser() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Analyze weight data
|
||||||
|
* @param [in] file Path of weight file after training
|
||||||
|
* @param [in|out] graph Graph for saving weight information after analysis
|
||||||
|
* @return SUCCESS
|
||||||
|
* @return Others failed
|
||||||
|
*/
|
||||||
|
virtual Status Parse(const char *file, ge::Graph &graph) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup domi_omg
|
||||||
|
* @brief Parse relevant data from memory and save it to graph
|
||||||
|
* @param [in] input Model file memory data
|
||||||
|
* @param [in|out] graph A graph for saving the model information after analysis
|
||||||
|
* @return SUCCESS
|
||||||
|
* @return FAILED
|
||||||
|
* @author
|
||||||
|
*/
|
||||||
|
virtual Status ParseFromMemory(const char *input, uint32_t lengt, ge::ComputeGraphPtr &graph) = 0;
|
||||||
|
};
|
||||||
|
} // namespace domi
|
||||||
|
|
||||||
|
#endif // INC_FRAMEWORK_OMG_PARSER_WEIGHTS_PARSER_H_
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue