Browse Source

Pre Merge pull request !649 from songmingyang001/smy_code

pull/649/MERGE
songmingyang001 Gitee 3 years ago
parent
commit
fd68121774
No known key found for this signature in database GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 7 additions and 31 deletions
  1. +4
    -6
      parser/common/acl_graph_parser_util.cc
  2. +3
    -25
      parser/common/acl_graph_parser_util.h

+ 4
- 6
parser/common/acl_graph_parser_util.cc View File

@@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.

* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -291,7 +291,7 @@ domi::Status AclGrphParseUtil::ParseAclOutputNodes(const string &out_nodes) cons
return PARAM_INVALID;
}

auto iter = ge::GetParserContext().out_nodes_map.find(key_value_v[0]);
const auto iter = ge::GetParserContext().out_nodes_map.find(key_value_v[0]);
int32_t index = stoi(StringUtils::Trim(key_value_v[1]));
GELOGD("Get output info: node[%s] and index[%d]", key_value_v[0].c_str(), index);
if (iter != ge::GetParserContext().out_nodes_map.end()) {
@@ -532,7 +532,7 @@ domi::Status AclGrphParseUtil::GetDefaultOutInfo(ge::ComputeGraphPtr &compute_gr
}

domi::Status AclGrphParseUtil::SetOutputNodeInfo(ge::Graph &graph,
const std::map<AscendString, AscendString> &parser_params) {
const std::map<AscendString, AscendString> &parser_params) const {
(void)parser_params;
ge::ComputeGraphPtr compute_graph = ge::GraphUtils::GetComputeGraph(graph);
GE_CHECK_NOTNULL(compute_graph);
@@ -610,7 +610,7 @@ domi::Status AclGrphParseUtil::CheckOptions(const std::map<AscendString, AscendS
}

domi::Status AclGrphParseUtil::ParseParamsBeforeGraph(const std::map<AscendString, AscendString> &parser_params,
string &graph_name) {
string &graph_name) const {
GELOGI("Parse graph user options start.");
ge::GetParserContext().input_nodes_format_map.clear();
ge::GetParserContext().output_formats.clear();
@@ -938,12 +938,10 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromMem(const cha
return ret;
}

///
/// @brief get the Original Type of FrameworkOp
/// @param [in] node
/// @param [out] type
/// @return Status
///
Status GetOriginalType(const ge::NodePtr &node, string &type) {
GE_CHECK_NOTNULL(node);
type = node->GetType();


+ 3
- 25
parser/common/acl_graph_parser_util.h View File

@@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* Copyright (c) Huawei Technologies Co., Ltd. 2020. All rights reserved.

* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,7 +26,6 @@
#include <vector>

#include "framework/omg/parser/parser_types.h"
#include "graph/ascend_string.h"
#include "graph/utils/graph_utils.h"
#include "register/register_error_codes.h"

@@ -41,9 +40,9 @@ class AclGrphParseUtil {
static domi::Status LoadOpsProtoLib();
static void SaveCustomCaffeProtoPath();
domi::Status AclParserInitialize(const std::map<std::string, std::string> &options);
domi::Status SetOutputNodeInfo(ge::Graph &graph, const std::map<AscendString, AscendString> &parser_params);
domi::Status SetOutputNodeInfo(ge::Graph &graph, const std::map<AscendString, AscendString> &parser_params) const;
domi::Status ParseParamsBeforeGraph(const std::map<AscendString, AscendString> &parser_params,
std::string &graph_name);
std::string &graph_name) const;
domi::Status ParseParamsAfterGraph(ge::Graph &graph, const std::map<AscendString,
AscendString> &parser_params) const;

@@ -67,31 +66,23 @@ class AclGrphParseUtil {
};

namespace parser {
///
/// @ingroup: domi_common
/// @brief: get length of file
/// @param [in] input_file: path of file
/// @return long: File length. If the file length fails to be obtained, the value -1 is returned.
///
extern long GetFileLength(const std::string &input_file);

///
/// @ingroup domi_common
/// @brief Absolute path for obtaining files.
/// @param [in] path of input file
/// @param [out] Absolute path of a file. If the absolute path cannot be obtained, an empty string is returned
///
std::string RealPath(const char *path);

///
/// @ingroup domi_common
/// @brief Obtains the absolute time (timestamp) of the current system.
/// @return Timestamp, in microseconds (US)
///
///
uint64_t GetCurrentTimestamp();

///
/// @ingroup domi_common
/// @brief Reads all data from a binary file.
/// @param [in] file_name path of file
@@ -99,20 +90,16 @@ uint64_t GetCurrentTimestamp();
/// @param [out] length Output memory size
/// @return false fail
/// @return true success
///
bool ReadBytesFromBinaryFile(const char *file_name, char **buffer, int &length);

///
/// @ingroup domi_common
/// @brief proto file in bianary format
/// @param [in] file path of proto file
/// @param [out] proto memory for storing the proto file
/// @return true success
/// @return false fail
///
bool ReadProtoFromBinaryFile(const char *file, Message *proto);

///
/// @ingroup domi_common
/// @brief Reads the proto structure from an array.
/// @param [in] data proto data to be read
@@ -120,42 +107,33 @@ bool ReadProtoFromBinaryFile(const char *file, Message *proto);
/// @param [out] proto Memory for storing the proto file
/// @return true success
/// @return false fail
///
bool ReadProtoFromArray(const void *data, int size, Message *proto);

///
/// @ingroup domi_proto
/// @brief Reads the proto file in the text format.
/// @param [in] file path of proto file
/// @param [out] message Memory for storing the proto file
/// @return true success
/// @return false fail
///
bool ReadProtoFromText(const char *file, google::protobuf::Message *message);

bool ReadProtoFromMem(const char *data, int size, google::protobuf::Message *message);

///
/// @brief get the Original Type of FrameworkOp
/// @param [in] node
/// @param [out] type
/// @return Status
///
domi::Status GetOriginalType(const ge::NodePtr &node, string &type);

///
/// @ingroup domi_common
/// @brief Check whether the file path meets the whitelist verification requirements.
/// @param [in] filePath file path
/// @param [out] result
///
bool ValidateStr(const std::string &filePath, const std::string &mode);

///
/// @ingroup domi_common
/// @brief Obtains the current time string.
/// @return Time character string in the format: %Y%m%d%H%M%S, eg: 20171011083555
///
std::string CurrentTimeInStr();

template <typename T, typename... Args>


Loading…
Cancel
Save